Commit 9a636191 authored by Wilko Manger's avatar Wilko Manger

Show version in settings

parent e71567f8
......@@ -32,7 +32,7 @@
/dev/integration_tests/**/xcuserdata
/dev/integration_tests/**/Pods
/packages/flutter/coverage/
version
/version
# packages file containing multi-root paths
.packages.generated
......
{
"@@last_modified": "2020-05-10T21:27:49.243825",
"@@last_modified": "2020-05-22T19:51:59.835654",
"appName": "Pattle",
"@appName": {
"type": "text",
......@@ -319,6 +319,13 @@
"type": "text",
"placeholders": {}
},
"_Settings_version": "Version {version}",
"@_Settings_version": {
"type": "text",
"placeholders": {
"version": {}
}
},
"Logout": "Logout",
"@Logout": {
"type": "text",
......
......@@ -319,6 +319,13 @@
"type": "text",
"placeholders": {}
},
"_Settings_version": "Versie {version}",
"@_Settings_version": {
"type": "text",
"placeholders": {
"version": {}
}
},
"Logout": "Uitloggen",
"@Logout": {
"type": "text",
......
......@@ -791,6 +791,15 @@ class _Settings extends _Category {
);
}
String version(String version) {
return Intl.message(
'Version $version',
name: '_Settings_version',
args: [version],
locale: _localeName,
);
}
String get logoutButton {
return Intl.message(
'Logout',
......
......@@ -76,6 +76,8 @@ class MessageLookup extends MessageLookupByLibrary {
static m11(name) => "${name} is typing...";
static m12(version) => "Version ${version}";
final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{
"Logout": MessageLookupByLibrary.simpleMessage("Logout"),
......@@ -145,6 +147,7 @@ class MessageLookup extends MessageLookupByLibrary {
"_Settings_editNameDescription": MessageLookupByLibrary.simpleMessage(
"This is not your username. This is the name that will be visible to others."),
"_Settings_title": MessageLookupByLibrary.simpleMessage("Settings"),
"_Settings_version": m12,
"_StartUsername_hostnameInvalidError":
MessageLookupByLibrary.simpleMessage("Invalid hostname"),
"_StartUsername_title":
......
......@@ -76,8 +76,11 @@ class MessageLookup extends MessageLookupByLibrary {
static m11(name) => "${name} typt...";
static m12(version) => "Versie ${version}";
final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{
"Logout": MessageLookupByLibrary.simpleMessage("Uitloggen"),
"Participants": MessageLookupByLibrary.simpleMessage("Deelnemers"),
"Profile": MessageLookupByLibrary.simpleMessage("Profiel"),
"_ChatDetails_description":
......@@ -146,6 +149,7 @@ class MessageLookup extends MessageLookupByLibrary {
"_Settings_editNameDescription": MessageLookupByLibrary.simpleMessage(
"Dit is niet je gebruikersnaam. Deze naam is zichtbaar voor anderen."),
"_Settings_title": MessageLookupByLibrary.simpleMessage("Instellingen"),
"_Settings_version": m12,
"_StartUsername_hostnameInvalidError":
MessageLookupByLibrary.simpleMessage("Ongeldige hostnaam"),
"_StartUsername_title":
......
......@@ -25,6 +25,7 @@ import '../../../resources/theme.dart';
import '../../../app.dart';
import 'widgets/logout_button/widget.dart';
import 'widgets/version/widget.dart';
class SettingsPage extends StatelessWidget {
SettingsPage({Key key});
......@@ -54,7 +55,14 @@ class SettingsPage extends StatelessWidget {
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: LogoutButton.withBloc(),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Version.withBloc(),
SizedBox(height: 24),
LogoutButton.withBloc(),
],
),
),
),
SizedBox(height: 24),
......
// Copyright (C) 2019 Wilko Manger
//
// This file is part of Pattle.
//
// Pattle is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pattle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'package:bloc/bloc.dart';
import 'package:package_info/package_info.dart';
import 'event.dart';
import 'state.dart';
export 'event.dart';
export 'state.dart';
class VersionBloc extends Bloc<VersionEvent, VersionState> {
@override
VersionState get initialState => VersionState(null);
@override
Stream<VersionState> mapEventToState(VersionEvent event) async* {
if (event is GetVersion) {
final info = await PackageInfo.fromPlatform();
yield VersionState(info.version);
}
}
}
import 'package:equatable/equatable.dart';
abstract class VersionEvent extends Equatable {
@override
List<Object> get props => [];
}
class GetVersion extends VersionEvent {}
// Copyright (C) 2020 Wilko Manger
//
// This file is part of Pattle.
//
// Pattle is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pattle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'package:meta/meta.dart';
@immutable
class VersionState {
final String version;
VersionState(this.version);
}
// Copyright (C) 2019 Wilko Manger
//
// This file is part of Pattle.
//
// Pattle is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pattle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../../resources/intl/localizations.dart';
import 'bloc.dart';
class Version extends StatefulWidget {
Version._({Key key});
static Widget withBloc() {
return BlocProvider<VersionBloc>(
create: (context) => VersionBloc(),
child: Version._(),
);
}
@override
State<StatefulWidget> createState() => _VersionState();
}
class _VersionState extends State<Version> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
context.bloc<VersionBloc>().add(GetVersion());
}
@override
Widget build(BuildContext context) {
return BlocBuilder<VersionBloc, VersionState>(
builder: (context, state) {
if (state.version != null) {
return Text(context.intl.settings.version(state.version));
} else {
return Container();
}
},
);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment