mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-15 03:04:25 +08:00
@ -60,7 +60,7 @@ class PagerIndicator extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
new Expanded(child: new Container()),
|
||||
new Transform(
|
||||
transform: new Matrix4.translationValues(translation, 0.0, 0.0),
|
||||
transform: new Matrix4.translationValues(0, 0.0, 0.0),
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: bubbles,
|
||||
|
@ -35,12 +35,16 @@ class Page extends StatelessWidget {
|
||||
this.viewModel,
|
||||
this.percentVisible = 1.0,
|
||||
});
|
||||
_goHomePage(context) {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
'/home', (Route<dynamic> route) => false);
|
||||
}
|
||||
|
||||
Widget creatButton(BuildContext context,String txt,IconData iconName,String type){
|
||||
return RaisedButton.icon(
|
||||
onPressed: () {
|
||||
if(type == 'start'){
|
||||
//Navigator.popUntil(context, ModalRoute.withName('/'));
|
||||
_goHomePage(context);
|
||||
}else if(type == 'goGithub'){
|
||||
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(txt)} Doc&&url=${Uri.encodeComponent("https://github.com/alibaba/flutter-go")}');
|
||||
}
|
||||
@ -60,13 +64,13 @@ class Page extends StatelessWidget {
|
||||
return new Container(
|
||||
width: double.infinity,
|
||||
color: viewModel.color,
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
||||
child: new Opacity(
|
||||
opacity: percentVisible,
|
||||
child: new Column(
|
||||
crossAxisAlignment:CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
new Transform(
|
||||
transform: new Matrix4.translationValues(0.0, 50.0 * (1.0 - percentVisible) ,0.0),
|
||||
child: new Padding(
|
||||
|
155
lib/main.dart
155
lib/main.dart
@ -1,17 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'views/first_page.dart';
|
||||
import 'views/widget_page.dart';
|
||||
import 'views/fourth_page.dart';
|
||||
import 'views/collection_page.dart';
|
||||
import 'routers/routers.dart';
|
||||
import 'routers/application.dart';
|
||||
import 'common/provider.dart';
|
||||
import 'model/widget.dart';
|
||||
import './widgets/index.dart';
|
||||
import 'package:flutter_go/components/search_input.dart';
|
||||
|
||||
import 'views/welcome_page/index.dart';
|
||||
|
||||
const int ThemeColor = 0xFFC91B3A;
|
||||
|
||||
@ -39,7 +33,9 @@ class MyApp extends StatelessWidget {
|
||||
size: 35.0,
|
||||
),
|
||||
),
|
||||
home: new MyHomePage(),
|
||||
home: new Scaffold(
|
||||
body: new WelcomePage(),
|
||||
),
|
||||
onGenerateRoute: Application.router.generator,
|
||||
);
|
||||
}
|
||||
@ -53,144 +49,3 @@ void main() async {
|
||||
db = Provider.db;
|
||||
runApp(new MyApp());
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _MyHomePageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
WidgetControlModel widgetControl = new WidgetControlModel();
|
||||
TabController controller;
|
||||
bool isSearch = false;
|
||||
String data = '无';
|
||||
String data2ThirdPage = '这是传给ThirdPage的值';
|
||||
String appBarTitle = tabData[0]['text'];
|
||||
static List tabData = [
|
||||
{'text': '业界动态', 'icon': new Icon(Icons.language)},
|
||||
{'text': 'WIDGET', 'icon': new Icon(Icons.extension)},
|
||||
{'text': '组件收藏', 'icon': new Icon(Icons.star)},
|
||||
{'text': '关于手册', 'icon': new Icon(Icons.favorite)}
|
||||
];
|
||||
|
||||
List<Widget> myTabs = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = new TabController(
|
||||
initialIndex: 0, vsync: this, length: 4); // 这里的length 决定有多少个底导 submenus
|
||||
for (int i = 0; i < tabData.length; i++) {
|
||||
myTabs.add(new Tab(text: tabData[i]['text'], icon: tabData[i]['icon']));
|
||||
}
|
||||
controller.addListener(() {
|
||||
if (controller.indexIsChanging) {
|
||||
_onTabChange();
|
||||
}
|
||||
});
|
||||
Application.controller = controller;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) {
|
||||
List widgetDemosList = new WidgetDemoList().getDemos();
|
||||
String targetName = widgetPoint.name;
|
||||
String targetRouter = '/category/error/404';
|
||||
widgetDemosList.forEach((item) {
|
||||
if (item.name == targetName) {
|
||||
targetRouter = item.routerName;
|
||||
}
|
||||
});
|
||||
Application.router.navigateTo(context, "$targetRouter");
|
||||
}
|
||||
|
||||
Widget buildSearchInput(BuildContext context) {
|
||||
return new SearchInput((value) async {
|
||||
if (value != '') {
|
||||
List<WidgetPoint> list = await widgetControl.search(value);
|
||||
|
||||
return list
|
||||
.map((item) => new MaterialSearchResult<String>(
|
||||
value: item.name,
|
||||
text: item.name,
|
||||
onTap: () {
|
||||
onWidgetTap(item, context);
|
||||
},
|
||||
))
|
||||
.toList();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}, (value) {}, () {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: buildSearchInput(context)),
|
||||
body: new TabBarView(controller: controller, children: <Widget>[
|
||||
new FirstPage(),
|
||||
new WidgetPage(db),
|
||||
new CollectionPage(),
|
||||
new FourthPage()
|
||||
]),
|
||||
bottomNavigationBar: Material(
|
||||
color: const Color(0xFFF0EEEF), //底部导航栏主题颜色
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: 65.0,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF0F0F0),
|
||||
boxShadow: <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: const Color(0xFFd0d0d0),
|
||||
blurRadius: 3.0,
|
||||
spreadRadius: 2.0,
|
||||
offset: Offset(-1.0, -1.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TabBar(
|
||||
controller: controller,
|
||||
indicatorColor: Theme.of(context).primaryColor, //tab标签的下划线颜色
|
||||
// labelColor: const Color(0xFF000000),
|
||||
indicatorWeight: 3.0,
|
||||
labelColor: Theme.of(context).primaryColor,
|
||||
unselectedLabelColor: const Color(0xFF8E8E8E),
|
||||
tabs: <Tab>[
|
||||
Tab(text: '业界动态', icon: Icon(Icons.language)),
|
||||
Tab(text: '组件', icon: Icon(Icons.extension)),
|
||||
Tab(text: '组件收藏', icon: Icon(Icons.favorite)),
|
||||
Tab(text: '关于手册', icon: Icon(Icons.line_weight)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onTabChange() {
|
||||
if (this.mounted) {
|
||||
this.setState(() {
|
||||
appBarTitle = tabData[controller.index]['text'];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// void _onDataChange(val) {
|
||||
// if (this.mounted) {
|
||||
// setState(() {
|
||||
// data = val;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -4,6 +4,14 @@ import '../views/category.dart';
|
||||
import '../widgets/404.dart';
|
||||
import '../common/full_screen_code_dialog.dart';
|
||||
import '../views/web_view_page.dart';
|
||||
import '../views/home.dart';
|
||||
|
||||
// app的首页
|
||||
var homeHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return new AppPage();
|
||||
},
|
||||
);
|
||||
|
||||
var categoryHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
|
@ -6,6 +6,7 @@ import './router_handler.dart';
|
||||
|
||||
class Routes {
|
||||
static String root = "/";
|
||||
static String home = "/home";
|
||||
static String widgetDemo = '/widget-demo';
|
||||
static String codeView = '/code-view';
|
||||
static String webViewPage = '/web-view-page';
|
||||
@ -15,16 +16,16 @@ class Routes {
|
||||
router.notFoundHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
});
|
||||
|
||||
router.define(home, handler: homeHandler);
|
||||
|
||||
router.define('/category/:type', handler: categoryHandler);
|
||||
router.define('/category/error/404', handler: widgetNotFoundHandler);
|
||||
router.define(codeView,handler:fullScreenCodeDialog);
|
||||
router.define(webViewPage,handler:webViewPageHand);
|
||||
widgetDemosList.forEach((demo) {
|
||||
Handler handler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return demo.buildRouter(context);
|
||||
widgetDemosList.forEach((demo) {
|
||||
Handler handler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return demo.buildRouter(context);
|
||||
});
|
||||
router.define('${demo.routerName}', handler: handler);
|
||||
});
|
||||
|
164
lib/views/home.dart
Normal file
164
lib/views/home.dart
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
* Created with Android Studio.
|
||||
* User: 三帆
|
||||
* Date: 16/01/2019
|
||||
* Time: 11:16
|
||||
* email: sanfan.hx@alibaba-inc.com
|
||||
* tartget: app首页
|
||||
*/
|
||||
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'first_page.dart';
|
||||
import 'widget_page.dart';
|
||||
//import 'package:flutter_go/views/welcome_page/fourth_page.dart';
|
||||
import 'collection_page.dart';
|
||||
import '../routers/application.dart';
|
||||
import '../common/provider.dart';
|
||||
import '../model/widget.dart';
|
||||
import '../widgets/index.dart';
|
||||
import 'package:flutter_go/components/search_input.dart';
|
||||
|
||||
const int ThemeColor = 0xFFC91B3A;
|
||||
|
||||
class AppPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _MyHomePageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<AppPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
WidgetControlModel widgetControl = new WidgetControlModel();
|
||||
TabController controller;
|
||||
bool isSearch = false;
|
||||
String data = '无';
|
||||
String data2ThirdPage = '这是传给ThirdPage的值';
|
||||
String appBarTitle = tabData[0]['text'];
|
||||
static List tabData = [
|
||||
{'text': '业界动态', 'icon': new Icon(Icons.language)},
|
||||
{'text': 'WIDGET', 'icon': new Icon(Icons.extension)},
|
||||
{'text': '组件收藏', 'icon': new Icon(Icons.star)},
|
||||
{'text': '关于手册', 'icon': new Icon(Icons.favorite)}
|
||||
];
|
||||
|
||||
List<Widget> myTabs = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = new TabController(
|
||||
initialIndex: 0, vsync: this, length: 4); // 这里的length 决定有多少个底导 submenus
|
||||
for (int i = 0; i < tabData.length; i++) {
|
||||
myTabs.add(new Tab(text: tabData[i]['text'], icon: tabData[i]['icon']));
|
||||
}
|
||||
controller.addListener(() {
|
||||
if (controller.indexIsChanging) {
|
||||
_onTabChange();
|
||||
}
|
||||
});
|
||||
Application.controller = controller;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) {
|
||||
List widgetDemosList = new WidgetDemoList().getDemos();
|
||||
String targetName = widgetPoint.name;
|
||||
String targetRouter = '/category/error/404';
|
||||
widgetDemosList.forEach((item) {
|
||||
if (item.name == targetName) {
|
||||
targetRouter = item.routerName;
|
||||
}
|
||||
});
|
||||
Application.router.navigateTo(context, "$targetRouter");
|
||||
}
|
||||
|
||||
Widget buildSearchInput(BuildContext context) {
|
||||
return new SearchInput((value) async {
|
||||
if (value != '') {
|
||||
List<WidgetPoint> list = await widgetControl.search(value);
|
||||
|
||||
return list
|
||||
.map((item) => new MaterialSearchResult<String>(
|
||||
value: item.name,
|
||||
text: item.name,
|
||||
onTap: () {
|
||||
onWidgetTap(item, context);
|
||||
},
|
||||
))
|
||||
.toList();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}, (value) {}, () {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var db = Provider.db;
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: buildSearchInput(context)),
|
||||
body: new TabBarView(controller: controller, children: <Widget>[
|
||||
new FirstPage(),
|
||||
new WidgetPage(db),
|
||||
new CollectionPage(),
|
||||
Container(
|
||||
child: Center(
|
||||
child: Text("开发中"),
|
||||
),
|
||||
)
|
||||
]),
|
||||
bottomNavigationBar: Material(
|
||||
color: const Color(0xFFF0EEEF), //底部导航栏主题颜色
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: 65.0,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF0F0F0),
|
||||
boxShadow: <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: const Color(0xFFd0d0d0),
|
||||
blurRadius: 3.0,
|
||||
spreadRadius: 2.0,
|
||||
offset: Offset(-1.0, -1.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TabBar(
|
||||
controller: controller,
|
||||
indicatorColor: Theme.of(context).primaryColor, //tab标签的下划线颜色
|
||||
// labelColor: const Color(0xFF000000),
|
||||
indicatorWeight: 3.0,
|
||||
labelColor: Theme.of(context).primaryColor,
|
||||
unselectedLabelColor: const Color(0xFF8E8E8E),
|
||||
tabs: <Tab>[
|
||||
Tab(text: '业界动态', icon: Icon(Icons.language)),
|
||||
Tab(text: '组件', icon: Icon(Icons.extension)),
|
||||
Tab(text: '组件收藏', icon: Icon(Icons.favorite)),
|
||||
Tab(text: '关于手册', icon: Icon(Icons.line_weight)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onTabChange() {
|
||||
if (this.mounted) {
|
||||
this.setState(() {
|
||||
appBarTitle = tabData[controller.index]['text'];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,6 @@ import 'package:flutter_go/components/fourth_page_feature/page_reveal.dart';
|
||||
import 'package:flutter_go/components/fourth_page_feature/pager_indicator.dart';
|
||||
import 'package:flutter_go/components/fourth_page_feature/pages.dart';
|
||||
|
||||
import '../components/comp_list.dart';
|
||||
|
||||
class FourthPage extends StatefulWidget {
|
||||
@override
|
||||
FourthPageState createState() => new FourthPageState();
|
31
lib/views/welcome_page/index.dart
Normal file
31
lib/views/welcome_page/index.dart
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Created with Android Studio.
|
||||
* User: 三帆
|
||||
* Date: 14/01/2019
|
||||
* Time: 23:00
|
||||
* email: sanfan.hx@alibaba-inc.com
|
||||
* tartget: xxx
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_go/views/welcome_page/fourth_page.dart';
|
||||
class WelcomePage extends StatefulWidget {
|
||||
WelcomePage({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_WelcomePageState createState() {
|
||||
return new _WelcomePageState();
|
||||
}
|
||||
}
|
||||
|
||||
class _WelcomePageState extends State<WelcomePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
color: Colors.white,
|
||||
child: FourthPage()
|
||||
);
|
||||
}
|
||||
}
|
33
lib/widgets/elements/Form/Text/RichText/demo.dart
Normal file
33
lib/widgets/elements/Form/Text/RichText/demo.dart
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Created with Android Studio.
|
||||
* User: 三帆
|
||||
* Date: 14/01/2019
|
||||
* Time: 19:02
|
||||
* email: sanfan.hx@alibaba-inc.com
|
||||
* tartget: xxx
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RichTextDemo extends StatefulWidget {
|
||||
_Demo createState() => _Demo();
|
||||
}
|
||||
|
||||
class _Demo extends State<RichTextDemo> {
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Color(0xff000000),
|
||||
width: 750.0,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: 'Hello ',
|
||||
children: <TextSpan>[
|
||||
TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold, color: Color(0xfffffc42))),
|
||||
TextSpan(text: ' world!', style: TextStyle(fontStyle: FontStyle.italic)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import '../../../../../common/widget_demo.dart';
|
||||
|
||||
import 'demo.dart';
|
||||
const String intro = """
|
||||
# 富文本显示
|
||||
|
||||
@ -70,20 +70,7 @@ class _Demo extends State<Demo> {
|
||||
contentList: [new Column(
|
||||
children: <Widget>[
|
||||
MarkdownBody(data: markDesc['intro']),
|
||||
Container(
|
||||
color: Color(0xff000000),
|
||||
width: 750.0,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: 'Hello ',
|
||||
// style: TextStyle(fontWeight: FontWeight.normal, inherit: true, fontSize: 44),
|
||||
children: <TextSpan>[
|
||||
TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold, color: Color(0xfffffc42))),
|
||||
TextSpan(text: ' world!', style: TextStyle(fontStyle: FontStyle.italic)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
RichTextDemo(),
|
||||
MarkdownBody(data: markDesc['diff']),
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user