first commit
This commit is contained in:
1
滴滴淘/ddt_flutter/lib/view/components/.pydio
Normal file
1
滴滴淘/ddt_flutter/lib/view/components/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
eb7647ee-2985-484a-aa90-5084e20f47ac
|
||||
72
滴滴淘/ddt_flutter/lib/view/components/BottomNavigationWidget.dart
Executable file
72
滴滴淘/ddt_flutter/lib/view/components/BottomNavigationWidget.dart
Executable file
@@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_app/config/index.dart';
|
||||
import 'package:fancy_bottom_navigation/fancy_bottom_navigation.dart';
|
||||
|
||||
import 'package:flutter_app/view/page/home.dart';
|
||||
import 'package:flutter_app/view/page/style.dart';
|
||||
import 'package:flutter_app/view/page/like.dart';
|
||||
import 'package:flutter_app/view/page/about.dart';
|
||||
import 'package:flutter_app/view/page/login.dart';
|
||||
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
|
||||
class BottomNavigationWidget extends StatefulWidget {
|
||||
_BottomNavigationWidgetState createState() => _BottomNavigationWidgetState();
|
||||
}
|
||||
|
||||
|
||||
class _BottomNavigationWidgetState extends State<BottomNavigationWidget> {
|
||||
|
||||
int _currentIndex = 0;
|
||||
var _currentPage;
|
||||
|
||||
final List<Widget> tabBodies = [
|
||||
Login(),
|
||||
Home(),
|
||||
Style(),
|
||||
Like(),
|
||||
About(),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_currentPage = tabBodies[_currentIndex];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 适配屏幕尺寸
|
||||
ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
|
||||
return Scaffold(
|
||||
body: new IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: tabBodies,
|
||||
),
|
||||
bottomNavigationBar: FancyBottomNavigation(
|
||||
tabs: [
|
||||
TabData(iconData: Icons.home, title: "首页"),
|
||||
TabData(iconData: Icons.view_module, title: "分类"),
|
||||
TabData(iconData: Icons.favorite, title: "喜欢"),
|
||||
TabData(iconData: Icons.pperson, title: "我的")
|
||||
],
|
||||
onTabChangedListener: (position) {
|
||||
setState(() {
|
||||
_currentIndex = position;
|
||||
_currentPage = tabBodies[_currentIndex];
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Icon getTabIcon(int index) {
|
||||
if (index == _currentIndex) {
|
||||
return Config.tabSelectedImages[index];
|
||||
} else {
|
||||
return Config.tabImages[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
133
滴滴淘/ddt_flutter/lib/view/components/ListWidget.dart
Executable file
133
滴滴淘/ddt_flutter/lib/view/components/ListWidget.dart
Executable file
@@ -0,0 +1,133 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app/model/ImageModel.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter_app/config/index.dart';
|
||||
import 'package:flutter_app/common/Application.dart';
|
||||
import 'package:flutter_app/event/indexLayoutChangeEvent.dart';
|
||||
|
||||
class ListWidget extends StatefulWidget {
|
||||
List<Infos> _infos = new List();
|
||||
ScrollController controller;
|
||||
ScrollPhysics physics;
|
||||
ListWidget(this._infos,this.controller,this.x);
|
||||
|
||||
@override
|
||||
_ListWidget createState() => _ListWidget();
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class _ListWidget extends State<ListWidget> {
|
||||
|
||||
String status;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
this.registerIndexEvent();
|
||||
getLayoutStyle().then((onValue) {
|
||||
setState(() {
|
||||
status = onValue;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: missing_return
|
||||
Widget build(BuildContext context) {
|
||||
if (widget._infos.length != 0) {
|
||||
if(status == "default") {
|
||||
return new ListView.builder(
|
||||
physics: widget.physics,
|
||||
controller: widget.controller,
|
||||
itemCount: widget._infos.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
new Image.network(
|
||||
widget._infos[index].imgurl,
|
||||
fit: BoxFit.cover,
|
||||
width: ScreenUtil.screenWidth,
|
||||
),
|
||||
new Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
widget._infos[index].title,
|
||||
style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold),
|
||||
),
|
||||
new Row(
|
||||
children: <Widget>[
|
||||
new Icon(Icons.visibility),
|
||||
new Text(widget._infos[index].view),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
return new GridView.custom(
|
||||
physics: widget.physics,
|
||||
controller: widget.controller,
|
||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 4.0,
|
||||
crossAxisSpacing: 4.0,
|
||||
),
|
||||
childrenDelegate: new SliverChildBuilderDelegate( (context, index) {
|
||||
return new Container(
|
||||
child: new Image.network(
|
||||
widget._infos[index].imgurl,
|
||||
fit: BoxFit.cover,
|
||||
width: ScreenUtil.screenWidth,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: widget._infos.length,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}else {
|
||||
return new SpinKitWave (
|
||||
color: Colors.orange,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void registerIndexEvent() {
|
||||
Application.eventBus
|
||||
.on<indexLayoutChangeEvent>()
|
||||
.listen((indexLayoutChangeEvent onData) => this.changeTheme(onData));
|
||||
}
|
||||
|
||||
// 更改页面布局
|
||||
void changeTheme(indexLayoutChangeEvent onData) {
|
||||
setState(() {
|
||||
status = onData.LayoutStyle;
|
||||
});
|
||||
}
|
||||
|
||||
Future<String> getLayoutStyle() async {
|
||||
SharedPreferences layoutSharedPreferences = await SharedPreferences.getInstance();
|
||||
String ls = layoutSharedPreferences.getString("indexLayout");
|
||||
if (ls == null) {
|
||||
ls = Config.indexLayout;
|
||||
}
|
||||
Config.indexLayout = ls;
|
||||
return ls;
|
||||
}
|
||||
|
||||
State<StatefulWidget> createState() {
|
||||
// TODO: implement createState
|
||||
return null;
|
||||
}
|
||||
}
|
||||
12
滴滴淘/ddt_flutter/lib/view/components/SwiperWidget.dart
Executable file
12
滴滴淘/ddt_flutter/lib/view/components/SwiperWidget.dart
Executable file
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SwiperWidget extends StatelessWidget {
|
||||
final List<String> swiperList;
|
||||
|
||||
SwiperWidget(this.swiperList);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
);
|
||||
}
|
||||
}
|
||||
25
滴滴淘/ddt_flutter/lib/view/components/WebViewWidget.dart
Executable file
25
滴滴淘/ddt_flutter/lib/view/components/WebViewWidget.dart
Executable file
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
|
||||
|
||||
/// 公共 webview 组件
|
||||
class WebViewWidget extends StatelessWidget {
|
||||
final String webViewUrl;
|
||||
final String webViewtitle;
|
||||
WebViewWidget(this.webViewUrl,this.webViewtitle);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new WebviewScaffold(
|
||||
url: webViewUrl,
|
||||
appBar: new AppBar( title: new Text(webViewtitle)),
|
||||
withZoom: true,
|
||||
withLocalStorage: true,
|
||||
hidden: true,
|
||||
initialChild: Container(
|
||||
color: Colors.redAccent,
|
||||
child: const Center(
|
||||
child: Text('Waiting.....'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
144
滴滴淘/ddt_flutter/lib/view/components/WelcomeWidget.dart
Executable file
144
滴滴淘/ddt_flutter/lib/view/components/WelcomeWidget.dart
Executable file
@@ -0,0 +1,144 @@
|
||||
import 'package:flutter/material.dart';
|
||||
// 底部导航入口,赋值绘制整个app
|
||||
import 'package:flutter_app/view/components/BottomNavigationWidget.dart';
|
||||
|
||||
|
||||
import 'package:intro_views_flutter/Models/page_view_model.dart';
|
||||
import 'package:intro_views_flutter/intro_views_flutter.dart';
|
||||
import 'package:flutter_app/R.dart';
|
||||
|
||||
|
||||
class WelcomeWidget extends StatefulWidget {
|
||||
// 这里接受一个 bool ,用于下面的判断,主要为了实现在设置页面也可以浏览查看app的启动欢迎页面
|
||||
// 而不进行跳转
|
||||
final bool enterAction;
|
||||
|
||||
WelcomeWidget(this.enterAction);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _WelcomeWidget();
|
||||
}
|
||||
|
||||
class _WelcomeWidget extends State<WelcomeWidget> {
|
||||
|
||||
// 启动页面的基本配置,一般从后端获取,这里直接写死
|
||||
final pages = [
|
||||
PageViewModel(
|
||||
pageColor: Colors.orange,
|
||||
body: Text(
|
||||
'国内高清模特写真,为您带来视觉享受',
|
||||
style: TextStyle(
|
||||
fontSize: 17.0
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
'夜色社区-美图精选',
|
||||
style: TextStyle(
|
||||
fontSize: 30.0
|
||||
),
|
||||
),
|
||||
textStyle: TextStyle(color: Colors.white),
|
||||
mainImage: Image.asset(
|
||||
R.libStaticImgLogoPng,
|
||||
height: 285.0,
|
||||
width: 285.0,
|
||||
alignment: Alignment.center,
|
||||
)
|
||||
),
|
||||
PageViewModel(
|
||||
pageColor: const Color(0xFF03A9F4),
|
||||
body: Text(
|
||||
'基于谷歌开源UI框架Flutter + Dart语言开发的原生App,为您带来更快更流畅的体验',
|
||||
style: TextStyle(
|
||||
fontSize: 17.0
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
'更快',
|
||||
style: TextStyle(
|
||||
fontSize: 30.0
|
||||
),
|
||||
),
|
||||
textStyle: TextStyle(color: Colors.white),
|
||||
mainImage: Image.asset(
|
||||
R.libStaticImgAirplanePng,
|
||||
height: 285.0,
|
||||
width: 285.0,
|
||||
alignment: Alignment.center,
|
||||
)
|
||||
),
|
||||
PageViewModel(
|
||||
pageColor: const Color(0xFF8BC34A),
|
||||
body: Text(
|
||||
'基于RSA非对称加密与HTTPS全面保障您的数据安全',
|
||||
style: TextStyle(
|
||||
fontSize: 17.0
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
'安全',
|
||||
style: TextStyle(
|
||||
fontSize: 30.0
|
||||
),
|
||||
),
|
||||
mainImage: Image.asset(
|
||||
R.libStaticImgHotelPng,
|
||||
height: 285.0,
|
||||
width: 285.0,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
textStyle: TextStyle(color: Colors.white),
|
||||
),
|
||||
PageViewModel(
|
||||
pageColor: const Color(0xFF607D8B),
|
||||
body: Text(
|
||||
'全面并且全力开发并支持Android,iOS,Web,桌面客户端,为您提供随时随地的观影体验',
|
||||
style: TextStyle(
|
||||
fontSize: 17.0
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
'方便',
|
||||
style: TextStyle(
|
||||
fontSize: 30.0
|
||||
),
|
||||
),
|
||||
mainImage: Image.asset(
|
||||
R.libStaticImgTaxiPng,
|
||||
height: 285.0,
|
||||
width: 285.0,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
textStyle: TextStyle(color: Colors.white),
|
||||
),
|
||||
];
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Builder(
|
||||
builder: (context) =>
|
||||
IntroViewsFlutter(
|
||||
pages,
|
||||
onTapDoneButton: () {
|
||||
if(widget.enterAction) {
|
||||
// 使用 pushAndRemoveUntil 进入app后销毁之前的启动页面,否则侧滑还能打开
|
||||
Navigator.pushAndRemoveUntil(context,
|
||||
new MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return new BottomNavigationWidget();
|
||||
},
|
||||
), (route) => route == null
|
||||
);
|
||||
}
|
||||
},
|
||||
skipText: Text("跳过"),
|
||||
doneText: Text("进入"),
|
||||
pageButtonTextStyles: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
), //IntroViewsFlutter
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user