Skip to content

Ysz #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app.apk
Binary file not shown.
26 changes: 16 additions & 10 deletions lib/components/exampleComp.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:efox_flutter/store/models/main_state_model.dart' show MainStateModel;
import 'package:efox_flutter/store/STORE.dart' show STORE;

class ExampleComp extends StatelessWidget {
final Widget child;
Expand All @@ -7,16 +9,20 @@ class ExampleComp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
height: 420.0,
margin: EdgeInsets.fromLTRB(50, 40, 50, 40),
decoration: BoxDecoration(
border: Border.all(
color: Colors.deepOrange,
width: 1.0
),
),
child: this.child,
return STORE.connect(
builder: (context, child, MainStateModel model) {
return Container(
height: 420.0,
margin: EdgeInsets.fromLTRB(50, 40, 50, 40),
decoration: BoxDecoration(
border: Border.all(
color: Color(model.theme.mainColor),
width: 1.0
),
),
child: this.child,
);
},
);
}
}
52 changes: 38 additions & 14 deletions lib/components/widgetLodingComp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class WidgetComp extends StatelessWidget {
}
});
// 增加
if (this.demoChild != null){
if (this.demoChild != null) {
this.demoChild.forEach((Widget item) {
_bodyList.add(ExampleComp(child: item));
});
}

return Scaffold(
appBar: AppBar(
title: Text(this.name),
Expand All @@ -53,14 +53,6 @@ class WidgetComp extends StatelessWidget {
icon: Icon(
Icons.favorite_border,
),
onPressed: () {
FluroRouter.router.navigateTo(context, '/webview?url=${Uri.encodeComponent(this.codeUrl)}');
},
),
IconButton(
icon: Icon(
Icons.code,
),
onPressed: () async {
String mdStr = await FileUtils.readLocaleFile(this.mdUrl);
Navigator.of(context).push(MaterialPageRoute(
Expand All @@ -75,6 +67,37 @@ class WidgetComp extends StatelessWidget {
));
},
),
IconButton(
icon: Icon(
Icons.code,
),
onPressed: () async {
FluroRouter.router.navigateTo(context,
'/webview?url=${Uri.encodeComponent(this.codeUrl)}');
},
),
PopupMenuButton(
onSelected: (index) {
print('index ${index.runtimeType}');
if (index == 0) {
FluroRouter.router.navigateTo(context,
'/webview?url=${Uri.encodeComponent('https://github.com/efoxTeam/flutter-ui')}');
}
},
itemBuilder: (context) {
return [
PopupMenuItem(
child: Row(children: [
Icon(
Icons.swap_horiz,
),
Text('官网'),
]),
value: 0,
),
];
},
),
],
),
body: this.renderWidget(context),
Expand Down Expand Up @@ -126,10 +149,11 @@ class WidgetComp extends StatelessWidget {
);
}
// 加载完成后返回页面
return ListView(
padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
shrinkWrap: true,
children: this._bodyList,
return Scrollbar(
child: ListView(
padding: EdgeInsets.all(10.0),
children: this._bodyList,
),
);
}
}
7 changes: 6 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ class MainAppState extends State<MainApp> {
],
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.deepOrange,
primarySwatch: Colors.indigo,
textTheme: TextTheme(
display1: TextStyle(
color: Colors.red,
),
)
),
onGenerateRoute: FluroRouter.router.generator,
),
Expand Down
17 changes: 8 additions & 9 deletions lib/page/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import 'package:efox_flutter/lang/app_translations.dart';
//
import 'package:efox_flutter/store/STORE.dart';

//
import 'tabbar/index.dart';
import 'tabbar/index.dart' as TabIndex;

class HomePage extends StatefulWidget {
@override
Expand All @@ -19,25 +18,25 @@ class _HomePageState extends State<HomePage>
super.initState();
}

Widget menu() {
Widget menu(MainStateModel model) {
return Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: Colors.deepOrange,
color: Color(model.theme.mainColor),
),
),
),
child: TabBar(
indicator: BoxDecoration(
border: Border(
top: BorderSide(
color: Colors.deepOrange,
color: Color(model.theme.mainColor),
),
),
),
labelColor: Colors.deepOrange,
unselectedLabelColor: Colors.orangeAccent,
labelColor: Color(model.theme.mainColor),
unselectedLabelColor: Color(model.theme.secondColor),
indicatorSize: TabBarIndicatorSize.tab,
indicatorColor: Colors.transparent,
tabs: [
Expand Down Expand Up @@ -103,10 +102,10 @@ class _HomePageState extends State<HomePage>
),
],
),
bottomNavigationBar: menu(),
bottomNavigationBar: menu(model),
body: TabBarView(
children: <Widget>[
ComponentsPage(),
TabIndex.ComponentsPage(),
Center(
child: new GridView.count(
// Create a grid with 2 columns. If you change the scrollDirection to
Expand Down
43 changes: 22 additions & 21 deletions lib/page/tabbar/index.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:efox_flutter/lang/app_translations.dart';
// import 'package:efox_flutter/lang/app_translations.dart';
import 'package:efox_flutter/router/index.dart';
import 'package:efox_flutter/store/models/main_state_model.dart';
import 'package:efox_flutter/store/STORE.dart' show STORE;
import 'package:efox_flutter/widget/index.dart' as WidgetRoot;

class ComponentsPage extends StatefulWidget {
Expand All @@ -14,13 +16,13 @@ class _ComponentsPageState extends State<ComponentsPage>
@override
initState() {
super.initState();
this.mapList = WidgetRoot.getAllWidgets();
this.mapList = WidgetRoot.getAllWidgets();
}

/**
* 渲染折叠板
*/
Widget renderExpanel(item) {
Widget renderExpanel(MainStateModel model, item) {
List _tmpWidgetList = item.widgetList;
return ExpansionTile(
title: Text(
Expand All @@ -29,9 +31,9 @@ class _ComponentsPageState extends State<ComponentsPage>
leading: Icon(
IconData(item.code ?? 58353,
fontFamily: 'MaterialIcons', matchTextDirection: true),
color: Colors.deepOrange,
color: Color(model.theme.secondColor),
),
backgroundColor: Colors.white12,
backgroundColor: Colors.white70,
children: [
GridView.count(
shrinkWrap: true,
Expand All @@ -44,11 +46,10 @@ class _ComponentsPageState extends State<ComponentsPage>
return Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: .1,
color: Colors.orange.shade300,
)
),
bottom: BorderSide(
width: .1,
color: Color(model.theme.mainColor),
)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -59,10 +60,11 @@ class _ComponentsPageState extends State<ComponentsPage>
IconData(_tmpWidgetList[index].code ?? 59101,
fontFamily: 'MaterialIcons',
matchTextDirection: true),
color: Colors.deepOrange,
color: Color(model.theme.mainColor),
),
onPressed: () {
FluroRouter.router.navigateTo(context, _tmpWidgetList[index].routerName);
FluroRouter.router.navigateTo(
context, _tmpWidgetList[index].routerName);
},
),
Text(_tmpWidgetList[index].name),
Expand All @@ -78,21 +80,20 @@ class _ComponentsPageState extends State<ComponentsPage>
}

Widget build(BuildContext context) {
AppTranslations lang = AppTranslations.of(context);
print('lang${lang}');
return Scrollbar(
child: SingleChildScrollView(
child: Container(
padding: EdgeInsets.all(10.0),
return STORE.connect(
builder: (context, child, model) {
return SingleChildScrollView(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(10),
child: Column(
children: mapList.map(
(item) {
return renderExpanel(item);
return renderExpanel(model, item);
},
).toList(),
),
),
),
);
},
);
}
}
3 changes: 2 additions & 1 deletion lib/store/models/main_state_model.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:scoped_model/scoped_model.dart';
import 'user_model.dart';
import 'theme_model.dart';

///主数据模型,需要全局使用的数据在这里添加模型
class MainStateModel extends Model with UserModel {
class MainStateModel extends Model with UserModel, AppThemeModel {
MainStateModel() {
// 初始化实例数据
}
Expand Down
11 changes: 11 additions & 0 deletions lib/store/models/theme_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:scoped_model/scoped_model.dart';

class AppTheme {
int mainColor = 0xFF1A237E;
int secondColor = 0xFF283593;
}

mixin AppThemeModel on Model {
AppTheme _appTheme = new AppTheme();
get theme => _appTheme;
}
2 changes: 1 addition & 1 deletion lib/store/models/user_model.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:scoped_model/scoped_model.dart';
import '../objects/user_info.dart';

class UserModel extends Model {
mixin UserModel on Model {
UserInfo _userInfo = UserInfo();
get userInfo => _userInfo;

Expand Down
2 changes: 1 addition & 1 deletion lib/widget/scrollview/gridview/demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Example extends StatelessWidget {
return Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.redAccent,
color: Colors.lightBlue,
),
),
child: Center(
Expand Down