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 UpdateSettingsPage extends StatefulWidget { const UpdateSettingsPage({super.key}); @override State createState() { return _UpdSet(); } } class _UpdSet extends State { @override void didChangeDependencies() { super.didChangeDependencies(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Time Tracker > Update Settings"), backgroundColor: LibACFlutterConstants.TITLEBAR_COLOR, ), body: SingleChildScrollView( child: Column( children: [ Text( "Here, you can check for updates, and adjust various settings, such as the update channel", style: TextStyle(fontSize: 24), ), ListTile( title: Text("Update Channel"), leading: Icon(Icons.wifi_channel), subtitle: Text("Current Channel: ${TTConsts.UPDATE_CHANNEL}"), trailing: DropdownMenu( dropdownMenuEntries: [ DropdownMenuEntry(value: UpdateChannel.alpha, label: "Alpha"), DropdownMenuEntry(value: UpdateChannel.beta, label: "Beta"), DropdownMenuEntry( value: UpdateChannel.stable, label: "Stable", ), ], initialSelection: TTConsts.UPDATE_CHANNEL, onSelected: (value) { setState(() { TTConsts.UPDATE_CHANNEL = value!; }); }, ), ), ListTile( title: Text("Check for updates.."), leading: Icon(Icons.refresh), subtitle: Text( "Check for a update on the preferred update channel", ), onTap: () async { await TTConsts.checkUpdate(); setState(() {}); }, ), if (TTConsts.UPDATE_AVAILABLE) ListTile( title: Text("Install Update"), leading: Icon(Icons.update), subtitle: Text( "Downloads and prompts you for installation of the update", ), onTap: () { OtaUpdate() .execute( "https://ci.zontreck.com/job/Projects/job/Dart/job/Time%20Tracker/job/${TTConsts.UPDATE_CHANNEL == UpdateChannel.stable ? "main" : TTConsts.UPDATE_CHANNEL}/lastSuccessfulBuild/artifact/build/app/outputs/flutter-apk/timetrack.apk", destinationFilename: "timetrack.apk", ) .listen((OtaEvent event) { //setState(() => currentEvent = event); }); }, ), ], ), ), ); } }