Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Jul 13, 2023
2 parents fbd4d04 + c593c50 commit 70cf4ea
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 19 deletions.
7 changes: 6 additions & 1 deletion lib/data/models/account_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ abstract class AccountEntity
setReactAsDefaultAP: false,
trialDaysLeft: 0,
hasIapPlan: false,
paymentId: '',
);
}

Expand Down Expand Up @@ -107,6 +108,9 @@ abstract class AccountEntity
@BuiltValueField(wireName: 'has_iap_plan')
bool get hasIapPlan;

@BuiltValueField(wireName: 'payment_id')
String get paymentId;

bool get isUpdateAvailable {
if (disableAutoUpdate) {
return false;
Expand Down Expand Up @@ -141,7 +145,8 @@ abstract class AccountEntity
..hostedClientCount = 0
..hostedCompanyCount = 1
..accountSmsVerified = true
..setReactAsDefaultAP = false;
..setReactAsDefaultAP = false
..paymentId = '';

static Serializer<AccountEntity> get serializer => _$accountEntitySerializer;
}
29 changes: 25 additions & 4 deletions lib/data/models/account_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/data/models/document_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ abstract class DocumentEntity extends Object
fileName.endsWith('.webp');
}

bool get isPdf {
final fileName = name.toLowerCase();
return fileName.endsWith('.pdf');
}

int compareTo(DocumentEntity document,
[String sortField, bool sortAscending = true]) {
int response = 0;
Expand Down
41 changes: 28 additions & 13 deletions lib/ui/app/document_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pinch_zoom/pinch_zoom.dart';
import 'package:printing/printing.dart';
import 'package:share_plus/share_plus.dart';

// Project imports:
Expand Down Expand Up @@ -312,17 +313,31 @@ class DocumentTile extends StatelessWidget {
context: navigatorKey.currentContext,
builder: (context) {
return AlertDialog(
actions: [
TextButton(
onPressed: () =>
Navigator.of(context).pop(),
child: Text(localization.close
.toUpperCase())),
],
content: PinchZoom(
child: Image.memory(
response.bodyBytes),
));
actions: [
TextButton(
onPressed: () =>
Navigator.of(context).pop(),
child: Text(localization.close
.toUpperCase())),
],
content: document.isImage
? PinchZoom(
child: Image.memory(
response.bodyBytes),
)
: SizedBox(
width: 600,
child: PdfPreview(
build: (format) =>
response.bodyBytes,
canChangeOrientation: false,
canChangePageFormat: false,
allowPrinting: false,
allowSharing: false,
canDebug: false,
),
),
);
});
} else if (value == localization.download) {
final http.Response response = await WebClient()
Expand Down Expand Up @@ -399,7 +414,7 @@ class DocumentTile extends StatelessWidget {
},
itemBuilder: (context) {
return [
if (document.isImage)
if (document.isImage || document.isPdf)
PopupMenuItem<String>(
child: IconText(
text: localization.view,
Expand Down Expand Up @@ -455,7 +470,7 @@ class DocumentPreview extends StatelessWidget {
Widget build(BuildContext context) {
final state = StoreProvider.of<AppState>(context).state;

if (['png', 'jpg', 'jpeg'].contains(document.type)) {
if (document.isImage) {
return CachedNetworkImage(
height: height,
width: double.infinity,
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/settings/account_management.dart
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ class _AccountOverview extends StatelessWidget {
),
),
onPressed: () {
if (supportsInAppPurchase() && !account.hasIapPlan) {
if (supportsInAppPurchase() &&
!account.hasIapPlan &&
account.paymentId.isEmpty) {
showDialog<void>(
context: context,
builder: (context) => UpgradeDialog(),
Expand Down

0 comments on commit 70cf4ea

Please sign in to comment.