Skip to content

Commit

Permalink
- Feature: Changelog Screen
Browse files Browse the repository at this point in the history
- Release: 5.1.0

Signed-off-by: Alexander <[email protected]>
  • Loading branch information
alexander authored and gruessung committed Aug 22, 2020
1 parent 57a2ea3 commit 5335849
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 22 deletions.
20 changes: 18 additions & 2 deletions lib/pages/about_page.dart
Original file line number Diff line number Diff line change
@@ -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<AboutPage> {
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,
Expand All @@ -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),
Expand Down
18 changes: 18 additions & 0 deletions lib/pages/changelog_screen.dart
Original file line number Diff line number Diff line change
@@ -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?"),
),
);
}
}
57 changes: 39 additions & 18 deletions lib/pages/homescreen_page.dart
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -34,6 +37,24 @@ class HomeScreenState extends State<HomeScreen> {
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 {
Expand Down Expand Up @@ -70,7 +91,6 @@ class HomeScreenState extends State<HomeScreen> {
firstStart = true;
});
}

}

_showFirstStartScreen() {
Expand All @@ -85,22 +105,22 @@ class HomeScreenState extends State<HomeScreen> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
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
Expand Down Expand Up @@ -155,7 +175,8 @@ class HomeScreenState extends State<HomeScreen> {
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => NewItemSelectContactScreen()))),
builder: (BuildContext context) =>
NewItemSelectContactScreen()))),
);
}
}
9 changes: 8 additions & 1 deletion lib/pages/show_items_to_contact_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ class ShowItemsToContactScreenState extends State<ShowItemsToContactScreen> {
}

@override
Widget build(BuildContext context) {
void initState() {
super.initState();
_loadContact();
}

@override
Widget build(BuildContext context) {
print("Run build");


return Scaffold(
appBar: AppBar(
Expand Down
8 changes: 8 additions & 0 deletions lib/widgets/drawer.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -45,6 +46,13 @@ class _AppDrawerState extends State<AppDrawer> {
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',
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down

0 comments on commit 5335849

Please sign in to comment.