mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
135 lines
4.5 KiB
Dart
135 lines
4.5 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gallery/demo/shrine/colors.dart';
|
|
|
|
class LoginPage extends StatefulWidget {
|
|
@override
|
|
_LoginPageState createState() => _LoginPageState();
|
|
}
|
|
|
|
class _LoginPageState extends State<LoginPage> {
|
|
final TextEditingController _usernameController = TextEditingController();
|
|
final TextEditingController _passwordController = TextEditingController();
|
|
static const ShapeDecoration _decoration = ShapeDecoration(
|
|
shape: BeveledRectangleBorder(
|
|
side: BorderSide(color: kShrineBrown900, width: 0.5),
|
|
borderRadius: BorderRadius.all(Radius.circular(7.0)),
|
|
),
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
elevation: 0.0,
|
|
backgroundColor: Colors.white,
|
|
brightness: Brightness.light,
|
|
leading: IconButton(
|
|
icon: const BackButtonIcon(),
|
|
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
|
|
onPressed: () {
|
|
// The login screen is immediately displayed on top of the Shrine
|
|
// home screen using onGenerateRoute and so rootNavigator must be
|
|
// set to true in order to get out of Shrine completely.
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
},
|
|
),
|
|
),
|
|
body: SafeArea(
|
|
child: ListView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
|
children: <Widget>[
|
|
const SizedBox(height: 80.0),
|
|
Column(
|
|
children: <Widget>[
|
|
Image.asset('packages/shrine_images/diamond.png'),
|
|
const SizedBox(height: 16.0),
|
|
Text(
|
|
'SHRINE',
|
|
style: Theme.of(context).textTheme.headline5,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 120.0),
|
|
PrimaryColorOverride(
|
|
color: kShrineBrown900,
|
|
child: Container(
|
|
decoration: _decoration,
|
|
child: TextField(
|
|
controller: _usernameController,
|
|
decoration: const InputDecoration(
|
|
labelText: 'Username',
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 12.0),
|
|
PrimaryColorOverride(
|
|
color: kShrineBrown900,
|
|
child: Container(
|
|
decoration: _decoration,
|
|
child: TextField(
|
|
controller: _passwordController,
|
|
decoration: const InputDecoration(
|
|
labelText: 'Password',
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Wrap(
|
|
children: <Widget>[
|
|
ButtonBar(
|
|
children: <Widget>[
|
|
FlatButton(
|
|
child: const Text('CANCEL'),
|
|
shape: const BeveledRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(7.0)),
|
|
),
|
|
onPressed: () {
|
|
// The login screen is immediately displayed on top of
|
|
// the Shrine home screen using onGenerateRoute and so
|
|
// rootNavigator must be set to true in order to get out
|
|
// of Shrine completely.
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
},
|
|
),
|
|
RaisedButton(
|
|
child: const Text('NEXT'),
|
|
elevation: 8.0,
|
|
shape: const BeveledRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(7.0)),
|
|
),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class PrimaryColorOverride extends StatelessWidget {
|
|
const PrimaryColorOverride({Key key, this.color, this.child}) : super(key: key);
|
|
|
|
final Color color;
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Theme(
|
|
child: child,
|
|
data: Theme.of(context).copyWith(primaryColor: color),
|
|
);
|
|
}
|
|
}
|