Replace placeholder text in about dialog

This commit is contained in:
Roland Geider
2021-01-27 22:53:44 +01:00
parent e2f8da0724
commit 5cbdb64dea
8 changed files with 72 additions and 23 deletions

View File

@@ -354,6 +354,16 @@ class AppLocalizations {
desc: 'Switch to toggle detail / overview',
);
}
String get aboutText {
return Intl.message(
'wger Workout Manager is free, open source (FLOSS) software released '
'under the GNU General Public version 3 or later. '
'The code is freely available on github: ',
name: 'aboutText',
desc: 'Text in the about dialog',
);
}
}
class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {

View File

@@ -34,10 +34,10 @@ class WorkoutPlan {
@JsonKey(required: true, name: 'comment')
String description;
@JsonKey(required: false, name: 'days')
@JsonKey(required: false, defaultValue: [], name: 'days')
List<Day> days = [];
@JsonKey(ignore: true)
@JsonKey(ignore: true, defaultValue: [])
List<Log> logs = [];
WorkoutPlan({

View File

@@ -15,8 +15,10 @@ WorkoutPlan _$WorkoutPlanFromJson(Map<String, dynamic> json) {
: DateTime.parse(json['creation_date'] as String),
description: json['comment'] as String,
days: (json['days'] as List)
?.map((e) => e == null ? null : Day.fromJson(e as Map<String, dynamic>))
?.toList(),
?.map((e) =>
e == null ? null : Day.fromJson(e as Map<String, dynamic>))
?.toList() ??
[],
);
}

View File

@@ -23,12 +23,15 @@ import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';
import 'package:http/http.dart' as http;
import 'package:package_info/package_info.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:wger/models/http_exception.dart';
class Auth with ChangeNotifier {
String token;
String serverUrl;
String serverVersion;
PackageInfo applicationVersion;
/// flag to indicate that the application has successfully loaded all initial data
bool dataInit = false;
@@ -54,13 +57,29 @@ class Auth with ChangeNotifier {
// return _userId;
// }
/// Server application version
Future<void> setServerVersion() async {
var url = '$serverUrl/api/v2/version/';
final response = await http.get(url);
final responseData = json.decode(response.body);
serverVersion = responseData;
}
/// (flutter) Application version
Future<void> setApplicationVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
applicationVersion = packageInfo;
}
Future<void> _authenticate(String username, String password, String serverUrl) async {
// The android emulator uses
var url = '$serverUrl/api/v2/login/';
//print(username);
//print(password);
try {
// Get the server version
await setServerVersion();
final response = await http.post(
url,
headers: <String, String>{
@@ -129,6 +148,8 @@ class Auth with ChangeNotifier {
// _expiryDate = expiryDate;
log('autologin successful');
setApplicationVersion();
setServerVersion();
notifyListeners();
//_autoLogout();
return true;

View File

@@ -47,6 +47,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
/// Load initial data from the server
Future<void> _loadEntries(BuildContext context) async {
if (!Provider.of<Auth>(context, listen: false).dataInit) {
Provider.of<Auth>(context, listen: false).setServerVersion();
// Exercises
await Provider.of<Exercises>(context, listen: false).fetchAndSetExercises();

View File

@@ -30,6 +30,8 @@ import 'package:wger/screens/workout_plans_screen.dart';
class AppDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final authProvider = Provider.of<Auth>(context, listen: false);
return Drawer(
child: Column(
children: [
@@ -109,29 +111,33 @@ class AppDrawer extends StatelessWidget {
dense: true,
icon: Icon(Icons.info),
applicationName: 'wger',
applicationVersion: '0.0.1 alpha',
applicationLegalese: '\u{a9} 2020 The wger team',
applicationIcon: Image.asset(
'assets/images/logo.png',
width: 60,
applicationVersion: '${authProvider.applicationVersion.version} '
'(server: ${authProvider.serverVersion})',
applicationLegalese: '\u{a9} 2020 - 2021 contributors',
applicationIcon: Padding(
padding: const EdgeInsets.only(top: 10),
child: Image.asset(
'assets/images/logo.png',
width: 60,
),
),
aboutBoxChildren: [
SizedBox(
height: 10,
),
RichText(
text: TextSpan(
style: TextStyle(fontSize: 16, color: Colors.black),
children: [
TextSpan(
text: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, '
'sed diam nonumy eirmod tempor invidunt ut labore et dolore '
'magna aliquyam erat, sed diam voluptua. At vero eos et accusam '
'et justo duo dolores et ea rebum.\n',
text: AppLocalizations.of(context).aboutText,
),
TextSpan(
text: 'https://github.com/wger-project/wger',
text: 'https://github.com/wger-project',
style: TextStyle(color: Colors.blue),
recognizer: TapGestureRecognizer()
..onTap = () {
launch('https://github.com/wger-project/wger');
launch('https://github.com/wger-project');
},
)
],

View File

@@ -63,7 +63,7 @@ packages:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
version: "2.1.6"
build_resolvers:
dependency: transitive
description:
@@ -154,7 +154,7 @@ packages:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "3.6.0"
collection:
dependency: transitive
description:
@@ -412,7 +412,7 @@ packages:
name: mockito
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.3"
version: "4.1.4"
nested:
dependency: transitive
description:
@@ -441,6 +441,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
package_info:
dependency: "direct main"
description:
name: package_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3+2"
path:
dependency: transitive
description:
@@ -517,7 +524,7 @@ packages:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2+3"
version: "4.3.3"
pub_semver:
dependency: transitive
description:
@@ -580,7 +587,7 @@ packages:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+3"
version: "0.0.2+2"
shelf:
dependency: transitive
description:
@@ -746,7 +753,7 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
win32:
dependency: transitive
description:
@@ -776,5 +783,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.10.0 <2.11.0"
flutter: ">=1.22.0 <2.0.0"

View File

@@ -37,6 +37,7 @@ dependencies:
charts_flutter: ^0.9.0
flutter_typeahead: ^2.0.0
table_calendar: ^2.3.3
package_info: ^0.4.3+2
dev_dependencies:
flutter_test: