first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
a938f8db-eb18-4365-91a8-bbfb2eb4e931

View File

@@ -0,0 +1 @@
eb7647ee-2985-484a-aa90-5084e20f47ac

View 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];
}
}
}

View 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;
}
}

View 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(
);
}
}

View 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.....'),
),
),
);
}
}

View 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(
'全面并且全力开发并支持AndroidiOSWeb桌面客户端为您提供随时随地的观影体验',
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
);
}
}

View File

@@ -0,0 +1,6 @@
# 视图层
---
- 1: main.dart 程序的主入口
- 2: R.dart 由 asset_gemerator.dart 读取 pubspec.yaml 的 # assets begin 动态生成,解决程序中的静态资源访问。需要在 idea 或者 android studio 的setting --> Tool --> External Tool 中新建任务

View File

@@ -0,0 +1 @@
6a9bf672-8ca9-43f0-a84b-66e4871ed6e8

View File

@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:flutter_app/R.dart';
class About extends StatelessWidget {
// final title;
// About({ this.title });
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0.0,
title: Text("我的"),
),
body: new Container(
color: Colors.orange,
height: 250.0,
alignment: Alignment.bottomCenter,
child: new Column(
verticalDirection: VerticalDirection.down,
children: <Widget>[
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Image.asset(
R.libStaticImgLogoPng,
width: 80.0,
height: 80.0,
fit: BoxFit.cover,
)
],
),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text("我的")
],
)
],
),
)
);
}
}

View File

@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
class Help extends StatefulWidget {
@override
_Help createState() => _Help();
}
class _Help extends State<Help> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: new Text(
"帮助"
),
),
body: new Center(
child: new RaisedButton(
child: new Text("点我"),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return SimpleDialog(
title: new Text("测试"),
children: <Widget>[
SimpleDialogOption(
child: new Image.asset(
"lib/static/img/logo.png",
width: 80.0,
height: 80.0,
fit: BoxFit.cover,
),
),
SimpleDialogOption(
child: const Text('你好2'),
),
],
);
},
);
},
),
),
);
}
}

View File

@@ -0,0 +1,203 @@
import 'package:flutter/material.dart';
import 'package:flutter_app/view/page/help.dart';
import 'package:flutter_app/config/index.dart';
import 'package:flutter_app/event/themeChangeEvent.dart';
import 'package:flutter_app/event/indexLayoutChangeEvent.dart';
import 'package:flutter_app/common/Application.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_app/R.dart';
import 'package:flutter_app/model/IndexModel.dart';
//import 'package:flutter_app/view/components/ListWidget.dart';
import 'package:flutter_app/service/service.dart';
import 'package:flutter_refresh/flutter_refresh.dart';
class Home extends StatefulWidget {
@override
_Home createState() => _Home();
}
//
class _Home extends State<Home> with AutomaticKeepAliveClientMixin<Home> {
@override
bool get wantKeepAlive => true;
List<Body> modules = [];
int page = 0;
@override
void initState() {
super.initState();
// getData();
}
@override
void dispose() {
super.dispose();
}
getData() async {
this.page += 1;
Index data = await ServiceMethods().getImageList({ "page": this.page });
setState(() {
modules = data.body;
});
print(this.modules);
}
Future<Null> onFooterRefresh() {
return new Future.delayed(new Duration(seconds: 2), () {
getData();
});
}
Future<Null> onHeaderRefresh() {
return new Future.delayed(new Duration(seconds: 2), () {
print("上拉");
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: appBars(),
body: Container(
child: InkWell(
onTap: () {
this.getData();
},
child: new Text(
'测试',
textAlign: TextAlign.center,
),
)
),
drawer: drawers()
);
}
// 主体内容区域
// ignore: non_constant_identifier_names
// Widget BodyLayout () {
// return new Refresh(
// onFooterRefresh: onFooterRefresh,
// onHeaderRefresh: onHeaderRefresh,
// childBuilder: (BuildContext context, { ScrollController controller, ScrollPhysics physics }) {
// return new ListWidget(modules,controller,physics);
// },
// );
// }
// 顶部appbar
Widget appBars() {
return AppBar(
leading: new IconButton(
icon: new Icon(Icons.help_outline),
tooltip: '关于',
onPressed: () {
Navigator.push(context,new MaterialPageRoute(
builder:(context) => new Help())
);
},
),
title: Text('精选美图'),
actions: <Widget>[
IconButton(
icon: Config.indexLayout == "default" ? Icon(Icons.subject) : Icon(Icons.border_all),
tooltip: '切换布局',
onPressed: () {
setState(() {
if (Config.indexLayout == "default") {
Config.indexLayout = "twoColumn";
}else {
Config.indexLayout = "default";
}
changeIndexLayout();
});
},
),
],
);
}
// 抽屉侧边栏
Widget drawers() {
return new Drawer(
child: new ListView(
padding: new EdgeInsets.all(0.0),
children: <Widget>[
new UserAccountsDrawerHeader(
accountName: new Text(
'编码猿',
style: new TextStyle( fontWeight: FontWeight.bold ),
), //用户名
accountEmail: new Text('2271608011@qq.com'), //用户邮箱
currentAccountPicture: new GestureDetector( //用户头像
onTap: () => print('current user'),
child: new CircleAvatar( //圆形图标控件
backgroundImage: new AssetImage(
R.libStaticImgLogoPng
),
),
),
decoration: new BoxDecoration( //用一个BoxDecoration装饰器提供背景图片
image: new DecorationImage(
fit: BoxFit.fill,
image: new ExactAssetImage(R.libStaticImgShopJpg),
),
),
),
new ListTile(
title: new Text('设置中心'),
leading: new Icon(Icons.settings),
),
new ListTile(
title: Text(Config.dark ? "日间模式" : "夜间模式"),
leading: new Icon(Icons.brightness_2),
onTap: () {
setState(() {
if (Config.dark == true) {
Config.dark = false;
} else {
Config.dark = true;
}
print(Config.dark);
changeTheme();
});
},
),
new ListTile( //第二个功能项
title: new Text('关于我'),
leading: new Icon(Icons.account_circle),
onTap: () {
Navigator.of(context).pushNamed('/about');
},
),
new Divider(), //分割线控件
new ListTile( //退出按钮
title: new Text('关闭'),
leading: new Icon(Icons.cancel),
onTap: () => Navigator.of(context).pop(), //点击后收起侧边栏
),
],
),
);
}
changeIndexLayout() async {
SharedPreferences sp = await SharedPreferences.getInstance();
sp.setString("indexLayout", Config.indexLayout);
Application.eventBus.fire(new indexLayoutChangeEvent(Config.indexLayout));
}
changeTheme() async {
SharedPreferences sp = await SharedPreferences.getInstance();
sp.setBool("themeIndex", Config.dark);
Application.eventBus.fire(new themeChangeEvent(Config.dark));
}
}

View File

@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
class Like extends StatefulWidget {
@override
_Like createState() => _Like();
}
class _Like extends State<Like> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:AppBar(
title: Text('喜欢'),
),
body:Center(
child: Text('喜欢'),
)
);
}
}

View File

@@ -0,0 +1,191 @@
import 'package:flutter/material.dart';
import 'package:extended_tabs/extended_tabs.dart';
class Login extends StatefulWidget {
@override
_Login createState() => _Login();
}
class _Login extends State<Login> with TickerProviderStateMixin{
TabController tabController;
//表单状态
GlobalKey<FormState> _formKey = GlobalKey<FormState>();
//用户名输入框控制器,此控制器可以监听用户名输入框操作
TextEditingController _userNameController = new TextEditingController();
//焦点
FocusNode _focusNodeUserName = new FocusNode();
FocusNode _focusNodePassWord = new FocusNode();
var _password = '';//用户名
var _username = '';//密码
var _isShowPwd = false;//是否显示密码
var _isShowClear = false;//是否显示输入框尾部的清除按钮
@override
void initState() {
tabController = TabController(length: 2, vsync: this);
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Flex(
direction: Axis.vertical,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: 250,
color: Colors.red[500],
),
Container(
color: Colors.red[500],
child: TabBar(
indicator: ColorTabIndicator(Colors.red[500]),
labelColor: Colors.white,
tabs: [
Tab(
child: Text(
'登录',
style: TextStyle(
fontSize: 18
)
),
),
Tab(
child: Text(
'注册',
style: TextStyle(
fontSize: 18
),
),
),
],
controller: tabController,
),
),
Expanded(
child: ExtendedTabBarView(
controller: tabController,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 20,right: 20),
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8)),
color: Colors.white
),
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new TextFormField(
controller: _userNameController,
focusNode: _focusNodeUserName,
//设置键盘类型
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: "手机号",
hintText: "请输入手机号",
prefixIcon: Icon(Icons.local_phone),
//尾部添加清除按钮
suffixIcon:(_isShowClear)
? IconButton(
icon: Icon(Icons.clear),
onPressed: (){
// 清空输入框内容
_userNameController.clear();
},
)
: null ,
),
//验证用户名
validator: validateUserName,
//保存数据
onSaved: (String value){
_username = value;
},
),
new TextFormField(
controller: _userNameController,
focusNode: _focusNodeUserName,
//设置键盘类型
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
labelText: "密码",
hintText: "请输入密码",
prefixIcon: Icon(Icons.lock),
//尾部添加清除按钮
suffixIcon:(_isShowClear)
? IconButton(
icon: Icon(Icons.clear),
onPressed: (){
// 清空输入框内容
_userNameController.clear();
},
)
: null ,
),
//验证用户名
validator: validateUserName,
//保存数据
onSaved: (String value){
_username = value;
},
),
],
),
),
),
Container()
],
)
)
],
),
// body: Stack(
// children: <Widget>[
// Container(
// width: MediaQuery.of(context).size.width,
// height: 250,
// color: Colors.red[500],
// ),
// Positioned(
//
// child: Text('测试'),
// )
// ],
// ),
// body: Container(
// width: MediaQuery.of(context).size.width,
// height: 250,
// color: Colors.red[500],
// child: Row(
// children: <Widget>[
//
// ],
// ),
// ),
);
}
/**
* 验证用户名
*/
String validateUserName(value){
// 正则匹配手机号
RegExp exp = RegExp(r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$');
if (value.isEmpty) {
return '用户名不能为空!';
}else if (!exp.hasMatch(value)) {
return '请输入正确手机号';
}
return null;
}
}

View File

@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_app/R.dart';
class Style extends StatefulWidget {
@override
_Style createState() => _Style();
}
class _Style extends State<Style> with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar:AppBar(
title: Text('分类'),
elevation: 0.0,
),
body: new Container(
child: new Row(
children: <Widget>[
new Row(
children: <Widget>[
new Container(
width: MediaQuery.of(context).size.width,
height: 120.0,
decoration: BoxDecoration(
color: Colors.grey,
image: DecorationImage(
image: AssetImage(R.libStaticImgClassallPng),
fit: BoxFit.cover,
),
),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
"全 部",
style: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.bold,
color: Colors.white70
),
)
],
),
),
],
),
new Row(
children: <Widget>[
new Text("dddd")
],
)
],
),
)
);
}
@override
bool get wantKeepAlive => true;
}