Skip to content

Commit

Permalink
Merge pull request #25 from KizKizz/backend-rework
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
KizKizz authored Jul 12, 2022
2 parents 3027ba5 + cbbcdbb commit 0b1f84e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 27 deletions.
2 changes: 2 additions & 0 deletions lib/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:pso2_mod_manager/state_provider.dart';

String newVersion = '';
String patchNotes = '';
List<String> patchNoteSplit = [];

class ApplicationConfig {
static List<String> currentVersionValues = appVersion.split('.');
Expand All @@ -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<stateProvider>(context, listen: false).isUpdateAvailableTrue();
}
Expand Down
14 changes: 7 additions & 7 deletions lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ class _HomePageState extends State<HomePage> 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(
Expand Down Expand Up @@ -673,7 +673,7 @@ class _HomePageState extends State<HomePage> 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(
Expand Down Expand Up @@ -944,7 +944,7 @@ class _HomePageState extends State<HomePage> 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(
Expand Down Expand Up @@ -1056,7 +1056,7 @@ class _HomePageState extends State<HomePage> 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(
Expand Down Expand Up @@ -1971,7 +1971,7 @@ class _HomePageState extends State<HomePage> 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,
Expand Down Expand Up @@ -2216,9 +2216,9 @@ class _HomePageState extends State<HomePage> 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),
Expand Down
44 changes: 24 additions & 20 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,56 +570,60 @@ class _MyHomePageState extends State<MyHomePage> with WindowListener {
),
),
),

//New version banner
if (context.watch<stateProvider>().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<stateProvider>(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<stateProvider>(context, listen: false).isUpdateAvailableFalse();
setState(() {});
}),
child: const Text('Dismiss')),
)
),
ElevatedButton(
onPressed: (() {
Provider.of<stateProvider>(context, listen: false).isUpdateAvailableFalse();
launchUrl(Uri.parse('https://github.com/KizKizz/pso2_mod_manager/releases'));
}),
child: const Text('Update')),
],
)
],
Expand Down
27 changes: 27 additions & 0 deletions lib/popup_handlers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -688,3 +689,29 @@ Future pictureDialog(context, List<Widget> previewImageSliders) async {
});
});
}

Future<void> patchNotesDialog(context) async {
return showDialog<void>(
context: context, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Center(child: Text('Patch Notes')),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
for (int i = 0; i < patchNoteSplit.length; i++) Text('- ${patchNoteSplit[i]}'),
],
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('Close'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}

0 comments on commit 0b1f84e

Please sign in to comment.