mirror of
https://github.com/ente-io/ente.git
synced 2025-08-09 07:48:52 +00:00
[mob][photos] Show loading indicator on device tap
This commit is contained in:
parent
b12e6221d4
commit
bd07759d8e
@ -23,11 +23,11 @@ class AutoCastDialog extends StatefulWidget {
|
|||||||
|
|
||||||
class _AutoCastDialogState extends State<AutoCastDialog> {
|
class _AutoCastDialogState extends State<AutoCastDialog> {
|
||||||
final bool doesUserExist = true;
|
final bool doesUserExist = true;
|
||||||
|
final Set<Object> _isDeviceTapInProgress = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final textStyle = getEnteTextTheme(context);
|
final textStyle = getEnteTextTheme(context);
|
||||||
|
|
||||||
final AlertDialog alert = AlertDialog(
|
final AlertDialog alert = AlertDialog(
|
||||||
title: Text(
|
title: Text(
|
||||||
S.of(context).connectToDevice,
|
S.of(context).connectToDevice,
|
||||||
@ -65,19 +65,39 @@ class _AutoCastDialogState extends State<AutoCastDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: snapshot.data!.map((result) {
|
children: snapshot.data!.map((result) {
|
||||||
final device = result.$2;
|
final device = result.$2;
|
||||||
final name = result.$1;
|
final name = result.$1;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
if (_isDeviceTapInProgress.contains(device)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_isDeviceTapInProgress.add(device);
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
await _connectToYourApp(context, device);
|
await _connectToYourApp(context, device);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showGenericErrorDialog(context: context, error: e)
|
showGenericErrorDialog(context: context, error: e)
|
||||||
.ignore();
|
.ignore();
|
||||||
|
} finally {
|
||||||
|
setState(() {
|
||||||
|
_isDeviceTapInProgress.remove(device);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(name),
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(child: Text(name)),
|
||||||
|
if (_isDeviceTapInProgress.contains(device))
|
||||||
|
const EnteLoadingWidget(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
);
|
||||||
@ -93,6 +113,8 @@ class _AutoCastDialogState extends State<AutoCastDialog> {
|
|||||||
BuildContext context,
|
BuildContext context,
|
||||||
Object castDevice,
|
Object castDevice,
|
||||||
) async {
|
) async {
|
||||||
|
// sleep for 10 seconds
|
||||||
|
await Future.delayed(const Duration(seconds: 10));
|
||||||
await castService.connectDevice(
|
await castService.connectDevice(
|
||||||
context,
|
context,
|
||||||
castDevice,
|
castDevice,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user