1
+import 'package:cake_wallet/di.dart';
2
+import 'package:cake_wallet/entities/preferences_key.dart';
3
+import 'package:cake_wallet/entities/service_status.dart';
4
+import 'package:cake_wallet/src/widgets/primary_button.dart';
5
+import 'package:cake_wallet/src/widgets/service_status_tile.dart';
6
+import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
7
+import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
8
+import 'package:flutter/material.dart';
9
+import 'package:shared_preferences/shared_preferences.dart';
10
+import 'package:url_launcher/url_launcher.dart';
11
+
12
+class ServicesUpdatesWidget extends StatelessWidget {
13
+ final Future<ServicesResponse> servicesResponse;
14
+
15
+ const ServicesUpdatesWidget(this.servicesResponse, {super.key});
16
+
17
+ @override
18
+ Widget build(BuildContext context) {
19
+ return Padding(
20
+ padding: const EdgeInsets.all(8.0),
21
+ child: FutureBuilder<ServicesResponse>(
22
+ future: servicesResponse,
23
+ builder: (context, state) {
24
+ return InkWell(
25
+ onTap: state.hasData
26
+ ? () {
27
+ // save currentSha when the user see the status
28
+ getIt
29
+ .get<SharedPreferences>()
30
+ .setString(PreferencesKey.serviceStatusShaKey, state.data!.currentSha);
31
+
32
+ showModalBottomSheet(
33
+ context: context,
34
+ shape: RoundedRectangleBorder(
35
+ borderRadius: BorderRadius.only(
36
+ topLeft: Radius.circular(50),
37
+ topRight: Radius.circular(50),
38
+ ),
39
+ ),
40
+ constraints: BoxConstraints(
41
+ maxHeight: MediaQuery.of(context).size.height / 2,
42
+ minHeight: MediaQuery.of(context).size.height / 4,
43
+ ),
44
+ builder: (context) {
45
+ Widget body;
46
+ if (state.data!.servicesStatus.isEmpty) {
47
+ body = Center(
48
+ child: Text("Everything is up and running as expected"),
49
+ );
50
+ } else {
51
+ body = SingleChildScrollView(
52
+ child: Column(
53
+ children: state.data!.servicesStatus
54
+ .map((status) => ServiceStatusTile(status))
55
+ .toList()),
56
+ );
57
+ }
58
+ return Padding(
59
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 20),
60
+ child: Stack(
61
+ children: [
62
+ body,
63
+ Align(
64
+ alignment: Alignment.bottomCenter,
65
+ child: Padding(
66
+ padding: EdgeInsets.symmetric(
67
+ horizontal: MediaQuery.of(context).size.width / 8),
68
+ child: PrimaryImageButton(
69
+ onPressed: () {
70
+ try {
71
+ launchUrl(Uri.parse("https://status.cakewallet.com/"));
72
+ } catch (_) {}
73
+ },
74
+ image: Image.asset(
75
+ "assets/images/status_website_image.png",
76
+ color: Theme.of(context).brightness == Brightness.light
77
+ ? Colors.white
78
+ : null,
79
+ ),
80
+ text: "Status Website",
81
+ color: Theme.of(context)
82
+ .extension<WalletListTheme>()!
83
+ .createNewWalletButtonBackgroundColor,
84
+ textColor: Theme.of(context)
85
+ .extension<WalletListTheme>()!
86
+ .restoreWalletButtonTextColor,
87
+ ),
88
+ ),
89
+ )
90
+ ],
91
+ ),
92
+ );
93
+ },
94
+ );
95
+ }
96
+ : null,
97
+ child: Stack(
98
+ children: [
99
+ Image.asset(
100
+ "assets/images/notification_icon.png",
101
+ color: Theme.of(context).extension<DashboardPageTheme>()!.pageTitleTextColor,
102
+ ),
103
+ if (state.hasData && state.data!.hasUpdates)
104
+ Container(
105
+ height: 7,
106
+ width: 7,
107
+ margin: EdgeInsetsDirectional.only(start: 8),
108
+ decoration: BoxDecoration(
109
+ color: Colors.red,
110
+ shape: BoxShape.circle,
111
+ ),
112
+ ),
113
+ ],
114
+ ),
115
+ );
116
+ },
117
+ ),
118
+ );
119
+ }
120
+}