dev
dart 60 lines 1.91 KB
Raw
1 import 'package:cake_wallet/generated/i18n.dart';
2 import 'package:cw_core/sync_status.dart';
3 import 'package:flutter/material.dart';
4
5 class SendSyncingIndicator extends StatelessWidget {
6 const SendSyncingIndicator({super.key, required this.status});
7
8 final SyncStatus status;
9
10 static const outlineColor = Color(0xFFFFB84E);
11 static const backgroundColor = Color(0xFF8E5800);
12
13 @override
14 Widget build(BuildContext context) {
15 late final String eta;
16 if (status is SyncingSyncStatus) {
17 eta = (status as SyncingSyncStatus).getFormattedEta() ?? "";
18 } else {
19 eta = "";
20 }
21
22 final statusText = "${S.of(context).synchronizing}... ${eta}";
23
24 // A single status node: progress ticks keep updating the value, and without a live
25 // region they do not interrupt the user on every tick.
26 return Semantics(
27 container: true,
28 label: statusText,
29 value: status.progress() > 0 ? "${(status.progress() * 100).round()}%" : null,
30 excludeSemantics: true,
31 child: Container(
32 height: 48,
33 decoration:
34 BoxDecoration(color: backgroundColor, borderRadius: BorderRadius.circular(99999)),
35 child: Padding(
36 padding: const EdgeInsets.symmetric(horizontal: 12.0),
37 child: Row(
38 mainAxisSize: MainAxisSize.min,
39 spacing: 10,
40 children: [
41 if (status.progress() > 0)
42 SizedBox(
43 width: 24,
44 height: 24,
45 child: CircularProgressIndicator(
46 value: status.progress(),
47 strokeWidth: 3,
48 strokeCap: StrokeCap.round,
49 color: outlineColor,
50 semanticsLabel: S.of(context).synchronizing,
51 ),
52 ),
53 Text(statusText, style: TextStyle(color: outlineColor)),
54 ],
55 ),
56 ),
57 ),
58 );
59 }
60 }