Skip to content

Commit 2b5e4c1

Browse files
committed
feat: replace FilledButton with TextButton in multiple screens and update navigation to use PersistentNavBarNavigator
1 parent 1a4031f commit 2b5e4c1

File tree

13 files changed

+1261
-545
lines changed

13 files changed

+1261
-545
lines changed

client/assets/i18n/de.po

Lines changed: 341 additions & 100 deletions
Large diffs are not rendered by default.

client/assets/i18n/en_US.po

Lines changed: 103 additions & 100 deletions
Large diffs are not rendered by default.

client/assets/i18n/es.po

Lines changed: 339 additions & 100 deletions
Large diffs are not rendered by default.

client/assets/i18n/messages.pot

Lines changed: 103 additions & 100 deletions
Large diffs are not rendered by default.

client/assets/i18n/zh_CN.po

Lines changed: 338 additions & 100 deletions
Large diffs are not rendered by default.

client/lib/devices/borneo/lyfi/views/settings_screen.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,7 @@ class SettingsScreen extends StatelessWidget {
319319
),
320320
actions: [
321321
TextButton(onPressed: () => Navigator.of(context).pop(), child: Text(context.translate('Cancel'))),
322-
FilledButton.tonal(
323-
style: FilledButton.styleFrom(
324-
backgroundColor: Theme.of(context).colorScheme.errorContainer,
325-
foregroundColor: Theme.of(context).colorScheme.onErrorContainer,
326-
),
322+
TextButton(
327323
onPressed: () {
328324
Navigator.of(context).pop();
329325
// after the factory reset completes navigate all the way back to the
@@ -402,7 +398,7 @@ class SettingsScreen extends StatelessWidget {
402398
),
403399
actions: [
404400
TextButton(onPressed: () => Navigator.of(context).pop(), child: Text(context.translate('Cancel'))),
405-
FilledButton(
401+
TextButton(
406402
onPressed: () async {
407403
Navigator.of(context).pop();
408404
await vm.updateManualFanPower(tempValue.toInt());
@@ -460,7 +456,7 @@ class SettingsScreen extends StatelessWidget {
460456
onPressed: vm.isBusy ? null : () => Navigator.of(context).pop(),
461457
child: Text(context.translate('Cancel')),
462458
),
463-
FilledButton(
459+
TextButton(
464460
onPressed: vm.isBusy || errorText != null
465461
? null
466462
: () async {

client/lib/devices/views/device_ota_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class _DeviceOtaScreenState extends State<DeviceOtaScreen> with TickerProviderSt
8989
),
9090
actions: [
9191
TextButton(onPressed: () => Navigator.of(ctx).pop(false), child: Text(context.translate('Cancel'))),
92-
FilledButton(onPressed: () => Navigator.of(ctx).pop(true), child: Text(context.translate('Update Now'))),
92+
TextButton(onPressed: () => Navigator.of(ctx).pop(true), child: Text(context.translate('Update Now'))),
9393
],
9494
),
9595
);

client/lib/features/devices/views/devices_screen.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import 'dart:io';
22
import 'dart:ui';
33

44
import 'package:borneo_app/features/devices/providers/group_edit_provider.dart';
5+
import 'package:persistent_bottom_nav_bar/persistent_bottom_nav_bar.dart';
56
import 'package:flutter_gettext/flutter_gettext/context_ext.dart';
67
import 'package:flutter/material.dart';
78
import 'package:provider/provider.dart';
89

910
import 'package:borneo_app/features/devices/models/device_group_entity.dart';
10-
import 'package:borneo_app/routes/app_routes.dart';
1111
import 'package:borneo_app/features/devices/view_models/group_view_model.dart';
1212
import 'package:borneo_app/features/devices/views/device_card.dart';
1313
import 'package:borneo_app/features/devices/view_models/grouped_devices_view_model.dart';
1414
import 'package:borneo_app/core/models/scene_entity.dart';
1515
import 'package:borneo_app/devices/view_models/abstract_device_summary_view_model.dart';
1616
import 'package:borneo_app/features/devices/widgets/empty_groups_widget.dart';
17+
import 'package:borneo_app/features/devices/views/device_discovery_screen.dart';
1718
import 'group_edit_screen.dart';
1819

1920
class GroupSnapshot {
@@ -43,7 +44,11 @@ class NoDataHintView extends StatelessWidget {
4344
hasScrollBody: false,
4445
child: EmptyGroupsWidget(
4546
onCreateGroup: () async {
46-
await Navigator.of(context).pushNamed(AppRoutes.kDeviceDiscovery);
47+
await PersistentNavBarNavigator.pushNewScreen(
48+
context,
49+
screen: const DeviceDiscoveryScreen(),
50+
withNavBar: false,
51+
);
4752
// Refresh after adding devices
4853
if (context.mounted) {
4954
context.read<GroupedDevicesViewModel>().refresh();
@@ -60,16 +65,15 @@ class DevicesScreen extends StatelessWidget {
6065
static const _smallShadow = Shadow(offset: Offset(1.0, 1.0), blurRadius: 2.0, color: Color.fromARGB(128, 0, 0, 0));
6166

6267
Future<void> _showDiscoveryPage(BuildContext context) async {
63-
await Navigator.of(context).pushNamed(AppRoutes.kDeviceDiscovery);
68+
await PersistentNavBarNavigator.pushNewScreen(context, screen: const DeviceDiscoveryScreen(), withNavBar: false);
6469
}
6570

6671
Future<void> _showNewGroupScreen(BuildContext context) async {
67-
final result = await Navigator.push<bool>(
72+
final result = await PersistentNavBarNavigator.pushNewScreen<bool>(
6873
context,
69-
MaterialPageRoute(
70-
builder: (context) => GroupEditScreen(),
71-
settings: RouteSettings(arguments: GroupEditArguments(isCreation: true)),
72-
),
74+
screen: const GroupEditScreen(args: GroupEditArguments(isCreation: true)),
75+
withNavBar: false,
76+
pageTransitionAnimation: PageTransitionAnimation.cupertino,
7377
);
7478

7579
// Refresh if group was created
@@ -321,12 +325,11 @@ class DevicesScreen extends StatelessWidget {
321325
}
322326

323327
void _showEditGroupPage(BuildContext context, DeviceGroupEntity group) async {
324-
final result = await Navigator.push<bool>(
328+
final result = await PersistentNavBarNavigator.pushNewScreen<bool>(
325329
context,
326-
MaterialPageRoute(
327-
builder: (context) => GroupEditScreen(),
328-
settings: RouteSettings(arguments: GroupEditArguments(isCreation: false, model: group)),
329-
),
330+
screen: GroupEditScreen(args: GroupEditArguments(isCreation: false, model: group)),
331+
withNavBar: false,
332+
pageTransitionAnimation: PageTransitionAnimation.cupertino,
330333
);
331334

332335
// Refresh if group was deleted or updated

client/lib/features/devices/views/group_edit_screen.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import 'package:borneo_app/shared/widgets/confirmation_sheet.dart';
1818
/// Riverpod provider overrides so that the inner [_GroupEditBody] can be a
1919
/// pure Riverpod consumer.
2020
class GroupEditScreen extends StatelessWidget {
21-
const GroupEditScreen({super.key});
21+
final GroupEditArguments args;
22+
23+
const GroupEditScreen({super.key, required this.args});
2224

2325
@override
2426
Widget build(BuildContext context) {
25-
final args = ModalRoute.of(context)!.settings.arguments as GroupEditArguments;
2627
final groupManager = legacy.Provider.of<IGroupManager>(context, listen: false);
2728

2829
return ProviderScope(

client/lib/features/scenes/views/scene_edit_screen.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class _SceneEditBodyState extends ConsumerState<_SceneEditBody> {
338338
sourcePath: picked.path,
339339
uiSettings: [
340340
AndroidUiSettings(
341-
toolbarTitle: 'Crop Image',
341+
toolbarTitle: context.translate('Crop Image'),
342342
toolbarColor: theme.colorScheme.primary,
343343
toolbarWidgetColor: Colors.white,
344344
initAspectRatio: CropAspectRatioPreset.ratio16x9,
@@ -351,6 +351,8 @@ class _SceneEditBodyState extends ConsumerState<_SceneEditBody> {
351351
),
352352
IOSUiSettings(
353353
title: 'Crop Image',
354+
doneButtonTitle: context.translate('Done'),
355+
cancelButtonTitle: context.translate('Cancel'),
354356
aspectRatioPresets: [
355357
CropAspectRatioPreset.ratio16x9,
356358
CropAspectRatioPreset.original,

0 commit comments

Comments
 (0)