Commit ae66bd4c authored by Wilko Manger's avatar Wilko Manger

Use platform aware widgets on StartPage

parent 24eff5c2
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:matrix_sdk/matrix_sdk.dart'; import 'package:matrix_sdk/matrix_sdk.dart';
import 'package:pattle/src/ui/initial/initial_page.dart'; import 'package:pattle/src/ui/initial/initial_page.dart';
import 'package:pattle/src/ui/main/chat/chat_page.dart'; import 'package:pattle/src/ui/main/chat/chat_page.dart';
...@@ -28,19 +29,15 @@ import 'package:pattle/src/ui/start/advanced_page.dart'; ...@@ -28,19 +29,15 @@ import 'package:pattle/src/ui/start/advanced_page.dart';
import 'package:pattle/src/ui/start/phase/identity/username_page.dart'; import 'package:pattle/src/ui/start/phase/identity/username_page.dart';
import 'package:pattle/src/ui/start/phase/key/password_page.dart'; import 'package:pattle/src/ui/start/phase/key/password_page.dart';
import 'package:pattle/src/ui/start/start_page.dart'; import 'package:pattle/src/ui/start/start_page.dart';
import 'package:pattle/src/ui/main/overview/create/group/create_group_members_page.dart'; import 'package:pattle/src/ui/main/overview/create/group/create_group_members_page.dart';
import 'ui/main/overview/create/group/create_group_details_page.dart'; import 'ui/main/overview/create/group/create_group_details_page.dart';
final routes = { final routes = {
Routes.root: (Object params) => MaterialPageRoute( Routes.root: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.root), settings: RouteSettings(name: Routes.root),
builder: (context) => InitialPage() builder: (context) => InitialPage()
), ),
Routes.chats: (Object arguments) => MaterialPageRoute( Routes.chats: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.chats), settings: RouteSettings(name: Routes.chats),
builder: (context) { builder: (context) {
if (arguments is Room) { if (arguments is Room) {
...@@ -50,31 +47,31 @@ final routes = { ...@@ -50,31 +47,31 @@ final routes = {
} }
} }
), ),
Routes.chatsNew: (Object arguments) => MaterialPageRoute( Routes.chatsNew: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.chatsNew), settings: RouteSettings(name: Routes.chatsNew),
builder: (context) => CreateGroupMembersPage() builder: (context) => CreateGroupMembersPage()
), ),
Routes.chatsNewDetails: (Object arguments) => MaterialPageRoute( Routes.chatsNewDetails: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.chatsNewDetails), settings: RouteSettings(name: Routes.chatsNewDetails),
builder: (context) => CreateGroupDetailsPage() builder: (context) => CreateGroupDetailsPage()
), ),
Routes.image: (Object arguments) => MaterialPageRoute( Routes.image: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.image), settings: RouteSettings(name: Routes.image),
builder: (context) => ImagePage(arguments) builder: (context) => ImagePage(arguments)
), ),
Routes.start: (Object params) => MaterialPageRoute( Routes.start: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.start), settings: RouteSettings(name: Routes.start),
builder: (context) => StartPage() builder: (context) => StartPage()
), ),
Routes.startAdvanced: (Object params) => MaterialPageRoute( Routes.startAdvanced: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.startAdvanced), settings: RouteSettings(name: Routes.startAdvanced),
builder: (context) => AdvancedPage() builder: (context) => AdvancedPage()
), ),
Routes.startUsername: (Object params) => MaterialPageRoute( Routes.startUsername: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.startUsername), settings: RouteSettings(name: Routes.startUsername),
builder: (context) => UsernamePage() builder: (context) => UsernamePage()
), ),
Routes.startPassword: (Object params) => MaterialPageRoute( Routes.startPassword: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.startPassword), settings: RouteSettings(name: Routes.startPassword),
builder: (context) => PasswordPage() builder: (context) => PasswordPage()
), ),
...@@ -102,10 +99,9 @@ class App extends StatelessWidget { ...@@ -102,10 +99,9 @@ class App extends StatelessWidget {
// This widget is the root of your application. // This widget is the root of your application.
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return PlatformApp(
onGenerateTitle: (BuildContext context) onGenerateTitle: (BuildContext context)
=> l(context).appName, => l(context).appName,
theme: lightTheme,
localizationsDelegates: [ localizationsDelegates: [
const AppLocalizationsDelegate(), const AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
...@@ -118,6 +114,9 @@ class App extends StatelessWidget { ...@@ -118,6 +114,9 @@ class App extends StatelessWidget {
onGenerateRoute: (settings) { onGenerateRoute: (settings) {
return routes[settings.name](settings.arguments); return routes[settings.name](settings.arguments);
}, },
android: (_) => MaterialAppData(
theme: lightTheme,
),
); );
} }
} }
\ No newline at end of file
...@@ -14,21 +14,30 @@ ...@@ -14,21 +14,30 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>. // along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:pattle/src/app.dart'; import 'package:pattle/src/app.dart';
import 'package:pattle/src/ui/resources/localizations.dart'; import 'package:pattle/src/ui/resources/localizations.dart';
class StartPage extends StatelessWidget { class StartPage extends StatelessWidget {
@override // TODO: PR: Make BorderRadius.circular const
Widget build(BuildContext context) { static const buttonBorderRadius = BorderRadius.all(Radius.circular(96));
final buttonShape = RoundedRectangleBorder(
borderRadius: BorderRadius.circular(96)
);
final buttonPadding = EdgeInsets.all(16); static const buttonShape = RoundedRectangleBorder(
borderRadius: buttonBorderRadius
);
return Scaffold( static const buttonPadding = EdgeInsets.all(16);
void _loginWithUsername(BuildContext context) {
Navigator.pushNamed(context, Routes.startUsername);
}
@override
Widget build(BuildContext context) {
return PlatformScaffold(
body: Container( body: Container(
margin: const EdgeInsets.only(top: 16), margin: const EdgeInsets.only(top: 16),
child: Center( child: Center(
...@@ -41,28 +50,56 @@ class StartPage extends StatelessWidget { ...@@ -41,28 +50,56 @@ class StartPage extends StatelessWidget {
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
RaisedButton( PlatformWidget(
onPressed: null, android: (_) =>
child: Text(l(context).loginWithPhone.toUpperCase()), RaisedButton(
shape: buttonShape, onPressed: null,
padding: buttonPadding, child: PlatformText(l(context).loginWithPhone),
shape: buttonShape,
padding: buttonPadding,
),
ios: (_) =>
CupertinoButton.filled(
onPressed: null,
child: Text(l(context).loginWithPhone),
borderRadius: buttonBorderRadius,
padding: buttonPadding,
)
), ),
SizedBox(height: 16), SizedBox(height: 16),
OutlineButton( PlatformWidget(
onPressed: null, android: (_) =>
child: Text(l(context).loginWithEmail.toUpperCase()), OutlineButton(
shape: buttonShape, onPressed: null,
padding: buttonPadding, child: PlatformText(l(context).loginWithEmail),
shape: buttonShape,
padding: buttonPadding,
),
ios: (_) =>
CupertinoButton(
onPressed: null,
child: Text(l(context).loginWithEmail),
borderRadius: buttonBorderRadius,
padding: buttonPadding,
)
), ),
SizedBox(height: 16), SizedBox(height: 16),
FlatButton( PlatformWidget(
onPressed: () { android: (_) =>
Navigator.pushNamed(context, Routes.startUsername); FlatButton(
}, onPressed: () => _loginWithUsername(context),
child: Text(l(context).loginWithUsername.toUpperCase()), child: PlatformText(l(context).loginWithUsername),
shape: buttonShape, shape: buttonShape,
padding: buttonPadding, padding: buttonPadding,
), ),
ios: (_) =>
CupertinoButton(
onPressed: () => _loginWithUsername(context),
child: Text(l(context).loginWithUsername),
borderRadius: buttonBorderRadius,
padding: buttonPadding,
)
)
], ],
) )
], ],
......
...@@ -132,6 +132,13 @@ packages: ...@@ -132,6 +132,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_platform_widgets:
dependency: "direct main"
description:
name: flutter_platform_widgets
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
......
...@@ -32,6 +32,8 @@ dependencies: ...@@ -32,6 +32,8 @@ dependencies:
flutter_dotenv: ^2.0.1 flutter_dotenv: ^2.0.1
flutter_platform_widgets: ^0.10.0
respect_24_hour: ^0.0.2 respect_24_hour: ^0.0.2
transparent_image: ^1.0.0 transparent_image: ^1.0.0
......
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