diff --git a/lib/pages/about_page.dart b/lib/pages/about_page.dart index cf0f9eb..2e56626 100644 --- a/lib/pages/about_page.dart +++ b/lib/pages/about_page.dart @@ -1,11 +1,27 @@ import 'package:flutter/material.dart'; import 'package:oweapp4/widgets/drawer.dart'; +import 'package:package_info/package_info.dart'; -class AboutPage extends StatelessWidget { +class AboutPage extends StatefulWidget { static const String routeName = '/about'; + @override + _AboutPageState createState() => _AboutPageState(); +} + +class _AboutPageState extends State { + String versionName = ''; + + _getBuildNumber() async { + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + setState(() { + versionName = packageInfo.version; + }); + } + @override Widget build(BuildContext context) { + _getBuildNumber(); TextStyle textStyle = TextStyle( color: Theme.of(context).accentColor, fontWeight: FontWeight.w300, @@ -28,7 +44,7 @@ class AboutPage extends StatelessWidget { height: 5, ), Text( - "Leihen v5", + "Leihen v" + this.versionName, style: textStyle, ), Text("www.leihen.app", style: textStyle), diff --git a/lib/pages/changelog_screen.dart b/lib/pages/changelog_screen.dart new file mode 100644 index 0000000..9029f28 --- /dev/null +++ b/lib/pages/changelog_screen.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; +import 'package:oweapp4/widgets/drawer.dart'; + +class ChangelogScreen extends StatelessWidget { + static const String routeName = '/changelog'; + + @override + Widget build(BuildContext context) { + return WebviewScaffold( + url: "https://leihen.app/changelog.html", + clearCache: true, + appBar: new AppBar( + title: new Text("Was gibt's neues?"), + ), + ); + } +} diff --git a/lib/pages/homescreen_page.dart b/lib/pages/homescreen_page.dart index bb6d8bf..4dfad28 100644 --- a/lib/pages/homescreen_page.dart +++ b/lib/pages/homescreen_page.dart @@ -1,12 +1,15 @@ import 'package:flutter/material.dart'; import 'package:oweapp4/Database.dart'; +import 'package:oweapp4/pages/changelog_screen.dart'; import 'package:oweapp4/pages/input_item_screen.dart'; import 'package:oweapp4/NI_SelectContactScreen.dart'; import 'package:oweapp4/pages/about_page.dart'; import 'package:oweapp4/widgets/drawer.dart'; import 'package:oweapp4/widgets/main_card.dart'; +import 'package:package_info/package_info.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; class HomeScreen extends StatefulWidget { @override @@ -34,6 +37,24 @@ class HomeScreenState extends State { print("Call initState()"); _getHomeScreenData(); super.initState(); + + WidgetsBinding.instance.addPostFrameCallback((_) => __showChangelogIfNeccesary()); + } + + __showChangelogIfNeccesary() async { + + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + print(packageInfo.buildNumber); + print(this._lastVersionNumber); + print((this._lastVersionNumber.compareTo(packageInfo.buildNumber).isEven)); + + if (this._lastVersionNumber == null || (this._lastVersionNumber != null && (this._lastVersionNumber.compareTo(packageInfo.buildNumber).isEven) == false)) { + final prefs = await SharedPreferences.getInstance(); + prefs.setString('lastVersionNumber', packageInfo.buildNumber); + Navigator.push(context, + MaterialPageRoute(builder: (BuildContext context) => ChangelogScreen())); + } + } _checkContactPermission() async { @@ -70,7 +91,6 @@ class HomeScreenState extends State { firstStart = true; }); } - } _showFirstStartScreen() { @@ -85,22 +105,22 @@ class HomeScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon( - Icons.info, - size: 25, - ), - Container( - height: 5, - ), - Text( - "Diese App braucht die Berechtigung zum Lesen deiner Kontakte.", - style: textStyle, - ), - Container(height: 50), - - Icon(Icons.favorite, color: Colors.redAccent), - Text("Deine Daten bleiben auf deinem Gerät, versprochen!", style: textStyle) - ])); + Icon( + Icons.info, + size: 25, + ), + Container( + height: 5, + ), + Text( + "Diese App braucht die Berechtigung zum Lesen deiner Kontakte.", + style: textStyle, + ), + Container(height: 50), + Icon(Icons.favorite, color: Colors.redAccent), + Text("Deine Daten bleiben auf deinem Gerät, versprochen!", + style: textStyle) + ])); } @override @@ -155,7 +175,8 @@ class HomeScreenState extends State { onPressed: () => Navigator.push( context, MaterialPageRoute( - builder: (BuildContext context) => NewItemSelectContactScreen()))), + builder: (BuildContext context) => + NewItemSelectContactScreen()))), ); } } diff --git a/lib/pages/show_items_to_contact_screen.dart b/lib/pages/show_items_to_contact_screen.dart index 597a449..47a8d17 100644 --- a/lib/pages/show_items_to_contact_screen.dart +++ b/lib/pages/show_items_to_contact_screen.dart @@ -104,8 +104,15 @@ class ShowItemsToContactScreenState extends State { } @override - Widget build(BuildContext context) { + void initState() { + super.initState(); _loadContact(); + } + + @override + Widget build(BuildContext context) { + print("Run build"); + return Scaffold( appBar: AppBar( diff --git a/lib/widgets/drawer.dart b/lib/widgets/drawer.dart index 4e14295..30aeb00 100644 --- a/lib/widgets/drawer.dart +++ b/lib/widgets/drawer.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:oweapp4/main.dart'; import 'package:oweapp4/pages/about_page.dart'; +import 'package:oweapp4/pages/changelog_screen.dart'; import 'package:oweapp4/routes/Routes.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:package_info/package_info.dart'; @@ -45,6 +46,13 @@ class _AppDrawerState extends State { MaterialPageRoute( builder: (BuildContext context) => AboutPage()))), Divider(), + _createDrawerItem( + icon: Icons.fiber_new_outlined, + text: 'Changelog', + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => ChangelogScreen()))), _createDrawerItem( icon: Icons.bug_report, text: 'Fehler melden', diff --git a/pubspec.lock b/pubspec.lock index 85911fe..85906da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -135,6 +135,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_webview_plugin: + dependency: "direct main" + description: + name: flutter_webview_plugin + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.11" http: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a9a505f..7b6e96a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Leihen # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 5.0.3+503 +version: 5.1.0+510 environment: sdk: ">=2.1.0 <3.0.0" @@ -33,6 +33,7 @@ dependencies: flutter_launcher_icons: ^0.7.4 package_info: ^0.4.1 shared_preferences: + flutter_webview_plugin: ^0.3.11 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.