Commit 53c2b36a authored by Wilko Manger's avatar Wilko Manger

Make more use of theming

parent 4e046d70
......@@ -123,7 +123,8 @@ class App extends StatelessWidget {
Widget build(BuildContext context) {
return DynamicTheme(
defaultBrightness: Brightness.light,
data: (brightness) => theme(brightness),
data: (brightness) =>
brightness == Brightness.dark ? darkTheme : lightTheme,
themedWidgetBuilder: (context, theme) {
return MaterialApp(
onGenerateTitle: (BuildContext context) => l(context).appName,
......
......@@ -18,27 +18,49 @@
import 'package:flutter/material.dart';
import 'package:pattle/src/ui/util/color.dart';
ThemeData theme(Brightness brightness) {
return ThemeData(
primarySwatch: LightColors.red,
primaryColorDark: LightColors.red[700],
accentColor: LightColors.red,
brightness: brightness,
primaryColorBrightness: Brightness.dark,
accentColorBrightness: Brightness.dark,
cursorColor: LightColors.red,
toggleableActiveColor:
brightness == Brightness.dark ? LightColors.red[400] : null,
textSelectionHandleColor:
brightness == Brightness.dark ? LightColors.red[400] : null,
buttonTheme: ButtonThemeData(
buttonColor: LightColors.red[500],
textTheme: ButtonTextTheme.primary,
),
appBarTheme: AppBarTheme(
color: LightColors.red,
),
);
final _theme = ThemeData(
primarySwatch: LightColors.red,
primaryColorDark: LightColors.red[700],
accentColor: LightColors.red,
primaryColorBrightness: Brightness.dark,
accentColorBrightness: Brightness.dark,
cursorColor: LightColors.red,
buttonTheme: ButtonThemeData(
buttonColor: LightColors.red[500],
textTheme: ButtonTextTheme.primary,
),
appBarTheme: AppBarTheme(
color: LightColors.red,
),
);
final lightTheme = _theme.copyWith(
brightness: Brightness.light,
);
final darkTheme = _theme.copyWith(
brightness: Brightness.dark,
toggleableActiveColor: LightColors.red[400],
textSelectionHandleColor: LightColors.red[400],
);
extension Themes on ThemeData {
Widget withTransparentAppBar({@required Widget child}) => Builder(
builder: (context) {
return Theme(
data: copyWith(
appBarTheme: AppBarTheme(
color: Colors.transparent,
iconTheme: IconThemeData(
color: Theme.of(context).primaryColor,
),
elevation: 0,
),
),
child: child,
);
},
);
}
Color chatBackgroundColor(BuildContext context) {
......
......@@ -14,11 +14,12 @@
//
// 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:pattle/src/ui/resources/localizations.dart';
import 'package:pattle/src/ui/start/start_bloc.dart';
import '../resources/theme.dart';
class AdvancedPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => AdvancedPageState();
......@@ -37,91 +38,88 @@ class AdvancedPageState extends State<AdvancedPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
l(context).advanced,
style: TextStyle(
color: Theme.of(context).primaryColor,
return Theme.of(context).withTransparentAppBar(
child: Scaffold(
appBar: AppBar(
title: Text(
l(context).advanced,
style: TextStyle(
color: Theme.of(context).primaryColor,
),
),
),
iconTheme: IconThemeData(
color: Theme.of(context).primaryColor,
),
elevation: 0,
backgroundColor: const Color(0x00000000),
),
body: Container(
margin: EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.home,
color: Theme.of(context).hintColor,
size: 32,
),
SizedBox(width: 16),
Flexible(
child: StreamBuilder<bool>(
stream: bloc.homeserverChanged,
builder:
(BuildContext context, AsyncSnapshot<bool> snapshot) {
var errorText;
body: Container(
margin: EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.home,
color: Theme.of(context).hintColor,
size: 32,
),
SizedBox(width: 16),
Flexible(
child: StreamBuilder<bool>(
stream: bloc.homeserverChanged,
builder:
(BuildContext context, AsyncSnapshot<bool> snapshot) {
var errorText;
if (snapshot.hasError) {
errorText = l(context).hostnameInvalidError;
} else {
errorText = null;
}
if (snapshot.hasError) {
errorText = l(context).hostnameInvalidError;
} else {
errorText = null;
}
return TextField(
controller: homeserverTextController,
decoration: InputDecoration(
filled: true,
labelText: l(context).homeserver,
hintText: bloc.userIdDomain.toString(),
errorText: errorText,
),
);
},
),
)
],
),
SizedBox(height: 32),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.person,
color: Theme.of(context).hintColor,
size: 32,
),
SizedBox(width: 16),
Flexible(
child: TextField(
decoration: InputDecoration(
filled: true,
labelText: l(context).identityServer,
return TextField(
controller: homeserverTextController,
decoration: InputDecoration(
filled: true,
labelText: l(context).homeserver,
hintText: bloc.userIdDomain.toString(),
errorText: errorText,
),
);
},
),
)
],
),
SizedBox(height: 32),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.person,
color: Theme.of(context).hintColor,
size: 32,
),
)
],
),
SizedBox(height: 32),
RaisedButton(
onPressed: () {
bloc.setHomeserverUrl(homeserverTextController.text);
bloc.homeserverSetViaAdvanced = true;
Navigator.pop(context);
},
child: Text(l(context).confirm.toUpperCase()),
)
],
SizedBox(width: 16),
Flexible(
child: TextField(
decoration: InputDecoration(
filled: true,
labelText: l(context).identityServer,
),
),
)
],
),
SizedBox(height: 32),
RaisedButton(
onPressed: () {
bloc.setHomeserverUrl(homeserverTextController.text);
bloc.homeserverSetViaAdvanced = true;
Navigator.pop(context);
},
child: Text(l(context).confirm.toUpperCase()),
)
],
),
),
),
);
......
......@@ -89,7 +89,7 @@ class UsernamePageState extends State<UsernamePage> {
children: <Widget>[
Text(
l(context).enterUsername,
style: TextStyle(fontSize: 24),
style: Theme.of(context).textTheme.headline,
),
SizedBox(height: 16),
StreamBuilder<bool>(
......
......@@ -76,7 +76,7 @@ class PasswordPageState extends State<PasswordPage> {
children: <Widget>[
Text(
l(context).enterPassword,
style: TextStyle(fontSize: 24),
style: Theme.of(context).textTheme.headline,
),
SizedBox(height: 16),
StreamBuilder<RequestState>(
......
......@@ -20,15 +20,6 @@ import 'package:pattle/src/app.dart';
import 'package:pattle/src/ui/resources/localizations.dart';
class StartPage extends StatelessWidget {
// TODO: PR: Make BorderRadius.circular const
static const buttonBorderRadius = BorderRadius.all(Radius.circular(96));
static const buttonShape = RoundedRectangleBorder(
borderRadius: buttonBorderRadius,
);
static const buttonPadding = EdgeInsets.all(16);
void _loginWithUsername(BuildContext context) {
Navigator.pushNamed(context, Routes.startUsername);
}
......@@ -50,31 +41,33 @@ class StartPage extends StatelessWidget {
l(context).appName,
style: TextStyle(fontSize: 96),
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
RaisedButton(
onPressed: null,
child: Text(loginWithPhone),
shape: buttonShape,
padding: buttonPadding,
ButtonTheme.fromButtonThemeData(
data: ButtonTheme.of(context).copyWith(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(96),
),
SizedBox(height: 16),
OutlineButton(
onPressed: null,
child: Text(loginWithEmail),
shape: buttonShape,
padding: buttonPadding,
),
SizedBox(height: 16),
FlatButton(
onPressed: () => _loginWithUsername(context),
child: Text(loginWithUsername),
shape: buttonShape,
padding: buttonPadding,
),
],
),
padding: EdgeInsets.all(16),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
RaisedButton(
onPressed: null,
child: Text(loginWithPhone),
),
SizedBox(height: 16),
OutlineButton(
onPressed: null,
child: Text(loginWithEmail),
),
SizedBox(height: 16),
FlatButton(
onPressed: () => _loginWithUsername(context),
child: Text(loginWithUsername),
),
],
),
)
],
),
),
......
......@@ -526,4 +526,4 @@ packages:
version: "2.2.0"
sdks:
dart: ">=2.6.0 <3.0.0"
flutter: ">=1.10.15-pre.148 <2.0.0"
flutter: ">=1.12.1 <2.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