diff --git a/images/github_icon.png b/images/github_icon.png new file mode 100644 index 0000000..ee52ac0 Binary files /dev/null and b/images/github_icon.png differ diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000..7467879 Binary files /dev/null and b/images/logo.png differ diff --git a/images/silan_icon.png b/images/silan_icon.png new file mode 100644 index 0000000..a62bdc0 Binary files /dev/null and b/images/silan_icon.png differ diff --git a/images/splash_logo.png b/images/splash_logo.png new file mode 100644 index 0000000..12d0e6f Binary files /dev/null and b/images/splash_logo.png differ diff --git a/images/wechat_icon.png b/images/wechat_icon.png new file mode 100644 index 0000000..2c2302b Binary files /dev/null and b/images/wechat_icon.png differ diff --git a/lib/common/GlobalConfig.dart b/lib/common/GlobalConfig.dart index 79e97cf..d7649a3 100644 --- a/lib/common/GlobalConfig.dart +++ b/lib/common/GlobalConfig.dart @@ -9,10 +9,15 @@ class GlobalConfig { static Color color_white_a80 = Color(0xccffffff); static Color color_blue = Color(0xcc0000ff); + static bool dark = false; + static ThemeData themeData = new ThemeData.light(); + static Color searchBackgroundColor = Colors.white10; + static Color cardBackgroundColor = new Color(0xFF222222); + static Color fontColor = Colors.white30; ///导航 static String homeTab = "首页"; - static String secondTab = "二页"; - static String thiredTab = "三页"; - static String fourthTab = "四页"; - static String fifthTab = "五页"; + static String secondTab = "项目中心"; + static String thiredTab = ""; + static String fourthTab = "英雄广场"; + static String fifthTab = "发现"; } diff --git a/lib/common/NavigationIconView.dart b/lib/common/NavigationIconView.dart new file mode 100644 index 0000000..ac0aca8 --- /dev/null +++ b/lib/common/NavigationIconView.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class NavigationIconView { + + NavigationIconView({ + Widget icon, + Widget title, + TickerProvider vsync + }): + item = new BottomNavigationBarItem( + icon: icon, + title: title, + ), + controller = new AnimationController( + duration: kThemeAnimationDuration, + vsync: vsync + ); + + final BottomNavigationBarItem item; + final AnimationController controller; +} \ No newline at end of file diff --git a/lib/common/color_const.dart b/lib/common/color_const.dart new file mode 100644 index 0000000..ac45f05 --- /dev/null +++ b/lib/common/color_const.dart @@ -0,0 +1,20 @@ +/// +/// Created by NieBin on 18-12-14 +/// Github: https://github.com/nb312 +/// Email: niebin312@gmail.com +/// +import "package:flutter/material.dart"; + +const MAIN_COLOR = Color(0xFF303030); +const DARK_COLOR = Color(0xFFBDBDBD); +const BOTTOM_COLORS = [MAIN_COLOR, DARK_COLOR]; +const YELLOW = Color(0xfffbed96); +const BLUE = Color(0xffabecd6); +const BLUE_DEEP = Color(0xffA8CBFD); +const BLUE_LIGHT = Color(0xffAED3EA); +const PURPLE = Color(0xffccc3fc); +const RED = Color(0xffF2A7B3); +const GREEN = Color(0xffc7e5b4); +const RED_LIGHT = Color(0xffFFC3A0); +const TEXT_BLACK = Color(0xFF353535); +const TEXT_BLACK_LIGHT = Color(0xFF34323D); diff --git a/lib/fonts/iconfont.ttf b/lib/fonts/iconfont.ttf new file mode 100644 index 0000000..9a0d69f Binary files /dev/null and b/lib/fonts/iconfont.ttf differ diff --git a/lib/main.dart b/lib/main.dart index 069b124..61c6bd2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,7 @@ import 'package:coderiver/ui/Application.dart'; +import 'package:coderiver/ui/home/HomePage.dart'; +import 'package:coderiver/ui/home/SplashPage.dart'; +import 'package:coderiver/ui/login/LoginPage.dart'; import 'package:flutter/material.dart'; void main() => runApp(MyApp()); @@ -8,18 +11,11 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - - primarySwatch: Colors.blue, - ), - home: Scaffold( - appBar: AppBar( - title: Text("CodeRiver"), - ), - body: ApplicationPage(), - ) + home: new SplashPage(), + routes: { + // 路由 + '/HomePage': (BuildContext context) => new LoginPage() + }, ); } } - diff --git a/lib/ui/Application.dart b/lib/ui/Application.dart index 0924a81..29c327c 100644 --- a/lib/ui/Application.dart +++ b/lib/ui/Application.dart @@ -1,8 +1,11 @@ import 'package:coderiver/common/GlobalConfig.dart'; +import 'package:coderiver/common/NavigationIconView.dart'; import 'package:coderiver/common/User.dart'; +import 'package:coderiver/ui/four/HeroPage.dart'; import 'package:coderiver/ui/home/HomePage.dart'; import 'package:coderiver/ui/home/MinePage.dart'; import 'package:coderiver/ui/home/SeconedPage.dart'; +import 'package:coderiver/ui/three/AddPage.dart'; import 'package:flutter/material.dart'; class ApplicationPage extends StatefulWidget { @@ -13,8 +16,101 @@ class ApplicationPage extends StatefulWidget { } class _ApplicationPageState extends State - with SingleTickerProviderStateMixin { - int _page = 0; + with TickerProviderStateMixin { + int _currentIndex = 0; + List _navigationViews; + List _pageList; + StatefulWidget _currentPage; + + @override + void initState() { + super.initState(); + _navigationViews = [ + new NavigationIconView( + icon: new Icon(Icons.account_balance), + title: new Text(GlobalConfig.homeTab), + vsync: this, + ), + new NavigationIconView( + icon: new Icon(Icons.album), + title: new Text(GlobalConfig.secondTab), + vsync: this, + ), + new NavigationIconView( + icon: new Icon(Icons.add_circle_outline), + title: new Text(GlobalConfig.thiredTab), + vsync: this, + ), + new NavigationIconView( + icon: new Icon(Icons.add_alert), + title: new Text(GlobalConfig.fourthTab), + vsync: this, + ), + new NavigationIconView( + icon: new Icon(Icons.perm_identity), + title: new Text(GlobalConfig.fifthTab), + vsync: this, + ), + ]; + for (NavigationIconView view in _navigationViews) { + view.controller.addListener(_rebuild); + } + + _pageList = [ + new HomePage(), + new SeconedPage(), + new AddPage(), + new HeroPage(), + new MinePage() + ]; + _currentPage = _pageList[_currentIndex]; + } + + void _rebuild() { + setState(() {}); + } + + @override + void dispose() { + super.dispose(); + for (NavigationIconView view in _navigationViews) { + view.controller.dispose(); + } + } + + @override + Widget build(BuildContext context) { + final BottomNavigationBar bottomNavigationBar = new BottomNavigationBar( + items: _navigationViews + .map((NavigationIconView navigationIconView) => + navigationIconView.item) + .toList(), + currentIndex: _currentIndex, + fixedColor: Colors.blue, + type: BottomNavigationBarType.fixed, + onTap: (int index) { + setState(() { + _navigationViews[_currentIndex].controller.reverse(); + _currentIndex = index; + _navigationViews[_currentIndex].controller.forward(); + _currentPage = _pageList[_currentIndex]; + }); + } + ); + + return new MaterialApp( + home: new Scaffold( + body: new Center( + child: _currentPage + ), + bottomNavigationBar: bottomNavigationBar, + ), + theme: new ThemeData.light() + ); + } + +} +/*int _page = 0; PageController _pageController; final List _bottomTabs = [ @@ -75,3 +171,4 @@ class _ApplicationPageState extends State }); } } +*/ \ No newline at end of file diff --git a/lib/ui/four/HeroPage.dart b/lib/ui/four/HeroPage.dart new file mode 100644 index 0000000..fb51f54 --- /dev/null +++ b/lib/ui/four/HeroPage.dart @@ -0,0 +1,33 @@ +import 'package:coderiver/common/GlobalConfig.dart'; +import 'package:flutter/material.dart'; + +class HeroPage extends StatefulWidget { + + @override + _IdeaPageState createState() => new _IdeaPageState(); + +} + +class _IdeaPageState extends State { + + @override + Widget build(BuildContext context) { + return new MaterialApp( + home: new Scaffold( + appBar: new AppBar( + title: new Text('想法'), + actions: [ + new Container( + + ) + ], + ), + body: new Center( + child: null + ), + ), + theme: GlobalConfig.themeData + ); + } + +} \ No newline at end of file diff --git a/lib/ui/home/HomePage.dart b/lib/ui/home/HomePage.dart index 82c9b40..b0a5aa2 100644 --- a/lib/ui/home/HomePage.dart +++ b/lib/ui/home/HomePage.dart @@ -1,37 +1,1224 @@ import 'package:coderiver/common/GlobalConfig.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class HomePage extends StatefulWidget { @override - State createState() { - return _HomePageState(); - } + _HomePageState createState() => new _HomePageState(); } -class _HomePageState extends State - with AutomaticKeepAliveClientMixin { - @override - bool get wantKeepAlive => null; +class _HomePageState extends State { + Widget barSearch() { + return new Container( + child: new FlatButton( + onPressed: () {}, + child: new Row( + children: [ + new Container( + child: new Icon( + Icons.search, + size: 18.0, + ), + margin: const EdgeInsets.only(right: 26.0), + ), + new Expanded( + child: new Container( + child: new Text("搜索知乎内容"), + )), + new Container( + child: new FlatButton( + onPressed: () {}, + child: new Icon(Icons.settings_overscan, size: 18.0), + ), + width: 40.0, + ), + ], + )), + decoration: new BoxDecoration( + borderRadius: const BorderRadius.all(const Radius.circular(4.0)), + color: GlobalConfig.searchBackgroundColor)); + } - @override - void initState() { - super.initState(); + Widget myInfoCard() { + return new Container( + color: GlobalConfig.cardBackgroundColor, + margin: const EdgeInsets.only(top: 10.0, bottom: 6.0), + padding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + child: new Column( + children: [ + new Container( + margin: + const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 16.0), + decoration: new BoxDecoration( + color: GlobalConfig.dark == true + ? Colors.white10 + : new Color(0xFFF5F5F5), + borderRadius: new BorderRadius.all(new Radius.circular(6.0))), + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new ListTile( + leading: new Container( + child: new CircleAvatar( + backgroundImage: new NetworkImage( + "https://pic1.zhimg.com/v2-ec7ed574da66e1b495fcad2cc3d71cb9_xl.jpg"), + radius: 20.0), + ), + title: new Container( + margin: const EdgeInsets.only(bottom: 2.0), + child: new Text("learner"), + ), + subtitle: new Container( + margin: const EdgeInsets.only(top: 2.0), + child: new Text("查看或编辑个人主页"), + ), + ), + )), + ), + new Container( + child: new Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + new Container( + width: (MediaQuery.of(context).size.width - 6.0) / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + height: 50.0, + child: new Column( + children: [ + new Container( + child: new Text( + "57", + style: new TextStyle( + fontSize: 16.0, + color: GlobalConfig.fontColor), + ), + ), + new Container( + child: new Text( + "我的创作", + style: new TextStyle( + fontSize: 12.0, + color: GlobalConfig.fontColor), + ), + ), + ], + ), + )), + ), + new Container( + height: 14.0, + width: 1.0, + decoration: new BoxDecoration( + border: new BorderDirectional( + start: new BorderSide( + color: GlobalConfig.dark == true + ? Colors.white12 + : Colors.black12, + width: 1.0))), + ), + new Container( + width: (MediaQuery.of(context).size.width - 6.0) / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + height: 50.0, + child: new Column( + children: [ + new Container( + child: new Text( + "210", + style: new TextStyle( + fontSize: 16.0, + color: GlobalConfig.fontColor), + ), + ), + new Container( + child: new Text( + "关注", + style: new TextStyle( + fontSize: 12.0, + color: GlobalConfig.fontColor), + ), + ) + ], + ), + )), + ), + new Container( + height: 14.0, + width: 1.0, + decoration: new BoxDecoration( + border: new BorderDirectional( + start: new BorderSide( + color: GlobalConfig.dark == true + ? Colors.white12 + : Colors.black12, + width: 1.0))), + ), + new Container( + width: (MediaQuery.of(context).size.width - 6.0) / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + height: 50.0, + child: new Column( + children: [ + new Container( + child: new Text( + "18", + style: new TextStyle( + fontSize: 16.0, + color: GlobalConfig.fontColor), + ), + ), + new Container( + child: new Text( + "我的收藏", + style: new TextStyle( + fontSize: 12.0, + color: GlobalConfig.fontColor), + ), + ) + ], + ), + )), + ), + new Container( + height: 14.0, + width: 1.0, + decoration: new BoxDecoration( + border: new BorderDirectional( + start: new BorderSide( + color: GlobalConfig.dark == true + ? Colors.white12 + : Colors.black12, + width: 1.0))), + ), + new Container( + width: (MediaQuery.of(context).size.width - 6.0) / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + height: 50.0, + child: new Column( + children: [ + new Container( + child: new Text( + "33", + style: new TextStyle( + fontSize: 16.0, + color: GlobalConfig.fontColor), + ), + ), + new Container( + child: new Text( + "最近浏览", + style: new TextStyle( + fontSize: 12.0, + color: GlobalConfig.fontColor), + ), + ) + ], + ), + ))) + ], + ), + ) + ], + ), + ); } - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(GlobalConfig.homeTab), - centerTitle: true, - actions: [ - IconButton( - icon: new Icon(Icons.assignment), - onPressed: () {}, + Widget myServiceCard() { + return new Container( + color: GlobalConfig.cardBackgroundColor, + margin: const EdgeInsets.only(top: 6.0, bottom: 6.0), + padding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + child: new Column( + children: [ + new Container( + child: new Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: + new Icon(Icons.book, color: Colors.white), + backgroundColor: Colors.green, + ), + ), + new Container( + child: new Text( + "我的书架", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0), + ), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.flash_on, + color: Colors.white), + backgroundColor: Colors.blue, + ), + ), + new Container( + child: new Text("我的 Live", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.free_breakfast, + color: Colors.white), + backgroundColor: new Color(0xFFA68F52), + ), + ), + new Container( + child: new Text("私家课", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.attach_money, + color: Colors.white), + backgroundColor: new Color(0xFF355A9B), + ), + ), + new Container( + child: new Text("付费咨询", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + ], + ), + ), + new Container( + child: new Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: + new Icon(Icons.book, color: Colors.white), + backgroundColor: Colors.green, + ), + ), + new Container( + child: new Text( + "我的书架", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0), + ), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.flash_on, + color: Colors.white), + backgroundColor: Colors.blue, + ), + ), + new Container( + child: new Text("我的 Live", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.free_breakfast, + color: Colors.white), + backgroundColor: new Color(0xFFA68F52), + ), + ), + new Container( + child: new Text("私家课", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.attach_money, + color: Colors.white), + backgroundColor: new Color(0xFF355A9B), + ), + ), + new Container( + child: new Text("付费咨询", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + ], + ), + ), + new Container( + child: new Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: + new Icon(Icons.book, color: Colors.white), + backgroundColor: Colors.green, + ), + ), + new Container( + child: new Text( + "我的书架", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0), + ), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.flash_on, + color: Colors.white), + backgroundColor: Colors.blue, + ), + ), + new Container( + child: new Text("我的 Live", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.free_breakfast, + color: Colors.white), + backgroundColor: new Color(0xFFA68F52), + ), + ), + new Container( + child: new Text("私家课", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.attach_money, + color: Colors.white), + backgroundColor: new Color(0xFF355A9B), + ), + ), + new Container( + child: new Text("付费咨询", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + ], + ), + ), + new Container( + margin: const EdgeInsets.only(top: 16.0), + child: new Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: + new Icon(Icons.shop, color: Colors.white), + backgroundColor: new Color(0xFF088DB4), + ), + ), + new Container( + child: new Text( + "已购", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0), + ), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: + new Icon(Icons.radio, color: Colors.white), + backgroundColor: Colors.blue, + ), + ), + new Container( + child: new Text("余额礼卷", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.wifi_tethering, + color: Colors.white), + backgroundColor: new Color(0xFF029A3F), + ), + ), + new Container( + child: new Text("服务", + style: new TextStyle( + color: GlobalConfig.fontColor, + fontSize: 14.0)), + ) + ], + ), + )), + ), + ], + ), + ) + ], + ), + ); + } + + Widget settingCard() { + return new Container( + color: GlobalConfig.cardBackgroundColor, + margin: const EdgeInsets.only(top: 6.0, bottom: 6.0), + padding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + child: new Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.invert_colors, + color: Colors.white), + backgroundColor: new Color(0xFFB88800), + ), + ), + new Container( + child: new Text("社区建设", + style: new TextStyle( + color: GlobalConfig.fontColor, fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: + new Icon(Icons.golf_course, color: Colors.white), + backgroundColor: new Color(0xFF63616D), + ), + ), + new Container( + child: new Text("反馈", + style: new TextStyle( + color: GlobalConfig.fontColor, fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () { + setState(() { + if (GlobalConfig.dark == true) { + GlobalConfig.themeData = new ThemeData( + primaryColor: Colors.white, + scaffoldBackgroundColor: new Color(0xFFEBEBEB), + ); + GlobalConfig.searchBackgroundColor = + new Color(0xFFEBEBEB); + GlobalConfig.cardBackgroundColor = Colors.white; + GlobalConfig.fontColor = Colors.black54; + GlobalConfig.dark = false; + } else { + GlobalConfig.themeData = new ThemeData.dark(); + GlobalConfig.searchBackgroundColor = Colors.white10; + GlobalConfig.cardBackgroundColor = new Color(0xFF222222); + GlobalConfig.fontColor = Colors.white30; + GlobalConfig.dark = true; + } + }); + }, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon( + GlobalConfig.dark == true + ? Icons.wb_sunny + : Icons.brightness_2, + color: Colors.white), + backgroundColor: new Color(0xFFB86A0D), + ), + ), + new Container( + child: new Text( + GlobalConfig.dark == true ? "日间模式" : "夜间模式", + style: new TextStyle( + color: GlobalConfig.fontColor, fontSize: 14.0)), + ) + ], + ), + )), + ), + new Container( + width: MediaQuery.of(context).size.width / 4, + child: new FlatButton( + onPressed: () {}, + child: new Container( + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(bottom: 6.0), + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.perm_data_setting, + color: Colors.white), + backgroundColor: new Color(0xFF636269), + ), + ), + new Container( + child: new Text("设置", + style: new TextStyle( + color: GlobalConfig.fontColor, fontSize: 14.0)), + ) + ], + ), + )), + ), + ], + ), + ); + } + + Widget videoCard() { + return new Container( + color: GlobalConfig.cardBackgroundColor, + margin: const EdgeInsets.only(top: 6.0, bottom: 6.0), + padding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(left: 16.0, bottom: 20.0), + child: new Row( + children: [ + new Container( + child: new CircleAvatar( + radius: 20.0, + child: new Icon(Icons.videocam, color: Colors.white), + backgroundColor: new Color(0xFFB36905), + ), + ), + new Expanded( + child: new Container( + margin: const EdgeInsets.only(left: 8.0), + child: new Text( + "视频创作", + style: new TextStyle(fontSize: 18.0), + ), + ), + ), + new Container( + child: new FlatButton( + onPressed: () {}, + child: new Text( + "拍一个", + style: new TextStyle(color: Colors.blue), + )), + ) + ], + )), + new Container( + margin: const EdgeInsets.only(left: 16.0), + child: new SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: new Row( + children: [ + new Container( + width: MediaQuery.of(context).size.width / 2.5, + margin: const EdgeInsets.only(right: 6.0), + child: new AspectRatio( + aspectRatio: 4.0 / 2.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic2.zhimg.com/50/v2-5942a51e6b834f10074f8d50be5bbd4d_400x224.jpg"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))), + new Container( + margin: const EdgeInsets.only(right: 6.0), + width: MediaQuery.of(context).size.width / 2.5, + child: new AspectRatio( + aspectRatio: 4.0 / 2.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic3.zhimg.com/50/v2-7fc9a1572c6fc72a3dea0b73a9be36e7_400x224.jpg"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))), + new Container( + margin: const EdgeInsets.only(right: 6.0), + width: MediaQuery.of(context).size.width / 2.5, + child: new AspectRatio( + aspectRatio: 4.0 / 2.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic4.zhimg.com/50/v2-898f43a488b606061c877ac2a471e221_400x224.jpg"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))), + new Container( + width: MediaQuery.of(context).size.width / 2.5, + child: new AspectRatio( + aspectRatio: 4.0 / 2.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic1.zhimg.com/50/v2-0008057d1ad2bd813aea4fc247959e63_400x224.jpg"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))) + ], + ), + ), + ) + ], + )); + } + + Widget ideaCard() { + return new Container( + color: GlobalConfig.cardBackgroundColor, + margin: const EdgeInsets.only(top: 6.0, bottom: 6.0), + padding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + child: new Column( + children: [ + new Container( + margin: const EdgeInsets.only(left: 16.0, bottom: 20.0), + child: new Row( + children: [ + new Container( + child: new CircleAvatar( + radius: 20.0, + child: + new Icon(Icons.all_inclusive, color: Colors.white), + backgroundColor: Colors.blue, + ), + ), + new Expanded( + child: new Container( + margin: const EdgeInsets.only(left: 8.0), + child: new Text( + "想法", + style: new TextStyle(fontSize: 18.0), + ), + ), + ), + new Container( + child: new FlatButton( + onPressed: () {}, + child: new Text( + "去往想法首页", + style: new TextStyle(color: Colors.blue), + )), + ) + ], + )), + new Container( + margin: const EdgeInsets.only(left: 16.0), + child: new SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: new Row( + children: [ + new Container( + margin: const EdgeInsets.only(right: 6.0), + decoration: new BoxDecoration( + color: GlobalConfig.searchBackgroundColor, + borderRadius: + new BorderRadius.all(new Radius.circular(6.0))), + child: new Row( + children: [ + new Container( + padding: const EdgeInsets.only(left: 10.0), + child: new Column( + children: [ + new Align( + alignment: Alignment.centerLeft, + child: new Container( + child: new Text( + "苹果 WWDC 2018 正在举行", + style: new TextStyle( + color: GlobalConfig.dark == true + ? Colors.white70 + : Colors.black, + fontSize: 16.0), + ), + ), + ), + new Align( + alignment: Alignment.centerLeft, + child: new Container( + margin: const EdgeInsets.only(top: 6.0), + child: new Text( + "软件更新意料之中,硬件之谜...", + style: new TextStyle( + color: GlobalConfig.fontColor), + ), + )) + ], + ), + ), + new Container( + margin: const EdgeInsets.all(10.0), + width: MediaQuery.of(context).size.width / 5, + child: new AspectRatio( + aspectRatio: 1.0 / 1.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic2.zhimg.com/50/v2-55039fa535f3fe06365c0fcdaa9e3847_400x224.jpg"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))) + ], + )), + new Container( + margin: const EdgeInsets.only(right: 6.0), + decoration: new BoxDecoration( + color: GlobalConfig.searchBackgroundColor, + borderRadius: + new BorderRadius.all(new Radius.circular(6.0))), + child: new Row( + children: [ + new Container( + padding: const EdgeInsets.only(left: 10.0), + child: new Column( + children: [ + new Align( + alignment: Alignment.centerLeft, + child: new Container( + child: new Text( + "此刻你的桌子是什么样子?", + style: new TextStyle( + color: GlobalConfig.dark == true + ? Colors.white70 + : Colors.black, + fontSize: 16.0), + ), + ), + ), + new Align( + alignment: Alignment.centerLeft, + child: new Container( + margin: const EdgeInsets.only(top: 6.0), + child: new Text( + "晒一晒你的书桌/办公桌", + style: new TextStyle( + color: GlobalConfig.fontColor), + ), + )) + ], + ), + ), + new Container( + margin: const EdgeInsets.all(10.0), + width: MediaQuery.of(context).size.width / 5, + child: new AspectRatio( + aspectRatio: 1.0 / 1.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic3.zhimg.com/v2-b4551f702970ff37709cdd7fd884de5e_294x245|adx4.png"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))) + ], + )), + new Container( + margin: const EdgeInsets.only(right: 6.0), + decoration: new BoxDecoration( + color: GlobalConfig.searchBackgroundColor, + borderRadius: + new BorderRadius.all(new Radius.circular(6.0))), + child: new Row( + children: [ + new Container( + padding: const EdgeInsets.only(left: 10.0), + child: new Column( + children: [ + new Align( + alignment: Alignment.centerLeft, + child: new Container( + child: new Text( + "关于高考你印象最深的是...", + style: new TextStyle( + color: GlobalConfig.dark == true + ? Colors.white70 + : Colors.black, + fontSize: 16.0), + ), + ), + ), + new Align( + alignment: Alignment.centerLeft, + child: new Container( + margin: const EdgeInsets.only(top: 6.0), + child: new Text( + "聊聊你的高三生活", + style: new TextStyle( + color: GlobalConfig.fontColor), + ), + )) + ], + ), + ), + new Container( + margin: const EdgeInsets.all(10.0), + width: MediaQuery.of(context).size.width / 5, + child: new AspectRatio( + aspectRatio: 1.0 / 1.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic2.zhimg.com/50/v2-ce2e01a047e4aba9bfabf8469cfd3e75_400x224.jpg"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))) + ], + )), + new Container( + margin: const EdgeInsets.only(right: 6.0), + decoration: new BoxDecoration( + color: GlobalConfig.searchBackgroundColor, + borderRadius: + new BorderRadius.all(new Radius.circular(6.0))), + child: new Row( + children: [ + new Container( + padding: const EdgeInsets.only(left: 10.0), + child: new Column( + children: [ + new Align( + alignment: Alignment.centerLeft, + child: new Container( + child: new Text( + "夏天一定要吃的食物有哪些", + style: new TextStyle( + color: GlobalConfig.dark == true + ? Colors.white70 + : Colors.black, + fontSize: 16.0), + ), + ), + ), + new Align( + alignment: Alignment.centerLeft, + child: new Container( + margin: const EdgeInsets.only(top: 6.0), + child: new Text( + "最适合夏天吃的那种", + style: new TextStyle( + color: GlobalConfig.fontColor), + ), + )) + ], + ), + ), + new Container( + margin: const EdgeInsets.all(10.0), + width: MediaQuery.of(context).size.width / 5, + child: new AspectRatio( + aspectRatio: 1.0 / 1.0, + child: new Container( + foregroundDecoration: new BoxDecoration( + image: new DecorationImage( + image: new NetworkImage( + "https://pic1.zhimg.com/50/v2-bb3806c2ced60e5b7f38a0aa06b89511_400x224.jpg"), + centerSlice: new Rect.fromLTRB( + 270.0, 180.0, 1360.0, 730.0), + ), + borderRadius: const BorderRadius.all( + const Radius.circular(6.0))), + ))) + ], + )), + ], + ), + ), ) ], - ), - body: Text(('开发中..'))); + )); + } + + @override + Widget build(BuildContext context) { + return new MaterialApp( + theme: GlobalConfig.themeData, + home: new Scaffold( + appBar: new AppBar( + title: new Text('首页'), + actions: [new Container()], + ), + body: new SingleChildScrollView( + child: new Container( + child: new Column( + children: [ + myInfoCard(), + myServiceCard(), + myServiceCard(), + settingCard(), + videoCard(), + ideaCard() + ], + ), + ), + )), + ); } } diff --git a/lib/ui/home/MinePage.dart b/lib/ui/home/MinePage.dart index a67cae4..dfbbbb0 100644 --- a/lib/ui/home/MinePage.dart +++ b/lib/ui/home/MinePage.dart @@ -9,29 +9,19 @@ class MinePage extends StatefulWidget { } } -class _MinePageState extends State - with AutomaticKeepAliveClientMixin { - @override - bool get wantKeepAlive => null; - - @override - void initState() { - super.initState(); - } - +class _MinePageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(GlobalConfig.homeTab), - centerTitle: true, - actions: [ - IconButton( - icon: new Icon(Icons.assignment), - onPressed: () {}, - ) - ], + return new MaterialApp( + home: new Scaffold( + appBar: new AppBar( + title: new Text('想法'), + actions: [new Container()], + ), + body: new Center( + child: new Text('想法'), + ), ), - body: Text(('开发中..'))); + theme: GlobalConfig.themeData); } } diff --git a/lib/ui/home/SeconedPage.dart b/lib/ui/home/SeconedPage.dart index 10c3209..3f7e2e9 100644 --- a/lib/ui/home/SeconedPage.dart +++ b/lib/ui/home/SeconedPage.dart @@ -9,29 +9,20 @@ class SeconedPage extends StatefulWidget { } } -class _SeconedPageState extends State - with AutomaticKeepAliveClientMixin { - @override - bool get wantKeepAlive => null; - - @override - void initState() { - super.initState(); - } +class _SeconedPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(GlobalConfig.homeTab), - centerTitle: true, - actions: [ - IconButton( - icon: new Icon(Icons.assignment), - onPressed: () {}, - ) - ], + return new MaterialApp( + home: new Scaffold( + appBar: new AppBar( + title: new Text('想法'), + actions: [new Container()], + ), + body: new Center( + child: new Text('想法'), + ), ), - body: Text(('开发中..'))); + theme: GlobalConfig.themeData); } } diff --git a/lib/ui/home/SplashPage.dart b/lib/ui/home/SplashPage.dart new file mode 100644 index 0000000..72fbc67 --- /dev/null +++ b/lib/ui/home/SplashPage.dart @@ -0,0 +1,44 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class SplashPage extends StatefulWidget { + @override + State createState() { + return _SplashPageState(); + } +} + +class _SplashPageState extends State { + @override + Widget build(BuildContext context) { + return new MaterialApp( + theme: new ThemeData(backgroundColor: Colors.blue), + home: new Scaffold( + backgroundColor: Colors.white, + body: new Center( + child: new Image.asset( + "images/splash_logo.png", + width: 170, + height: 170, + ), + ), + )); + } + + @override + void initState() { + super.initState(); + countDown(); + } + +// 倒计时 + void countDown() { + var _duration = new Duration(seconds: 3); + new Future.delayed(_duration, go2HomePage); + } + + void go2HomePage() { + Navigator.of(context).pushReplacementNamed('/HomePage'); + } +} diff --git a/lib/ui/login/LoginPage.dart b/lib/ui/login/LoginPage.dart index e69de29..ab4686f 100644 --- a/lib/ui/login/LoginPage.dart +++ b/lib/ui/login/LoginPage.dart @@ -0,0 +1,206 @@ +import 'package:coderiver/common/GlobalConfig.dart'; +import 'package:coderiver/common/ShowToast.dart'; +import 'package:coderiver/common/Snack.dart'; +import 'package:coderiver/common/color_const.dart'; +import 'package:coderiver/ui/Application.dart'; +import 'package:coderiver/ui/home/HomePage.dart'; +import 'package:coderiver/ui/login/LoginPhone.dart'; +import 'package:coderiver/ui/mine/RegisterNickNamePage.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class LoginPage extends StatefulWidget { + @override + _MarketPageState createState() => new _MarketPageState(); +} + +class _MarketPageState extends State { + @override + Widget build(BuildContext context) { + return new MaterialApp( + home: new Scaffold( + body: Container( + alignment: AlignmentDirectional.topStart, + padding: EdgeInsets.only(top: 40, left: 20, right: 20), + constraints: BoxConstraints.expand(), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [GREEN, GlobalConfig.colorPrimary]), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _logText(context), + Padding( + padding: const EdgeInsets.fromLTRB(0.0, 70.0, 0.0, 0.0), + child: new Image.asset( + 'images/logo.png', + width: 90, + height: 90, + )), + Padding( + padding: const EdgeInsets.fromLTRB(0.0, 40.0, 0.0, 20.0), + child: new Text( + '欢迎来到CodeRiver', + style: new TextStyle( + fontSize: 24.0, + color: Colors.white, + fontStyle: FontStyle.normal), + ), + ), + _btnGithubLogin(context), + _btnCreadeAccound(context), + Padding( + padding: const EdgeInsets.fromLTRB(0.0, 30.0, 0.0, 0.0), + child: new Text( + '更多登录方式', + style: new TextStyle( + fontSize: 18.0, + color: Colors.white, + fontStyle: FontStyle.normal), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.fromLTRB(0.0, 26.0, 0.0, 0.0), + child: weiboOR('新浪微博')), + Padding( + padding: EdgeInsets.fromLTRB(20.0, 26.0, 0.0, 0.0), + child: weChatOR('微信')), + ], + ) + //_body(), + ], + ), + ), + ), + ); + } +} + +Widget _logText(context) { + return new Align( + alignment: FractionalOffset.topRight, + child: new Padding( + padding: EdgeInsets.only(right: 0.0, top: 0.0), + child: new GestureDetector( + child: new Text( + '登录', + style: new TextStyle( + fontSize: 18.0, color: Colors.white, fontStyle: FontStyle.normal), + ), + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (BuildContext context) => new LoginPhonePage())); + }, + ), + ), + ); +} + +Widget _btnGithubLogin(context) { + return Container( + child: RaisedButton.icon( + color: Colors.white, + disabledColor: Colors.transparent, + shape: new RoundedRectangleBorder( + side: BorderSide(color: Colors.white), + borderRadius: BorderRadius.all(Radius.circular(50))), + icon: new Icon(Icons.star), + onPressed: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (BuildContext context) => new ApplicationPage())); + }, + label: new Text( + '使用GitHub账号登录', + style: new TextStyle( + color: Colors.green, fontStyle: FontStyle.normal, fontSize: 20), + )), + width: double.infinity, + height: 50, + ); +} + +Widget _btnCreadeAccound(context) { + return Container( + margin: new EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 5.0), + child: FlatButton( + color: Colors.transparent, + disabledColor: Colors.transparent, + onPressed: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (BuildContext context) => + new RegisterNickNamePage())); + }, + shape: new RoundedRectangleBorder( + side: BorderSide(color: Colors.white), + borderRadius: BorderRadius.all(Radius.circular(50))), + child: new Text( + '创建账号', + style: new TextStyle( + color: Colors.white, fontStyle: FontStyle.normal, fontSize: 20), + )), + width: double.infinity, + height: 50, + ); +} + +Widget weiboOR(String str) { + return Row( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), + child: new Image.asset( + 'images/silan_icon.png', + )), + Padding( + padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), + child: new GestureDetector( + child: new Text( + str, + style: new TextStyle( + color: Colors.white, fontStyle: FontStyle.normal), + ), + onTap: () { + Fluttertoast.showToast(msg: "微博登录"); + }), + ), + ], + ); +} + +Widget weChatOR(String str) { + return Row( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), + child: new Image.asset( + 'images/wechat_icon.png', + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), + child: new GestureDetector( + child: new Text( + str, + style: new TextStyle( + color: Colors.white, fontStyle: FontStyle.normal), + ), + onTap: () { + Fluttertoast.showToast(msg: "微信登录"); + }), + ), + ], + ); +} diff --git a/lib/ui/login/LoginPhone.dart b/lib/ui/login/LoginPhone.dart new file mode 100644 index 0000000..4ce6a80 --- /dev/null +++ b/lib/ui/login/LoginPhone.dart @@ -0,0 +1,187 @@ +import 'package:coderiver/common/GlobalConfig.dart'; +import 'package:coderiver/common/ShowToast.dart'; +import 'package:coderiver/common/color_const.dart'; +import 'package:coderiver/ui/login/LoginPage.dart'; +import 'package:coderiver/ui/mine/ClearableInputField.dart'; +import 'package:coderiver/ui/mine/RegisterNickNamePage.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class LoginPhonePage extends StatefulWidget { + @override + _LoginPhonePageState createState() => new _LoginPhonePageState(); +} + +class _LoginPhonePageState extends State { + ClearableInputField _userNameInputForm; + ClearableInputField _psdInputForm; + TextEditingController _userNameController = TextEditingController(); + TextEditingController _psdController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return new MaterialApp( + home: new Scaffold( + floatingActionButton: new Theme( + data: Theme.of(context).copyWith(accentColor: Colors.white), + child: new FloatingActionButton( + onPressed: () { + Fluttertoast.showToast(msg: "....."); + }, + child: new Icon(Icons.arrow_forward_ios, + color: GlobalConfig.colorPrimary), + ), + ), + body: Container( + alignment: AlignmentDirectional.topStart, + padding: EdgeInsets.only(top: 40, left: 20, right: 20), + constraints: BoxConstraints.expand(), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [GREEN, GlobalConfig.colorPrimary]), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(6.0), + child: new GestureDetector( + child: Icon(Icons.arrow_back_ios, color: Colors.white), + onTap: () { + Navigator.pop(context); + }), + ), + Padding( + padding: const EdgeInsets.fromLTRB(10.0, 40.0, 0.0, 20.0), + child: new Text( + '登录', + style: new TextStyle( + fontSize: 28.0, + color: Colors.white, + fontStyle: FontStyle.normal), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(10.0, 40.0, 0.0, 10.0), + child: new Text( + '手机号码', + style: new TextStyle( + fontSize: 20.0, + color: Colors.white, + fontStyle: FontStyle.normal), + ), + ), + SizedBox(height: 0.0), + _buildUserNameInputForm(), + Padding( + padding: const EdgeInsets.fromLTRB(10.0, 20.0, 0.0, 0.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + new Expanded( + child: new Container( + margin: const EdgeInsets.only(left: 0.0), + child: new Text( + "输入密码", + style: new TextStyle( + fontSize: 18.0, + color: Colors.white, + ), + ), + ), + ), + new Container( + child: new FlatButton( + onPressed: () {}, + child: new Text( + "隐藏", + style: new TextStyle( + color: Colors.white, fontSize: 18), + textAlign: TextAlign.right, + )), + ) + ]), + ), + SizedBox(height: 0.0), + _buildPsdInputForm(), + Expanded( + child: Container( + padding: EdgeInsets.all(5.0), + child: _emailText(context), + ), + flex: 1, + ), + ], + ), + ), + ), + ); + } + + Widget _buildUserNameInputForm() { + _userNameInputForm = ClearableInputField( + controller: _userNameController, + inputType: TextInputType.text, + hintTxt: null, + showPrefixIcon: false, + hintStyle: new TextStyle(color: Colors.white, fontSize: 18.0), + textStyle: new TextStyle(color: Colors.white, fontSize: 24.0), + padding: const EdgeInsets.fromLTRB(10.0, 4.0, 0.0, 20.0), + ); + return _userNameInputForm; + } + + Widget _buildPsdInputForm() { + _psdInputForm = ClearableInputField( + controller: _psdController, + inputType: TextInputType.text, + hintTxt: null, + showPrefixIcon: true, + hintStyle: new TextStyle(color: Colors.white, fontSize: 18.0), + textStyle: new TextStyle(color: Colors.white, fontSize: 24.0), + padding: const EdgeInsets.fromLTRB(10.0, 4.0, 0.0, 20.0), + ); + return _psdInputForm; + } +} + +Widget _emailText(context) { + return new Align( + alignment: FractionalOffset.bottomLeft, + child: new Padding( + padding: EdgeInsets.only(right: 0.0, top: 0.0), + child: _btnCreadeAccound(context), + ), + ); +} + +Widget _btnCreadeAccound(context) { + return Container( + margin: new EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 20.0), + child: FlatButton( + color: Colors.transparent, + disabledColor: Colors.transparent, + onPressed: () { + Fluttertoast.showToast(msg: "使用邮箱"); + /*Navigator.push( + context, + new MaterialPageRoute( + builder: (BuildContext context) => + new RegisterNickNamePage()));*/ + }, + shape: new RoundedRectangleBorder( + side: BorderSide(color: Colors.white), + borderRadius: BorderRadius.all(Radius.circular(50))), + child: new Text( + '使用邮箱', + style: new TextStyle( + color: Colors.white, fontStyle: FontStyle.normal, fontSize: 20), + )), + height: 50, + width: 160, + ); +} diff --git a/lib/ui/mine/ClearableInputField.dart b/lib/ui/mine/ClearableInputField.dart new file mode 100644 index 0000000..26de932 --- /dev/null +++ b/lib/ui/mine/ClearableInputField.dart @@ -0,0 +1,126 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class ClearableInputField extends StatefulWidget { + final ValueChanged onchange; + final ValueChanged onSubmit; + final String hintTxt; + final bool autoFocus; + final TextStyle textStyle; + final TextStyle hintStyle; + final InputBorder border; + final TextEditingController controller; + final TextInputType inputType; + final bool obscureText; + final EdgeInsetsGeometry padding; + final Color fillColor; + final bool showPrefixIcon; + + ClearableInputField( + {this.onchange, + this.hintTxt, + this.autoFocus = true, + this.onSubmit, + this.textStyle, + this.hintStyle, + this.border, + this.fillColor, + this.controller, + this.inputType, + this.padding, + this.showPrefixIcon = true, + this.obscureText = false}); + + @override + State createState() => new _ClearableInputFieldState(); +} + +class _ClearableInputFieldState extends State { + bool _showClearIcon = false; + FocusNode _focusNode; + + @override + Widget build(BuildContext context) { + var _controller = (null == widget.controller) + ? TextEditingController() + : widget.controller; + _focusNode = FocusNode(); + return TextField( + obscureText: widget.obscureText, + keyboardType: widget.inputType, + autofocus: widget.autoFocus, + focusNode: _focusNode, + controller: _controller, + cursorColor: Colors.white, + style: widget.textStyle, + onChanged: onTextChanged, + onSubmitted: onSubmit, + decoration: InputDecoration( + contentPadding: + (null == widget.padding) ? EdgeInsets.all(0.0) : widget.padding, + /* suffixIcon: Icon(Icons.chevron_right), //输入框内右侧图标 + icon: Icon(Icons.person), //输入框左侧图标 + prefixIcon: Icon(Icons.skip_previous), //输入框内左侧图标 + helperText: 'helperText',*/ + + hintText: widget.hintTxt, + hintStyle: widget.hintStyle, + fillColor: widget.fillColor, + filled: null != widget.fillColor, + border: widget.border, + labelText: widget.hintTxt, + labelStyle: widget.hintStyle, + errorBorder: widget.border, + focusedBorder: widget.border, + enabledBorder: widget.border, + disabledBorder: widget.border, + focusedErrorBorder: widget.border, + suffixIcon: _buildDefaultClearIcon(context, _controller), + prefixIcon: widget.showPrefixIcon + ? (_buildDefaultPrefixIcon()) + : Icon(Icons.person)), + ); + } + + void onTextChanged(String str) { + bool newState = (str.length <= 0) ? false : true; + if (newState != _showClearIcon) { + setState(() { + _showClearIcon = newState; + }); + } + widget.onchange(str); + } + + void onSubmit(String str) { + SystemChannels.textInput.invokeMethod('TextInput.hide'); +// FocusScope.of(context).requestFocus(new FocusNode()); + widget.onSubmit(str); + } + + Widget _buildDefaultClearIcon( + BuildContext context, TextEditingController controller) { + return Visibility( + child: InkWell( + child: Icon( + Icons.close, + color: Colors.white, + ), + onTap: () { + controller.clear(); + widget.onchange(""); + FocusScope.of(context).requestFocus(_focusNode); + setState(() { + _showClearIcon = false; + }); + }, + ), + visible: _showClearIcon, + ); + } + + Widget _buildDefaultPrefixIcon() { + return null; + //return Icon(Icons.close, color: Colors.white); + } +} diff --git a/lib/ui/mine/MinePage.dart b/lib/ui/mine/MinePage.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/ui/mine/RegisterNickNamePage.dart b/lib/ui/mine/RegisterNickNamePage.dart new file mode 100644 index 0000000..1fa3cd5 --- /dev/null +++ b/lib/ui/mine/RegisterNickNamePage.dart @@ -0,0 +1,94 @@ +import 'package:coderiver/common/GlobalConfig.dart'; +import 'package:coderiver/common/color_const.dart'; +import 'package:coderiver/ui/login/LoginPhone.dart'; +import 'package:coderiver/ui/mine/ClearableInputField.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class RegisterNickNamePage extends StatefulWidget { + @override + _RegisterNickNamePageState createState() => new _RegisterNickNamePageState(); +} + +class _RegisterNickNamePageState extends State { + ClearableInputField _userNameInputForm; + TextEditingController _userNameController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return new MaterialApp( + home: new Scaffold( + floatingActionButton: new Theme( + data: Theme.of(context).copyWith(accentColor: Colors.white), + child: new FloatingActionButton( + onPressed: () { + + }, + child: new Icon(Icons.arrow_forward_ios, + color: GlobalConfig.colorPrimary), + ), + ), + body: Container( + alignment: AlignmentDirectional.topStart, + padding: EdgeInsets.only(top: 40, left: 20, right: 20), + constraints: BoxConstraints.expand(), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [GREEN, GlobalConfig.colorPrimary]), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(6.0), + child: new GestureDetector( + child: Icon(Icons.arrow_back_ios, color: Colors.white), + onTap: () { + Navigator.pop(context); + }), + ), + Padding( + padding: const EdgeInsets.fromLTRB(10.0, 40.0, 0.0, 20.0), + child: new Text( + '您的昵称?', + style: new TextStyle( + fontSize: 28.0, + color: Colors.white, + fontStyle: FontStyle.normal), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(10.0, 40.0, 0.0, 20.0), + + child: new Text( + '昵称', + style: new TextStyle( + fontSize: 20.0, + color: Colors.white, + fontStyle: FontStyle.normal), + ), + ), + SizedBox(height: 0.0), + _buildUserNameInputForm(), + ], + ), + ), + ), + ); + } + + Widget _buildUserNameInputForm() { + _userNameInputForm = ClearableInputField( + controller: _userNameController, + inputType: TextInputType.text, + hintTxt: null, + hintStyle: new TextStyle(color: Colors.white, fontSize: 18.0), + textStyle: new TextStyle(color: Colors.white, fontSize: 24.0), + padding: const EdgeInsets.fromLTRB(10.0, 10.0, 0.0, 20.0), + ); + return _userNameInputForm; + } +} diff --git a/lib/ui/three/AddPage.dart b/lib/ui/three/AddPage.dart new file mode 100644 index 0000000..e29e5b8 --- /dev/null +++ b/lib/ui/three/AddPage.dart @@ -0,0 +1,33 @@ +import 'package:coderiver/common/GlobalConfig.dart'; +import 'package:flutter/material.dart'; + +class AddPage extends StatefulWidget { + + @override + _IdeaPageState createState() => new _IdeaPageState(); + +} + +class _IdeaPageState extends State { + + @override + Widget build(BuildContext context) { + return new MaterialApp( + home: new Scaffold( + appBar: new AppBar( + title: new Text('想法'), + actions: [ + new Container( + + ) + ], + ), + body: new Center( + child: null + ), + ), + theme: GlobalConfig.themeData + ); + } + +} \ No newline at end of file diff --git a/lib/utils/GradientUtil.dart b/lib/utils/GradientUtil.dart new file mode 100644 index 0000000..9756cce --- /dev/null +++ b/lib/utils/GradientUtil.dart @@ -0,0 +1,63 @@ +import 'package:coderiver/common/color_const.dart'; +/// +/// Created by NieBin on 2018/12/28 +/// Github: https://github.com/nb312 +/// Email: niebin312@gmail.com +/// +import "package:flutter/material.dart"; + +class GradientUtil { + static LinearGradient _getLinearGradient(Color left, Color right, + {begin = AlignmentDirectional.centerStart, + end = AlignmentDirectional.centerEnd, + opacity = 1.0}) => + LinearGradient( + colors: [ + left.withOpacity(opacity), + right.withOpacity(opacity), + ], + begin: begin, + end: end, + ); + + static LinearGradient yellowGreen( + {begin = AlignmentDirectional.centerStart, + end = AlignmentDirectional.centerEnd, + opacity = 1.0}) => + _getLinearGradient(YELLOW, GREEN, + begin: begin, end: end, opacity: opacity); + + static LinearGradient red( + {begin = AlignmentDirectional.centerStart, + end = AlignmentDirectional.centerEnd, + opacity = 1.0}) => + _getLinearGradient(RED_LIGHT, RED, + begin: begin, end: end, opacity: opacity); + + static LinearGradient yellowBlue( + {begin = AlignmentDirectional.centerStart, + end = AlignmentDirectional.centerEnd, + opacity = 1.0}) => + _getLinearGradient(YELLOW, GREEN, + begin: begin, end: end, opacity: opacity); + + static LinearGradient blue( + {begin = AlignmentDirectional.centerStart, + end = AlignmentDirectional.centerEnd, + opacity = 1.0}) => + _getLinearGradient(BLUE_LIGHT, BLUE_DEEP, + begin: begin, end: end, opacity: opacity); + + static LinearGradient greenRed( + {begin = AlignmentDirectional.centerStart, + end = AlignmentDirectional.centerEnd, + opacity = 1.0}) => + _getLinearGradient(GREEN, RED, begin: begin, end: end, opacity: opacity); + + static LinearGradient greenPurple( + {begin = AlignmentDirectional.centerStart, + end = AlignmentDirectional.centerEnd, + opacity = 1.0}) => + _getLinearGradient(GREEN, PURPLE, + begin: begin, end: end, opacity: opacity); +} diff --git a/lib/utils/SizeUtil.dart b/lib/utils/SizeUtil.dart new file mode 100644 index 0000000..f55ec20 --- /dev/null +++ b/lib/utils/SizeUtil.dart @@ -0,0 +1,46 @@ +/// +/// Created by NieBin on 2018/12/26 +/// Github: https://github.com/nb312 +/// Email: niebin312@gmail.com +/// +import 'package:flutter/material.dart'; +import 'dart:math'; + +class SizeUtil { + static const _DESIGN_WIDTH = 750; + static const _DESIGN_HEIGHT = 1334; + + //logic size in device + static Size _logicSize; + + //device pixel radio. + + static get width { + return _logicSize.width; + } + + static get height { + return _logicSize.height; + } + + static set size(size) { + _logicSize = size; + } + + //@param w is the design w; + static double getAxisX(double w) { + return (w * width) / _DESIGN_WIDTH; + } + +// the y direction + static double getAxisY(double h) { + return (h * height) / _DESIGN_HEIGHT; + } + + // diagonal direction value with design size s. + static double getAxisBoth(double s) { + return s * + sqrt((width * width + height * height) / + (_DESIGN_WIDTH * _DESIGN_WIDTH + _DESIGN_HEIGHT * _DESIGN_HEIGHT)); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 31e9c96..6e07555 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,4 +37,9 @@ flutter: # the material Icons class. uses-material-design: true - + assets: + - images/logo.png + - images/github_icon.png + - images/silan_icon.png + - images/wechat_icon.png + - images/splash_logo.png diff --git a/sources/images/logo.png b/sources/images/logo.png new file mode 100644 index 0000000..12d0e6f Binary files /dev/null and b/sources/images/logo.png differ