diff --git a/lib/application.dart b/lib/application.dart index d3e94864..1b024254 100644 --- a/lib/application.dart +++ b/lib/application.dart @@ -10,6 +10,7 @@ import 'package:pso2_mod_manager/state_provider.dart'; String newVersion = ''; String patchNotes = ''; +List patchNoteSplit = []; class ApplicationConfig { static List currentVersionValues = appVersion.split('.'); @@ -26,6 +27,7 @@ class ApplicationConfig { newVersion = newVersionValue; String tempPatchNote = jsonVal.entries.firstWhere((element) => element.key == 'description').value.toString(); patchNotes = tempPatchNote.replaceFirst('[', '', 0).replaceFirst(']', '', patchNotes.length); + patchNoteSplit = patchNotes.split(', '); //debugPrint('Response: ${patchNotes.first}'); Provider.of(context, listen: false).isUpdateAvailableTrue(); } diff --git a/lib/home_page.dart b/lib/home_page.dart index d17f68a3..324d348c 100644 --- a/lib/home_page.dart +++ b/lib/home_page.dart @@ -508,7 +508,7 @@ class _HomePageState extends State with TickerProviderStateMixin { trailing: Wrap( children: [ if (cateList[index].allModFiles.indexWhere((element) => element.modName == cateList[index].itemNames[i] && element.isNew == true) != -1) - const SizedBox(height: 50, child: Icon(Icons.new_releases, color: Colors.amber)), + SizedBox(height: 50, child: Icon(Icons.new_releases, color: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amber)), //Buttons Tooltip( @@ -673,7 +673,7 @@ class _HomePageState extends State with TickerProviderStateMixin { trailing: Wrap( children: [ if (cateList[index].allModFiles.indexWhere((element) => element.modName == cateList[index].itemNames[i] && element.isNew == true) != -1) - const SizedBox(height: 50, child: Icon(Icons.new_releases, color: Colors.amber)), + SizedBox(height: 50, child: Icon(Icons.new_releases, color: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amber,)), //Buttons Tooltip( @@ -944,7 +944,7 @@ class _HomePageState extends State with TickerProviderStateMixin { trailing: Wrap( children: [ if (cateListSearchResult[index].allModFiles.indexWhere((element) => element.modName == cateListSearchResult[index].itemNames[i] && element.isNew == true) != -1) - const SizedBox(height: 50, child: Icon(Icons.new_releases, color: Colors.amber)), + SizedBox(height: 50, child: Icon(Icons.new_releases, color: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amber,)), //Buttons Tooltip( @@ -1056,7 +1056,7 @@ class _HomePageState extends State with TickerProviderStateMixin { trailing: Wrap( children: [ if (cateListSearchResult[index].allModFiles.indexWhere((element) => element.modName == cateListSearchResult[index].itemNames[i] && element.isNew == true) != -1) - const SizedBox(height: 50, child: Icon(Icons.new_releases, color: Colors.amber)), + SizedBox(height: 50, child: Icon(Icons.new_releases, color: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amber,)), //Buttons Tooltip( @@ -1971,7 +1971,7 @@ class _HomePageState extends State with TickerProviderStateMixin { margin: const EdgeInsets.only(left: 3, right: 3, top: 2, bottom: 2), shape: RoundedRectangleBorder( borderRadius: const BorderRadius.all(Radius.circular(5.0)), - side: BorderSide(width: 1, color: modFilesList[index].indexWhere((e) => e.isNew == true) != -1 ? Colors.amber : Theme.of(context).primaryColor)), + side: BorderSide(width: 1, color: modFilesList[index].indexWhere((e) => e.isNew == true) != -1 ? MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amber : Theme.of(context).primaryColor)), child: ExpansionTile( initiallyExpanded: modViewExpandAll, textColor: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColor : Theme.of(context).iconTheme.color, @@ -2216,9 +2216,9 @@ class _HomePageState extends State with TickerProviderStateMixin { // }, child: ListTile( leading: modFilesList[index][i].isNew == true - ? const Icon( + ? Icon( Icons.new_releases, - color: Colors.amber, + color: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amber, ) : null, title: Text(modFilesList[index][i].iceName), diff --git a/lib/main.dart b/lib/main.dart index 9c7a0a11..2cefad4d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -570,56 +570,60 @@ class _MyHomePageState extends State with WindowListener { ), ), ), + //New version banner if (context.watch().isUpdateAvailable) ScaffoldMessenger( child: MaterialBanner( + backgroundColor: Theme.of(context).canvasColor, + elevation: 0, padding: const EdgeInsets.all(0), leadingPadding: const EdgeInsets.only(left: 15, right: 5), - leading: const Icon( + leading: Icon( Icons.new_releases, - color: Colors.amber, + color: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amberAccent, ), content: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ - const Text( + Text( 'New Update Available!', - style: TextStyle(color: Colors.amberAccent, fontWeight: FontWeight.w500), + style: TextStyle( + color: MyApp.themeNotifier.value == ThemeMode.light ? Theme.of(context).primaryColorDark : Colors.amberAccent, + fontWeight: FontWeight.w500), ), Padding( padding: const EdgeInsets.only(left: 5), child: Text('New Version: $newVersion - Your Version: $appVersion'), ), - const Padding( - padding: EdgeInsets.only(left: 5), - child: Text( - '- Patch Notes: ', - style: TextStyle(fontWeight: FontWeight.w500), - ), - ), - Text(patchNotes, overflow: TextOverflow.ellipsis) + TextButton( + onPressed: (() { + setState(() { + patchNotesDialog(context); + }); + }), + child: const Text('Patch Notes...')), ], ), Row( children: [ - ElevatedButton( - onPressed: (() { - Provider.of(context, listen: false).isUpdateAvailableFalse(); - launchUrl(Uri.parse('https://github.com/KizKizz/pso2_mod_manager/releases')); - }), - child: const Text('Update')), Padding( - padding: const EdgeInsets.only(left: 5), + padding: const EdgeInsets.only(right: 5), child: ElevatedButton( onPressed: (() { Provider.of(context, listen: false).isUpdateAvailableFalse(); setState(() {}); }), child: const Text('Dismiss')), - ) + ), + ElevatedButton( + onPressed: (() { + Provider.of(context, listen: false).isUpdateAvailableFalse(); + launchUrl(Uri.parse('https://github.com/KizKizz/pso2_mod_manager/releases')); + }), + child: const Text('Update')), ], ) ], diff --git a/lib/popup_handlers.dart b/lib/popup_handlers.dart index 8f6d6ddb..82f1a497 100644 --- a/lib/popup_handlers.dart +++ b/lib/popup_handlers.dart @@ -4,6 +4,7 @@ import 'package:carousel_slider/carousel_slider.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:pso2_mod_manager/application.dart'; import 'package:pso2_mod_manager/file_functions.dart'; import 'package:pso2_mod_manager/home_page.dart'; import 'package:pso2_mod_manager/main.dart'; @@ -688,3 +689,29 @@ Future pictureDialog(context, List previewImageSliders) async { }); }); } + +Future patchNotesDialog(context) async { + return showDialog( + context: context, // user must tap button! + builder: (BuildContext context) { + return AlertDialog( + title: const Center(child: Text('Patch Notes')), + content: SingleChildScrollView( + child: ListBody( + children: [ + for (int i = 0; i < patchNoteSplit.length; i++) Text('- ${patchNoteSplit[i]}'), + ], + ), + ), + actions: [ + ElevatedButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); +}