part of 'settings_page.dart'; class AboutSettings extends StatefulWidget { const AboutSettings({super.key}); @override State createState() => _AboutSettingsState(); } class _AboutSettingsState extends State { bool isCheckingUpdate = false; @override Widget build(BuildContext context) { return SmoothCustomScrollView( slivers: [ SliverAppbar(title: Text("About".tl)), SizedBox( height: 136, width: double.infinity, child: Center( child: Container( width: 136, height: 136, decoration: BoxDecoration( borderRadius: BorderRadius.circular(136), ), clipBehavior: Clip.antiAlias, child: const Image( image: AssetImage("assets/app_icon.png"), filterQuality: FilterQuality.medium, ), ), ), ).paddingTop(16).toSliver(), Column( children: [ const SizedBox(height: 8), Text( "V${App.version}", style: const TextStyle(fontSize: 16), ), Text("Venera is a free and open-source app for comic reading.".tl), const SizedBox(height: 8), ], ).toSliver(), ListTile( title: Text("Check for updates".tl), trailing: Button.filled( isLoading: isCheckingUpdate, child: Text("Check".tl), onPressed: () { setState(() { isCheckingUpdate = true; }); checkUpdateUi().then((value) { setState(() { isCheckingUpdate = false; }); }); }, ).fixHeight(32), ).toSliver(), ListTile( title: const Text("Github"), trailing: const Icon(Icons.open_in_new), onTap: () { launchUrlString("https://github.com/venera-app/venera"); }, ).toSliver(), ], ); } } Future checkUpdate() async { var res = await AppDio().get( "https://raw.githubusercontent.com/venera-app/venera/refs/heads/master/pubspec.yaml"); if (res.statusCode == 200) { var data = loadYaml(res.data); if (data["version"] != null) { return _compareVersion(data["version"].split("+")[0], App.version); } } return false; } Future checkUpdateUi([bool showMessageIfNoUpdate = true]) async { var value = await checkUpdate(); if (value) { showDialog( context: App.rootContext, builder: (context) { return ContentDialog( title: "New version available".tl, content: Text( "A new version is available. Do you want to update now?".tl), actions: [ Button.text( onPressed: () { Navigator.pop(context); launchUrlString( "https://github.com/venera-app/venera/releases"); }, child: Text("Update".tl), ), ], ); }); } else if (showMessageIfNoUpdate) { App.rootContext.showMessage(message: "No new version available".tl); } } /// return true if version1 > version2 bool _compareVersion(String version1, String version2) { var v1 = version1.split("."); var v2 = version2.split("."); for (var i = 0; i < v1.length; i++) { if (int.parse(v1[i]) > int.parse(v2[i])) { return true; } } return false; }