Skip to content

Commit fa9f22e

Browse files
committed
fix kernel disposing problem
1 parent 0997bfe commit fa9f22e

3 files changed

Lines changed: 37 additions & 22 deletions

File tree

client/lib/devices/borneo/lyfi/views/dashboard/dashboard_view.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ class DashboardView extends StatelessWidget {
386386
? Theme.of(context).colorScheme.primaryContainer
387387
: null,
388388
icon: AnimatedSwitcher(
389-
duration: Duration(milliseconds: 500),
389+
duration: const Duration(milliseconds: 500),
390390
child:
391391
props.state == LedState.temporary
392392
? IconProgressBar(
393-
icon: Icon(Icons.flashlight_on, size: 40),
393+
icon: const Icon(Icons.flashlight_on, size: 40),
394394
progress:
395395
(props.total.inSeconds - props.remain.inSeconds) / props.total.inSeconds,
396396
size: 40,
@@ -403,7 +403,7 @@ class DashboardView extends StatelessWidget {
403403
? Theme.of(context).colorScheme.onPrimaryContainer
404404
: Theme.of(context).colorScheme.primaryContainer,
405405
)
406-
: Icon(Icons.flashlight_on, size: 40),
406+
: const Icon(Icons.flashlight_on, size: 40),
407407
),
408408

409409
onPressed:
@@ -485,7 +485,7 @@ class DashboardView extends StatelessWidget {
485485
borderColor: Theme.of(context).colorScheme.primary,
486486
text: "Settings",
487487
buttonSize: 64,
488-
icon: Icon(Icons.settings_outlined, size: 40),
488+
icon: const Icon(Icons.settings_outlined, size: 40),
489489
onPressed:
490490
props.isOnline
491491
? () async {

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

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ class SettingsScreen extends StatelessWidget {
4747
const rightChevron = CupertinoListTileChevron();
4848
final tileColor = Theme.of(context).colorScheme.surfaceContainer;
4949
return <Widget>[
50-
ListTile(title: const Text('DEVICE INFORMATION')),
50+
ListTile(dense: true, title: Text('DEVICE INFORMATION', style: Theme.of(context).textTheme.titleSmall)),
5151
ListTile(
52+
dense: true,
5253
tileColor: tileColor,
5354
leading: Icon(Icons.info_outline),
5455
title: Text('Name'),
@@ -57,6 +58,7 @@ class SettingsScreen extends StatelessWidget {
5758
onTap: () {},
5859
),
5960
ListTile(
61+
dense: true,
6062
tileColor: tileColor,
6163
leading: Icon(Icons.factory_outlined),
6264
title: const Text('Manufacturer & Model'),
@@ -66,24 +68,26 @@ class SettingsScreen extends StatelessWidget {
6668
),
6769
),
6870
ListTile(
71+
dense: true,
6972
tileColor: tileColor,
70-
leading: Icon(Icons.numbers_outlined),
73+
leading: const Icon(Icons.numbers_outlined),
7174
title: Text('Serial number'),
72-
subtitle: Text(vm.borneoInfo.serno.substring(0, 12)),
75+
trailing: Text(vm.borneoInfo.serno.substring(0, 12)),
7376
),
7477
ListTile(
78+
dense: true,
7579
tileColor: tileColor,
76-
leading: Icon(Icons.info_outline),
80+
leading: _buildWifiRssiIcon(context),
7781
title: Text('Device address'),
78-
subtitle: Text(vm.address.toString()),
79-
trailing: _buildWifiRssiIcon(context),
82+
trailing: Text(vm.address.toString()),
8083
),
8184

8285
// Location
8386
Selector<SettingsViewModel, ({bool canUpdate, GeoLocation? location})>(
8487
selector: (_, vm) => (canUpdate: vm.canUpdateGeoLocation, location: vm.location),
8588
builder:
8689
(context, map, _) => ListTile(
90+
dense: true,
8791
tileColor: tileColor,
8892
leading: const Icon(Icons.location_pin),
8993
title: Text('Location'),
@@ -96,14 +100,15 @@ class SettingsScreen extends StatelessWidget {
96100
),
97101
),
98102

99-
ListTile(title: Text('DEVICE STATUS')),
103+
ListTile(dense: true, title: Text('DEVICE STATUS', style: Theme.of(context).textTheme.titleSmall)),
100104

101105
Selector<SettingsViewModel, ({bool canUpdate, String? tz, DateTime timestamp})>(
102106
selector: (_, vm) => (canUpdate: vm.canUpdateTimezone, tz: vm.timezone, timestamp: vm.borneoStatus.timestamp),
103107
builder:
104108
(context, map, _) => ListTile(
109+
dense: true,
105110
tileColor: tileColor,
106-
leading: Icon(Icons.access_time_outlined),
111+
leading: const Icon(Icons.access_time_outlined),
107112
title: Text('Device time & time zone'),
108113
subtitle: Column(
109114
crossAxisAlignment: CrossAxisAlignment.start,
@@ -118,7 +123,8 @@ class SettingsScreen extends StatelessWidget {
118123
selector: (_, vm) => (canUpdate: vm.canUpdatePowerBehavior, behavior: vm.powerBehavior),
119124
builder:
120125
(context, map, _) => ListTile(
121-
leading: Icon(Icons.settings_power_outlined),
126+
dense: true,
127+
leading: const Icon(Icons.settings_power_outlined),
122128
tileColor: tileColor,
123129
title: Text('Power status at startup'),
124130
trailing: DropdownButton<PowerBehavior>(
@@ -145,20 +151,22 @@ class SettingsScreen extends StatelessWidget {
145151
),
146152

147153
ListTile(
154+
dense: true,
148155
tileColor: tileColor,
149-
leading: Icon(Icons.power_off),
156+
leading: const Icon(Icons.power_off),
150157
title: Text('Last shutdown'),
151158
trailing: Text(vm.borneoStatus.shutdownTimestamp?.toString() ?? 'N/A'),
152159
subtitle: Text("Reason code: ${vm.borneoStatus.shutdownReason}"),
153160
),
154161

155162
// LED Lighting settings
156-
ListTile(title: Text('LIGHTING')),
163+
ListTile(dense: true, title: Text('LIGHTING', style: Theme.of(context).textTheme.titleSmall)),
157164

158165
Selector<SettingsViewModel, ({bool canUpdate, LedCorrectionMethod correctionMethod})>(
159166
selector: (_, vm) => (canUpdate: vm.canUpdateCorrectionMethod, correctionMethod: vm.correctionMethod),
160167
builder:
161168
(context, map, _) => ListTile(
169+
dense: true,
162170
tileColor: tileColor,
163171
title: Text('Correction curve'),
164172
trailing: Selector<SettingsViewModel, LedCorrectionMethod>(
@@ -200,6 +208,7 @@ class SettingsScreen extends StatelessWidget {
200208
selector: (_, vm) => (canUpdate: vm.canUpdateTemporaryDuration, duration: vm.temporaryDuration),
201209
builder:
202210
(context, map, _) => ListTile(
211+
dense: true,
203212
tileColor: tileColor,
204213
title: Text('Temporary light on duration'),
205214
trailing: Selector<SettingsViewModel, Duration>(
@@ -250,15 +259,17 @@ class SettingsScreen extends StatelessWidget {
250259
),
251260

252261
// Version & upgrade group
253-
ListTile(title: Text('VERSION & UPGRADE')),
262+
ListTile(dense: true, title: Text('VERSION & UPGRADE', style: Theme.of(context).textTheme.titleSmall)),
254263
ListTile(
255-
leading: Icon(Icons.info_outline),
264+
dense: true,
265+
leading: const Icon(Icons.info_outline),
256266
tileColor: tileColor,
257267
title: Text('Hardware version'),
258268
trailing: Text(vm.borneoInfo.hwVer.toString()),
259269
),
260270
ListTile(
261-
leading: Icon(Icons.info_outline),
271+
dense: true,
272+
leading: const Icon(Icons.info_outline),
262273
tileColor: tileColor,
263274
title: Text('Firmware version'),
264275
trailing: Text(vm.borneoInfo.fwVer.toString()),
@@ -276,6 +287,7 @@ class SettingsScreen extends StatelessWidget {
276287
),
277288
*/
278289
ListTile(
290+
dense: true,
279291
title: Row(
280292
children: [
281293
Icon(Icons.warning, size: 24, color: Theme.of(context).colorScheme.error),
@@ -285,6 +297,7 @@ class SettingsScreen extends StatelessWidget {
285297
),
286298
),
287299
ListTile(
300+
dense: true,
288301
leading: Icon(Icons.restore_outlined),
289302
tileColor: tileColor,
290303
title: Text('Restore to factory settings', style: TextStyle(color: Theme.of(context).colorScheme.error)),

client/lib/main.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,25 @@ Future<void> main() async {
6666
),
6767

6868
// mDns provider
69-
Provider<IMdnsProvider>(create: (_) => NsdMdnsProvider(), lazy: false),
69+
Provider<IMdnsProvider>(create: (_) => NsdMdnsProvider(), lazy: true),
7070

7171
// IDeviceModuleRegistry
7272
Provider<IDeviceModuleRegistry>(create: (_) => DeviceModuleRegistry(StaticDeviceModuleHarvester()), lazy: true),
7373

7474
// RouteManager
75-
ProxyProvider<IDeviceModuleRegistry, RouteManager>(update: (_, reg, __) => RouteManager(reg), lazy: true),
75+
ProxyProvider<IDeviceModuleRegistry, RouteManager>(update: (_, reg, rm) => rm ?? RouteManager(reg), lazy: true),
7676

7777
// IDriverRegistry
7878
ProxyProvider<IDeviceModuleRegistry, IDriverRegistry>(
79-
update: (_, reg, __) => StaticModularDriverRegistry(reg),
79+
update: (_, reg, smdr) => smdr ?? StaticModularDriverRegistry(reg),
8080
lazy: true,
8181
),
8282

8383
// IKernel
8484
ProxyProvider3<Logger, IDriverRegistry, IMdnsProvider, IKernel>(
85-
update: (_, logger, driverReg, nsdMdns, __) => DefaultKernel(logger, driverReg, mdnsProvider: nsdMdns),
85+
update:
86+
(_, logger, driverReg, nsdMdns, kernel) =>
87+
kernel ?? DefaultKernel(logger, driverReg, mdnsProvider: nsdMdns),
8688
dispose: (context, kernel) => kernel.dispose(),
8789
lazy: true,
8890
),

0 commit comments

Comments
 (0)