Commit ae66bd4c authored by Wilko Manger's avatar Wilko Manger

Use platform aware widgets on StartPage

parent 24eff5c2
......@@ -17,6 +17,7 @@
import 'package:flutter/material.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:pattle/src/ui/initial/initial_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';
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/start_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';
final routes = {
Routes.root: (Object params) => MaterialPageRoute(
Routes.root: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.root),
builder: (context) => InitialPage()
),
Routes.chats: (Object arguments) => MaterialPageRoute(
Routes.chats: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.chats),
builder: (context) {
if (arguments is Room) {
......@@ -50,31 +47,31 @@ final routes = {
}
}
),
Routes.chatsNew: (Object arguments) => MaterialPageRoute(
Routes.chatsNew: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.chatsNew),
builder: (context) => CreateGroupMembersPage()
),
Routes.chatsNewDetails: (Object arguments) => MaterialPageRoute(
Routes.chatsNewDetails: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.chatsNewDetails),
builder: (context) => CreateGroupDetailsPage()
),
Routes.image: (Object arguments) => MaterialPageRoute(
Routes.image: (Object arguments) => platformPageRoute(
settings: RouteSettings(name: Routes.image),
builder: (context) => ImagePage(arguments)
),
Routes.start: (Object params) => MaterialPageRoute(
Routes.start: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.start),
builder: (context) => StartPage()
),
Routes.startAdvanced: (Object params) => MaterialPageRoute(
Routes.startAdvanced: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.startAdvanced),
builder: (context) => AdvancedPage()
),
Routes.startUsername: (Object params) => MaterialPageRoute(
Routes.startUsername: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.startUsername),
builder: (context) => UsernamePage()
),
Routes.startPassword: (Object params) => MaterialPageRoute(
Routes.startPassword: (Object params) => platformPageRoute(
settings: RouteSettings(name: Routes.startPassword),
builder: (context) => PasswordPage()
),
......@@ -102,10 +99,9 @@ class App extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
return PlatformApp(
onGenerateTitle: (BuildContext context)
=> l(context).appName,
theme: lightTheme,
localizationsDelegates: [
const AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
......@@ -118,6 +114,9 @@ class App extends StatelessWidget {
onGenerateRoute: (settings) {
return routes[settings.name](settings.arguments);
},
android: (_) => MaterialAppData(
theme: lightTheme,
),
);
}
}
\ No newline at end of file
......@@ -14,21 +14,30 @@
//
// 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/cupertino.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/ui/resources/localizations.dart';
class StartPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final buttonShape = RoundedRectangleBorder(
borderRadius: BorderRadius.circular(96)
);
// TODO: PR: Make BorderRadius.circular const
static const buttonBorderRadius = BorderRadius.all(Radius.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(
margin: const EdgeInsets.only(top: 16),
child: Center(
......@@ -41,28 +50,56 @@ class StartPage extends StatelessWidget {
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
RaisedButton(
onPressed: null,
child: Text(l(context).loginWithPhone.toUpperCase()),
shape: buttonShape,
padding: buttonPadding,
PlatformWidget(
android: (_) =>
RaisedButton(
onPressed: null,
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),
OutlineButton(
onPressed: null,
child: Text(l(context).loginWithEmail.toUpperCase()),
shape: buttonShape,
padding: buttonPadding,
PlatformWidget(
android: (_) =>
OutlineButton(
onPressed: null,
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),
FlatButton(
onPressed: () {
Navigator.pushNamed(context, Routes.startUsername);
},
child: Text(l(context).loginWithUsername.toUpperCase()),
shape: buttonShape,
padding: buttonPadding,
),
PlatformWidget(
android: (_) =>
FlatButton(
onPressed: () => _loginWithUsername(context),
child: PlatformText(l(context).loginWithUsername),
shape: buttonShape,
padding: buttonPadding,
),
ios: (_) =>
CupertinoButton(
onPressed: () => _loginWithUsername(context),
child: Text(l(context).loginWithUsername),
borderRadius: buttonBorderRadius,
padding: buttonPadding,
)
)
],
)
],
......
......@@ -132,6 +132,13 @@ packages:
description: flutter
source: sdk
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:
dependency: "direct dev"
description: flutter
......
......@@ -32,6 +32,8 @@ dependencies:
flutter_dotenv: ^2.0.1
flutter_platform_widgets: ^0.10.0
respect_24_hour: ^0.0.2
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