Skip to content

Commit 19c45e1

Browse files
committed
feat: Buat UI dan fitur banner ketika ada app versi terbaru di halaman home
1 parent 03abb57 commit 19c45e1

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

lib/feature/presentation/page/home/home_page.dart

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:async';
22
import 'dart:io';
33

4+
import 'package:auto_updater/auto_updater.dart';
45
import 'package:dipantau_desktop_client/core/network/network_info.dart';
56
import 'package:dipantau_desktop_client/core/util/enum/global_variable.dart';
67
import 'package:dipantau_desktop_client/core/util/helper.dart';
@@ -76,6 +77,7 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
7677
final listTrackLocal = <Track>[];
7778
final listPathStartScreenshots = <String?>[];
7879
final networkInfo = sl<NetworkInfo>();
80+
final valueNotifierShowBannerUpdate = ValueNotifier(false);
7981

8082
var isWindowVisible = true;
8183
var userId = '';
@@ -130,6 +132,8 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
130132
}
131133
setupCronTimer();
132134
doLoadDataTask();
135+
final isNewUpdateAvailable = await widgetHelper.isNewUpdateAvailable();
136+
valueNotifierShowBannerUpdate.value = isNewUpdateAvailable;
133137
});
134138
super.initState();
135139
}
@@ -506,7 +510,7 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
506510
),
507511
),
508512
floatingActionButton: FloatingActionButton(
509-
onPressed: () {
513+
onPressed: () async {
510514
context.pushNamed(ManualTrackingPage.routeName).then((value) {
511515
// TODO: refresh data home jika add manual tracking-nya pada hari ini dan di project yang sama
512516
});
@@ -555,6 +559,7 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
555559
child: Column(
556560
crossAxisAlignment: CrossAxisAlignment.center,
557561
children: [
562+
buildWidgetBannerUpdate(),
558563
buildWidgetFieldProject(),
559564
const SizedBox(height: 24),
560565
buildWidgetTimer(),
@@ -1487,4 +1492,68 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
14871492
);
14881493
}
14891494
}
1495+
1496+
Widget buildWidgetBannerUpdate() {
1497+
return ValueListenableBuilder(
1498+
valueListenable: valueNotifierShowBannerUpdate,
1499+
builder: (BuildContext context, bool isShow, _) {
1500+
if (!isShow) {
1501+
return Container();
1502+
}
1503+
return Column(
1504+
children: [
1505+
Material(
1506+
borderRadius: BorderRadius.circular(8),
1507+
color: Theme.of(context).colorScheme.primaryContainer,
1508+
child: InkWell(
1509+
borderRadius: BorderRadius.circular(8),
1510+
onTap: () {
1511+
const feedURL = autoUpdaterUrl;
1512+
autoUpdater.setFeedURL(feedURL);
1513+
autoUpdater.checkForUpdates();
1514+
valueNotifierShowBannerUpdate.value = false;
1515+
},
1516+
child: Container(
1517+
width: double.infinity,
1518+
padding: const EdgeInsets.all(8),
1519+
decoration: BoxDecoration(
1520+
borderRadius: BorderRadius.circular(8),
1521+
),
1522+
child: Row(
1523+
children: [
1524+
Expanded(
1525+
child: Padding(
1526+
padding: const EdgeInsets.only(left: 8.0),
1527+
child: Column(
1528+
crossAxisAlignment: CrossAxisAlignment.start,
1529+
children: [
1530+
Text(
1531+
'title_new_update_available'.tr(),
1532+
style: Theme.of(context).textTheme.bodyLarge,
1533+
),
1534+
Text(
1535+
'description_new_update_available'.tr(),
1536+
style: Theme.of(context).textTheme.bodySmall,
1537+
),
1538+
],
1539+
),
1540+
),
1541+
),
1542+
IconButton(
1543+
onPressed: () {
1544+
valueNotifierShowBannerUpdate.value = false;
1545+
},
1546+
icon: const Icon(Icons.clear),
1547+
),
1548+
],
1549+
),
1550+
),
1551+
),
1552+
),
1553+
const SizedBox(height: 16),
1554+
],
1555+
);
1556+
},
1557+
);
1558+
}
14901559
}

0 commit comments

Comments
 (0)