add login

This commit is contained in:
yifeng.yl
2019-05-06 21:42:49 +08:00
parent edfe2cac20
commit 0ea68adb10
10 changed files with 330 additions and 40 deletions

17
android/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1

BIN
assets/images/FlutterGo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -353,7 +353,7 @@
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
@ -511,6 +511,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 4WLT68XRNA;
@ -527,7 +528,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.alibaba.fluttergo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "FlutterGO-alibaba-develop";
PROVISIONING_PROFILE_SPECIFIER = FlutterGO_alibaba_distribution_app_store;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;

View File

@ -9,6 +9,7 @@ import 'package:flutter_go/utils/shared_preferences.dart';
import 'package:flutter_go/views/home.dart';
import 'package:flutter_go/model/search_history.dart';
import 'package:flutter_go/utils/analytics.dart' as Analytics;
import 'package:flutter_go/views/login_page/login_page.dart';
//import 'views/welcome_page/index.dart';
const int ThemeColor = 0xFFC91B3A;
@ -25,7 +26,8 @@ class MyApp extends StatelessWidget {
}
showWelcomePage() {
// 暂时关掉欢迎介绍
return AppPage();
// return AppPage();
return LoginPage();
// bool showWelcome = sp.getBool(SharedPreferencesKeys.showWelcome);
// if (showWelcome == null || showWelcome == true) {
// return WelcomePage();

View File

@ -6,6 +6,7 @@ import '../widgets/404.dart';
import 'package:flutter_go/components/full_screen_code_dialog.dart';
import 'package:flutter_go/views/web_page/web_view_page.dart';
import 'package:flutter_go/views/home.dart';
import 'package:flutter_go/views/login_page/login_page.dart';
// app的首页
var homeHandler = new Handler(
@ -26,6 +27,10 @@ var widgetNotFoundHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return new WidgetNotFound();
});
var loginPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return LoginPage();
});
var fullScreenCodeDialog = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {

View File

@ -12,6 +12,7 @@ class Routes {
static String widgetDemo = '/widget-demo';
static String codeView = '/code-view';
static String webViewPage = '/web-view-page';
static String loginPage = '/loginpage';
static void configureRoutes(Router router) {
List widgetDemosList = new WidgetDemoList().getDemos();
@ -22,6 +23,7 @@ class Routes {
router.define('/category/:type', handler: categoryHandler);
router.define('/category/error/404', handler: widgetNotFoundHandler);
router.define(loginPage, handler: loginPageHandler);
router.define(codeView,handler:fullScreenCodeDialog);
router.define(webViewPage,handler:webViewPageHand);
widgetDemosList.forEach((demo) {

View File

@ -0,0 +1,218 @@
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
// 利用FocusNode和_focusScopeNode来控制焦点 可以通过FocusNode.of(context)来获取widget树中默认的_focusScopeNode
FocusNode _emailFocusNode = new FocusNode();
FocusNode _passwordFocusNode = new FocusNode();
FocusScopeNode _focusScopeNode = new FocusScopeNode();
GlobalKey<FormState> _signInFormKey = new GlobalKey();
bool isShowPassWord = false;
String username = '';
String password = '';
// 创建登录界面的TextForm
Widget buildSignInTextForm() {
return new Container(
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
width: MediaQuery.of(context).size.width * 0.8,
height: 190,
// * Flutter提供了一个Form widget它可以对输入框进行分组然后进行一些统一操作如输入内容校验、输入框重置以及输入内容保存。
child: new Form(
key: _signInFormKey,
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
child: Padding(
padding: const EdgeInsets.only(
left: 25, right: 25, top: 20, bottom: 20),
child: new TextFormField(
//关联焦点
focusNode: _emailFocusNode,
onEditingComplete: () {
if (_focusScopeNode == null) {
_focusScopeNode = FocusScope.of(context);
}
_focusScopeNode.requestFocus(_passwordFocusNode);
},
decoration: new InputDecoration(
icon: new Icon(
Icons.email,
color: Colors.black,
),
hintText: "Github 登录名",
border: InputBorder.none),
style: new TextStyle(fontSize: 16, color: Colors.black),
//验证
validator: (value) {
if (value.isEmpty) {
return "登录名不可为空!";
}
},
onSaved: (value) {
setState(() {
username = value;
});
},
),
),
),
new Container(
height: 1,
width: MediaQuery.of(context).size.width * 0.75,
color: Colors.grey[400],
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 25, right: 25, top: 20),
child: new TextFormField(
focusNode: _passwordFocusNode,
decoration: new InputDecoration(
icon: new Icon(
Icons.lock,
color: Colors.black,
),
hintText: "Github 登录密码",
border: InputBorder.none,
suffixIcon: new IconButton(
icon: new Icon(
Icons.remove_red_eye,
color: Colors.black,
),
onPressed: showPassWord,
),
),
//输入密码,需要用*****显示
obscureText: !isShowPassWord,
style: new TextStyle(fontSize: 16, color: Colors.black),
validator: (value) {
if (value == null || value.isEmpty) {
return "密码不可为空!";
}
},
onSaved: (value) {
setState(() {
password = value;
});
},
),
),
),
new Container(
height: 1,
width: MediaQuery.of(context).size.width * 0.75,
color: Colors.grey[400],
),
],
),
),
);
}
Widget buildSignInButton() {
return new GestureDetector(
child: new Container(
padding: EdgeInsets.only(left: 42, right: 42, top: 10, bottom: 10),
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
color: Theme.of(context).primaryColor),
child: new Text(
"LOGIN",
style: new TextStyle(fontSize: 25, color: Colors.white),
),
),
onTap: () {
// 利用key来获取widget的状态FormState,可以用过FormState对Form的子孙FromField进行统一的操作
if (_signInFormKey.currentState.validate()) {
// 如果输入都检验通过,则进行登录操作
Scaffold.of(context)
.showSnackBar(new SnackBar(content: new Text("执行登录操作")));
//调用所有自孩子的save回调保存表单内容
_signInFormKey.currentState.save();
}
},
);
}
// 点击控制密码是否显示
void showPassWord() {
setState(() {
isShowPassWord = !isShowPassWord;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
color: Theme.of(context).primaryColor,
child: Center(
child: Container(
width: MediaQuery.of(context).size.width * 0.85,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
color: Colors.white,
image: DecorationImage(
image: AssetImage(
'assets/images/paimaiLogo.png',
),
fit: BoxFit.scaleDown,
alignment: Alignment.bottomRight,
),
),
child: Stack(
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(height: 35.0),
Image.asset(
'assets/images/FlutterGo.png',
fit: BoxFit.contain,
width: 100.0,
height: 100.0,
),
buildSignInTextForm(),
buildSignInButton(),
SizedBox(height: 35.0),
],
),
Positioned(
top: 0,
left: 0,
bottom: 0,
child: Opacity(
opacity: .5,
child: Container(
width: MediaQuery.of(context).size.width * 0.85,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
color: Colors.black,
),
child: SpinKitPouringHourglass(color: Colors.white),
),
),
)
],
),
),
),
),
),
);
}
}

View File

@ -5,91 +5,105 @@ packages:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.1"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.0"
bloc:
dependency: "direct main"
description:
name: bloc
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
city_pickers:
dependency: "direct main"
description:
name: city_pickers
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.4"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.14.11"
cookie_jar:
dependency: transitive
description:
name: cookie_jar
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.8"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.16.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.2"
dio:
dependency: "direct main"
description:
name: dio
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.17"
event_bus:
dependency: "direct main"
description:
name: event_bus
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
firebase_analytics:
dependency: "direct main"
description:
name: firebase_analytics
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0+1"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.4"
fluro:
dependency: "direct main"
description:
name: fluro
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.4.0"
flutter:
@ -97,13 +111,27 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_bloc:
dependency: "direct main"
description:
name: flutter_bloc
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.11.1"
flutter_markdown:
dependency: "direct main"
description:
name: flutter_markdown
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.0"
flutter_spinkit:
dependency: "direct main"
description:
name: flutter_spinkit
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.0"
flutter_test:
dependency: "direct dev"
description: flutter
@ -113,77 +141,91 @@ packages:
dependency: "direct main"
description:
name: flutter_webview_plugin
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.4"
html:
dependency: "direct main"
description:
name: html
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.14.0+2"
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.0+1"
version: "0.6.0+2"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.15.7"
lpinyin:
dependency: transitive
description:
name: lpinyin
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.7"
markdown:
dependency: transitive
description:
name: markdown
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.3"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.3"
rxdart:
dependency: transitive
description:
name: rxdart
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.21.0"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
sky_engine:
@ -195,77 +237,77 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.5"
sqflite:
dependency: "direct main"
description:
name: sqflite
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.5"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.3"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.5"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.2"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
sdks:

View File

@ -27,6 +27,7 @@ dependencies:
url_launcher: ^5.0.2
# 本地存储、收藏功能
shared_preferences: ^0.4.3
flutter_spinkit: "^3.1.0"
dio: ^1.0.6
flutter_webview_plugin: ^0.3.4
# 日期格式化