Hide schedule report feature if not yet supported

This commit is contained in:
Hillel Coren 2024-01-23 15:44:21 +02:00
parent 16e1ff7b50
commit a51fbf3746
3 changed files with 38 additions and 29 deletions

View File

@ -385,13 +385,14 @@ class ReportsScreen extends StatelessWidget {
viewModel.onExportPressed(context);
},
),
AppTextButton(
label: localization.schedule,
isInHeader: true,
onPressed: () {
viewModel.onSchedulePressed(context);
},
),
if (supportsLatestFeatures('5.8.0'))
AppTextButton(
label: localization.schedule,
isInHeader: true,
onPressed: () {
viewModel.onSchedulePressed(context);
},
),
],
Padding(
padding: const EdgeInsets.only(right: 8),
@ -545,15 +546,17 @@ class ReportsScreen extends StatelessWidget {
},
),
),
SizedBox(width: kGutterWidth),
Expanded(
child: AppButton(
label: localization.schedule,
onPressed: () {
viewModel.onSchedulePressed(context);
},
if (supportsLatestFeatures('5.8.0')) ...[
SizedBox(width: kGutterWidth),
Expanded(
child: AppButton(
label: localization.schedule,
onPressed: () {
viewModel.onSchedulePressed(context);
},
),
),
),
],
],
),
),

View File

@ -19,6 +19,7 @@ import 'package:invoiceninja_flutter/ui/schedule/edit/schedule_edit_vm.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/completers.dart';
import 'package:invoiceninja_flutter/ui/app/scrollable_listview.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart';
import 'package:invoiceninja_flutter/utils/strings.dart';
class ScheduleEdit extends StatefulWidget {
@ -163,6 +164,9 @@ class _ScheduleEditState extends State<ScheduleEdit> {
);
},
items: ScheduleEntity.TEMPLATES
.where((entry) =>
supportsLatestFeatures('5.8.0') ||
entry != ScheduleEntity.TEMPLATE_EMAIL_REPORT)
.map((entry) => DropdownMenuItem(
value: entry,
child: Text(localization.lookup(entry)),

View File

@ -356,20 +356,22 @@ class _ImportExportState extends State<ImportExport> {
},
),
),
SizedBox(width: kGutterWidth),
Expanded(
child: AppButton(
label: localization.schedule,
iconData: Icons.schedule,
onPressed: () {
createEntity(
entity: ScheduleEntity(
ScheduleEntity.TEMPLATE_EMAIL_REPORT)
.rebuild((b) => b
..parameters.reportName =
_exportType.name));
},
))
if (supportsLatestFeatures('5.8.0')) ...[
SizedBox(width: kGutterWidth),
Expanded(
child: AppButton(
label: localization.schedule,
iconData: Icons.schedule,
onPressed: () {
createEntity(
entity: ScheduleEntity(
ScheduleEntity.TEMPLATE_EMAIL_REPORT)
.rebuild((b) => b
..parameters.reportName =
_exportType.name));
},
))
],
],
)
],