flutter/examples/flutter_gallery/lib/demo/shrine/login.dart
Ian Hickson a78fb87dfe
Relicense Shrine demo to match rest of repository (#45718)
* Relicense Shrine demo to match rest of repository

The Shrine demo was Apache-licensed. The code was mostly
Google-written, with contributions from:

 - Michelle Dudley (@michdud)

 - Abhijeeth Padarthi <rkinabhi@gmail.com> (@rkinabhi)

 - @a14n

I contacted all three, and they confirmed their approval for this
change, as described below.

Abhijeeth Padarthi said by e-mail on Thu, Nov 21, 2019 at 5:48 PM:

> hi Ian,
>
> sure :)
>
> let me know if I need to do anything on my end..

Michelle Dudley wrote by e-mail on Sun, Nov 24, 2019 at 2:07 PM:

> Hi Ian,
>
> That would be ok with me.
>
> Thanks,
>
> Michelle

@a14n said on Discord's Flutter server in the #hackers channel at 10:44PM on Thursday, November 21, 2019:

> @Hixie no problem I agree with this relicensing

* Remove shrine loophole from license checker.
2019-11-27 16:25:56 -08:00

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.headline,
),
],
),
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),
);
}
}