@@ -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 ),
0 commit comments