Implement the automatic update check and installation
This commit is contained in:
parent
70d8fc4d39
commit
660a4a670a
10 changed files with 176 additions and 122 deletions
80
lib/pages/HomePage.dart
Normal file
80
lib/pages/HomePage.dart
Normal file
|
@ -0,0 +1,80 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:libacflutter/Constants.dart';
|
||||
import 'package:ota_update/ota_update.dart';
|
||||
import 'package:timetrack/consts.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
HomePage({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _HomePageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
setState(() {});
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Time Tracker"),
|
||||
backgroundColor: LibACFlutterConstants.TITLEBAR_COLOR,
|
||||
),
|
||||
drawer: Drawer(
|
||||
elevation: 8,
|
||||
child: Column(
|
||||
children: [
|
||||
DrawerHeader(
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Time Tracker"),
|
||||
Text("Created by Tara Piccari"),
|
||||
Text("Copyright 2025 - Present"),
|
||||
],
|
||||
),
|
||||
),
|
||||
DrawerHeader(
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Version: ${TTConsts.VERSION}"),
|
||||
Text("Update Channel: ${TTConsts.UPDATE_CHANNEL}"),
|
||||
Text(
|
||||
"* ${TTConsts.UPDATE_AVAILABLE ? "Update Is Available" : "You are up to date!"} *",
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await TTConsts.checkUpdate();
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
child: Text("Check for Update"),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
OtaUpdate()
|
||||
.execute(
|
||||
"https://ci.zontreck.com/job/Projects/job/Dart/job/Time%20Tracker/job/main/lastSuccessfulBuild/artifact/build/app/outputs/flutter-apk/timetrack.apk",
|
||||
destinationFilename: "timetrack.apk",
|
||||
)
|
||||
.listen((OtaEvent event) {
|
||||
//setState(() => currentEvent = event);
|
||||
});
|
||||
},
|
||||
child: Text("Install Update"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue