Skip to content

Commit d4b5530

Browse files
committed
refactor: Simplify navigation bar interaction and improve device discovery UI
1 parent e768917 commit d4b5530

3 files changed

Lines changed: 69 additions & 69 deletions

File tree

client/lib/devices/borneo/lyfi/manifest.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ class LyfiDeviceModuleMetadata extends DeviceModuleMetadata {
105105
static String _modeText(BuildContext context, LyfiMode? mode) {
106106
switch (mode) {
107107
case LyfiMode.manual:
108-
return context.translate('Manual');
108+
return context.translate('MANU');
109109
case LyfiMode.scheduled:
110-
return context.translate('Scheduled');
110+
return context.translate('SCHED');
111111
case LyfiMode.sun:
112-
return context.translate('Sun');
112+
return context.translate('SUN');
113113
default:
114114
return '-';
115115
}
@@ -118,13 +118,13 @@ class LyfiDeviceModuleMetadata extends DeviceModuleMetadata {
118118
static String _stateText(BuildContext context, LyfiState? state) {
119119
switch (state) {
120120
case LyfiState.normal:
121-
return context.translate('Running');
121+
return context.translate('NORM');
122122
case LyfiState.dimming:
123-
return context.translate('Dimming');
123+
return context.translate('DIMM');
124124
case LyfiState.temporary:
125-
return context.translate('Temporary');
125+
return context.translate('TEMP');
126126
case LyfiState.preview:
127-
return context.translate('Preview');
127+
return context.translate('PREV');
128128
default:
129129
return '-';
130130
}

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

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DeviceDiscoveryScreen extends StatelessWidget {
3232
globalEventBus: cb.read<EventBus>(),
3333
gt: gt,
3434
logger: cb.read<Logger>(),
35-
)..onInitialize(),
35+
)..initialize(),
3636
child: const _DeviceDiscoveryContent(),
3737
);
3838
}
@@ -53,13 +53,7 @@ class _DeviceDiscoveryContent extends StatelessWidget {
5353
selector: (_, vm) => vm.isDiscovering,
5454
builder: (ctx, isDiscovering, child) {
5555
if (isDiscovering) {
56-
return TextButton(
57-
onPressed: () => ctx.read<DeviceDiscoveryViewModel>().stopDiscovery(),
58-
child: Text(
59-
context.translate('Stop'),
60-
style: TextStyle(color: Theme.of(context).colorScheme.primary),
61-
),
62-
);
56+
return const SizedBox();
6357
} else {
6458
return IconButton(
6559
icon: const Icon(Icons.refresh),
@@ -124,30 +118,38 @@ class _DeviceDiscoveryContent extends StatelessWidget {
124118

125119
return Stack(
126120
children: [
127-
if (devices.isEmpty)
128-
ListView(
129-
children: [
130-
const SizedBox(height: 60),
131-
Center(
132-
child: Column(
133-
mainAxisAlignment: MainAxisAlignment.center,
134-
children: [
135-
Icon(
136-
Icons.media_bluetooth_off,
137-
size: 64,
138-
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.38),
139-
),
140-
const SizedBox(height: 16),
141-
Text(
142-
context.translate('No devices found'),
143-
style: Theme.of(
144-
context,
145-
).textTheme.bodyLarge?.copyWith(color: Theme.of(context).colorScheme.outline),
146-
),
147-
],
121+
if (devices.isEmpty && vm.isInitialized && !vm.isDiscovering && !vm.isBusy && !vm.isDisposed)
122+
Center(
123+
child: Column(
124+
children: [
125+
const SizedBox(height: 60),
126+
Center(
127+
child: Column(
128+
mainAxisAlignment: MainAxisAlignment.center,
129+
children: [
130+
Icon(
131+
Icons.media_bluetooth_off,
132+
size: 64,
133+
color: Theme.of(context).colorScheme.outline.withValues(alpha: 0.38),
134+
),
135+
const SizedBox(height: 16),
136+
Text(
137+
context.translate('No devices found'),
138+
style: Theme.of(
139+
context,
140+
).textTheme.bodyLarge?.copyWith(color: Theme.of(context).colorScheme.outline),
141+
),
142+
const SizedBox(height: 16),
143+
ElevatedButton.icon(
144+
onPressed: () => context.read<DeviceDiscoveryViewModel>().startDiscovery(),
145+
icon: const Icon(Icons.refresh),
146+
label: Text(context.translate('Scan')),
147+
),
148+
],
149+
),
148150
),
149-
),
150-
],
151+
],
152+
),
151153
)
152154
else
153155
ListView.separated(
@@ -174,6 +176,11 @@ class _DeviceDiscoveryContent extends StatelessWidget {
174176
context.translate('Searching for devices...'),
175177
style: Theme.of(context).textTheme.bodyLarge,
176178
),
179+
const SizedBox(height: 16),
180+
TextButton(
181+
onPressed: () => context.read<DeviceDiscoveryViewModel>().stopDiscovery(),
182+
child: Text(context.translate('Cancel')),
183+
),
177184
],
178185
),
179186
),

client/lib/main/views/main_screen.dart

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -197,37 +197,30 @@ class _MainScreenState extends State<MainScreen> {
197197
],
198198
),
199199

200-
bottomNavigationBar: SafeArea(
201-
child: BottomNavigationBar(
202-
currentIndex: tabIndex.index,
203-
onTap: (index) {
204-
if (index != tabIndex.index) {
205-
_pageController.animateToPage(
206-
index,
207-
duration: const Duration(milliseconds: 300),
208-
curve: Curves.easeOutCubic,
209-
);
210-
// onPageChanged will sync the VM index
211-
}
212-
},
213-
items: [
214-
BottomNavigationBarItem(
215-
icon: const Icon(Icons.house_outlined),
216-
activeIcon: const Icon(Icons.house),
217-
label: context.translate('Scenes'),
218-
),
219-
BottomNavigationBarItem(
220-
icon: const Icon(Icons.device_hub_outlined),
221-
activeIcon: const Icon(Icons.device_hub),
222-
label: context.translate('Devices'),
223-
),
224-
BottomNavigationBarItem(
225-
icon: const Icon(Icons.person_outline),
226-
activeIcon: const Icon(Icons.person),
227-
label: context.translate('My'),
228-
),
229-
],
230-
),
200+
bottomNavigationBar: BottomNavigationBar(
201+
currentIndex: tabIndex.index,
202+
onTap: (index) {
203+
if (index != tabIndex.index) {
204+
_pageController.jumpToPage(index);
205+
}
206+
},
207+
items: [
208+
BottomNavigationBarItem(
209+
icon: const Icon(Icons.house_outlined),
210+
activeIcon: const Icon(Icons.house),
211+
label: context.translate('Scenes'),
212+
),
213+
BottomNavigationBarItem(
214+
icon: const Icon(Icons.device_hub_outlined),
215+
activeIcon: const Icon(Icons.device_hub),
216+
label: context.translate('Devices'),
217+
),
218+
BottomNavigationBarItem(
219+
icon: const Icon(Icons.person_outline),
220+
activeIcon: const Icon(Icons.person),
221+
label: context.translate('My'),
222+
),
223+
],
231224
),
232225
),
233226
);

0 commit comments

Comments
 (0)