Skip to content

Commit f461526

Browse files
committed
Bind notification calls to Home widget
1 parent 5a73179 commit f461526

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M21,10.12h-6.78l2.74,-2.82c-2.73,-2.7 -7.15,-2.8 -9.88,-0.1 -2.73,2.71 -2.73,7.08 0,9.79 2.73,2.71 7.15,2.71 9.88,0C18.32,15.65 19,14.08 19,12.1h2c0,1.98 -0.88,4.55 -2.64,6.29 -3.51,3.48 -9.21,3.48 -12.72,0 -3.5,-3.47 -3.53,-9.11 -0.02,-12.58 3.51,-3.47 9.14,-3.47 12.65,0L21,3v7.12zM12.5,8v4.25l3.5,2.08 -0.72,1.21L11,13V8h1.5z"/>
9+
</vector>

lib/screens/home.dart

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:sentinelx/models/tx.dart';
1010
import 'package:sentinelx/screens/Receive/receive_screen.dart';
1111
import 'package:sentinelx/screens/dojo_configure.dart';
1212
import 'package:sentinelx/screens/settings/settings.dart';
13+
import 'package:sentinelx/screens/settings/update_screen.dart';
1314
import 'package:sentinelx/screens/tx_details.dart';
1415
import 'package:sentinelx/screens/watch_list.dart';
1516
import 'package:sentinelx/shared_state/app_state.dart';
@@ -34,7 +35,6 @@ class Home extends StatefulWidget {
3435

3536
class _HomeState extends State<Home> {
3637
final GlobalKey<ScaffoldState> _ScaffoldKey = new GlobalKey<ScaffoldState>();
37-
final GlobalKey<RefreshIndicatorState> _refreshIndicator = new GlobalKey<RefreshIndicatorState>();
3838

3939
@override
4040
void initState() {
@@ -138,12 +138,11 @@ class _HomeState extends State<Home> {
138138
// color: Theme.of(context).primaryColorDark.withOpacity(Theme.of(context).brightness == Brightness.light ? 0.1 : 0.8),
139139
padding: EdgeInsets.symmetric(horizontal: 12),
140140
child: Text(tx.section,
141-
style: Theme.of(context)
142-
.textTheme
143-
.subtitle
144-
.copyWith(fontWeight: FontWeight.w700,
145-
color: tx.section == "Pending"? Colors.orangeAccent.withOpacity(0.5) : Theme.of(context).textTheme.subtitle.color.withOpacity(0.5)
146-
)),
141+
style: Theme.of(context).textTheme.subtitle.copyWith(
142+
fontWeight: FontWeight.w700,
143+
color: tx.section == "Pending"
144+
? Colors.orangeAccent.withOpacity(0.5)
145+
: Theme.of(context).textTheme.subtitle.color.withOpacity(0.5))),
147146
),
148147
Divider(),
149148
],
@@ -286,6 +285,8 @@ class _HomeState extends State<Home> {
286285
void setUp() {
287286
askPermission();
288287
askNetwork();
288+
checkUpdate();
289+
registerListeners(context);
289290
}
290291

291292
void askPermission() async {
@@ -330,4 +331,31 @@ class _HomeState extends State<Home> {
330331
},
331332
);
332333
}
334+
335+
void checkUpdate() async {
336+
try {
337+
Map<String, dynamic> update = await AppState().checkUpdate();
338+
if (update.containsKey("isUpToDate")) {
339+
if (update['isUpToDate'] as bool == false) {
340+
SystemChannel().showUpdateNotification(update['newVersion']);
341+
}
342+
}
343+
} catch (e) {
344+
print(e);
345+
}
346+
}
347+
348+
void registerListeners(BuildContext context) {
349+
SystemChannel().onNotificationCalls((event) {
350+
if (event == SystemChannel.UPDATE_NOTIFICATION_EVENT) {
351+
Navigator.push(
352+
context,
353+
new MaterialPageRoute(
354+
builder: (c) {
355+
return UpdateCheck();
356+
},
357+
fullscreenDialog: false));
358+
}
359+
});
360+
}
333361
}

0 commit comments

Comments
 (0)