X Tutup
Skip to content

Commit 60e7c3d

Browse files
committed
add login page
1 parent 708c7b0 commit 60e7c3d

File tree

7 files changed

+131
-15
lines changed

7 files changed

+131
-15
lines changed

lib/common/style/GSYStyle.dart

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,34 @@ import 'package:flutter/material.dart';
33
class GSYColors {
44
static const String welcomeMessage = "Welcome To Flutter";
55

6-
static const int _PrimaryValue = 0xFF24292E;
7-
static const int _PrimaryLightValue = 0xFF42464b;
8-
static const int _PrimaryDarkValue = 0xFF121917;
6+
static const int primaryValue = 0xFF24292E;
7+
static const int primaryLightValue = 0xFF42464b;
8+
static const int primaryDarkValue = 0xFF121917;
9+
10+
static const int cardWhite = 0xFFFFFFFF;
11+
12+
static const int textWhite = 0xFFFFFFFF;
913

1014
static const MaterialColor primarySwatch = const MaterialColor(
11-
_PrimaryValue,
15+
primaryValue,
1216
const <int, Color>{
13-
50: const Color(_PrimaryLightValue),
14-
100: const Color(_PrimaryLightValue),
15-
200: const Color(_PrimaryLightValue),
16-
300: const Color(_PrimaryLightValue),
17-
400: const Color(_PrimaryLightValue),
18-
500: const Color(_PrimaryValue),
19-
600: const Color(_PrimaryDarkValue),
20-
700: const Color(_PrimaryDarkValue),
21-
800: const Color(_PrimaryDarkValue),
22-
900: const Color(_PrimaryDarkValue),
17+
50: const Color(primaryLightValue),
18+
100: const Color(primaryLightValue),
19+
200: const Color(primaryLightValue),
20+
300: const Color(primaryLightValue),
21+
400: const Color(primaryLightValue),
22+
500: const Color(primaryValue),
23+
600: const Color(primaryDarkValue),
24+
700: const Color(primaryDarkValue),
25+
800: const Color(primaryDarkValue),
26+
900: const Color(primaryDarkValue),
2327
},
2428
);
2529
}
2630

2731
class GSYConstant {}
32+
33+
34+
class GSYStrings {
35+
static const String login_text = "登录";
36+
}

lib/page/LoginPage.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
3+
import 'package:gsy_github_app_flutter/widget/GSYFlexButton.dart';
4+
import 'package:gsy_github_app_flutter/widget/GSYInputWidget.dart';
5+
6+
class LoginPage extends StatelessWidget {
7+
@override
8+
Widget build(BuildContext context) {
9+
return new Container(
10+
color: Color(GSYColors.primaryValue),
11+
child: new Center(
12+
child: new Card(
13+
color: Color(GSYColors.cardWhite),
14+
margin: const EdgeInsets.all(20.0),
15+
child: new Padding(
16+
padding: new EdgeInsets.only(left: 30.0, top: 60.0, right: 30.0, bottom: 80.0),
17+
child: new Column(
18+
mainAxisAlignment: MainAxisAlignment.center,
19+
mainAxisSize: MainAxisSize.min,
20+
children: <Widget>[
21+
new Image(image: new AssetImage('static/images/logo.png'), width: 80.0, height: 80.0),
22+
new Padding(padding: new EdgeInsets.all(10.0)),
23+
new GSYInputWidget(hintText: "11111", iconData: Icons.access_alarm),
24+
new Padding(padding: new EdgeInsets.all(10.0)),
25+
new GSYInputWidget(hintText: "11111", iconData: Icons.access_alarm),
26+
new Padding(padding: new EdgeInsets.all(30.0)),
27+
new GSYFlexButton(
28+
text: GSYStrings.login_text,
29+
color: Color(GSYColors.primaryValue),
30+
textColor: Color(GSYColors.textWhite),
31+
onPress: () {},
32+
)
33+
],
34+
)))));
35+
}
36+
}

lib/page/WelcomePage.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:async';
22

33
import 'package:flutter/material.dart';
44
import 'package:gsy_github_app_flutter/page/HomePage.dart';
5+
import 'package:gsy_github_app_flutter/page/LoginPage.dart';
56

67
class WelcomePage extends StatelessWidget {
78
@override
@@ -11,7 +12,7 @@ class WelcomePage extends StatelessWidget {
1112
Navigator
1213
.of(context)
1314
.pushReplacement(new MaterialPageRoute(builder: (context) {
14-
return new HomePage();
15+
return new LoginPage();
1516
}));
1617
});
1718
return new Container(

lib/widget/GSYFlexButton.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'package:flutter/material.dart';
2+
3+
class GSYFlexButton extends StatelessWidget {
4+
final String text;
5+
6+
final Color color;
7+
8+
final Color textColor;
9+
10+
final VoidCallback onPress;
11+
12+
GSYFlexButton({Key key, this.text, this.color, this.textColor, this.onPress}) : super(key: key);
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
return new Row(children: <Widget>[
17+
new Expanded(
18+
child: new RaisedButton(
19+
padding: new EdgeInsets.only(left: 20.0, top: 10.0, right: 20.0, bottom: 10.0),
20+
textColor: textColor,
21+
color: color,
22+
child: new Text(text, style: new TextStyle(fontSize: 20.0)),
23+
onPressed: () {
24+
if (this.onPress != null) {
25+
this.onPress();
26+
}
27+
}))
28+
]);
29+
}
30+
}

lib/widget/GSYInputWidget.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'package:flutter/material.dart';
2+
3+
/// 带图标的输入框
4+
class GSYInputWidget extends StatefulWidget {
5+
6+
final String hintText;
7+
8+
final IconData iconData;
9+
10+
GSYInputWidget({Key key, this.hintText, this.iconData}) : super(key: key);
11+
12+
@override
13+
_GSYInputWidgetState createState() => new _GSYInputWidgetState(hintText, iconData);
14+
}
15+
16+
/// State for [GSYInputWidget] widgets.
17+
class _GSYInputWidgetState extends State<GSYInputWidget> {
18+
19+
final String hintText;
20+
21+
final IconData iconData;
22+
23+
final TextEditingController _controller = new TextEditingController();
24+
25+
_GSYInputWidgetState(this.hintText, this.iconData) : super();
26+
27+
@override
28+
Widget build(BuildContext context) {
29+
return new TextField(
30+
controller: _controller,
31+
decoration: new InputDecoration(
32+
hintText: hintText,
33+
icon: new Icon(iconData),
34+
),
35+
);
36+
}
37+
}

pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ flutter:
5555
#
5656
# For details regarding fonts from package dependencies,
5757
# see https://flutter.io/custom-fonts/#from-packages
58+
59+
assets:
60+
- static/images/logo.png

static/images/logo.png

75.6 KB
Loading

0 commit comments

Comments
 (0)
X Tutup