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 @@
e7dc70dc-c800-458f-a262-fe87e1bcc3a0

View File

@@ -0,0 +1,51 @@
class R {
/// 静态资源配置,程序自动生成,请勿手动修改
/// ![](http://127.0.0.1:2227/lib/static/img/ts.jpg)
static final String libStaticImgTsJpg = 'lib/static/img/ts.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/hotel.png)
static final String libStaticImgHotelPng = 'lib/static/img/hotel.png';
/// ![](http://127.0.0.1:2227/lib/static/img/taxi.png)
static final String libStaticImgTaxiPng = 'lib/static/img/taxi.png';
/// ![](http://127.0.0.1:2227/lib/static/img/mt.jpg)
static final String libStaticImgMtJpg = 'lib/static/img/mt.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/mb.jpg)
static final String libStaticImgMbJpg = 'lib/static/img/mb.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/wn.jpg)
static final String libStaticImgWnJpg = 'lib/static/img/wn.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/pgg.jpg)
static final String libStaticImgPggJpg = 'lib/static/img/pgg.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/yacj.png)
static final String libStaticImgYacjPng = 'lib/static/img/yacj.png';
/// ![](http://127.0.0.1:2227/lib/static/img/sw.jpg)
static final String libStaticImgSwJpg = 'lib/static/img/sw.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/myjr.png)
static final String libStaticImgMyjrPng = 'lib/static/img/myjr.png';
/// ![](http://127.0.0.1:2227/lib/static/img/swzf.png)
static final String libStaticImgSwzfPng = 'lib/static/img/swzf.png';
/// ![](http://127.0.0.1:2227/lib/static/img/shop.jpg)
static final String libStaticImgShopJpg = 'lib/static/img/shop.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/airplane.png)
static final String libStaticImgAirplanePng = 'lib/static/img/airplane.png';
/// ![](http://127.0.0.1:2227/lib/static/img/ry.jpg)
static final String libStaticImgRyJpg = 'lib/static/img/ry.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/hsl.jpg)
static final String libStaticImgHslJpg = 'lib/static/img/hsl.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/logo.png)
static final String libStaticImgLogoPng = 'lib/static/img/logo.png';
/// ![](http://127.0.0.1:2227/lib/static/img/wmzx.png)
static final String libStaticImgWmzxPng = 'lib/static/img/wmzx.png';
/// ![](http://127.0.0.1:2227/lib/static/img/snrq.png)
static final String libStaticImgSnrqPng = 'lib/static/img/snrq.png';
/// ![](http://127.0.0.1:2227/lib/static/img/yh.jpg)
static final String libStaticImgYhJpg = 'lib/static/img/yh.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/xka.jpg)
static final String libStaticImgXkaJpg = 'lib/static/img/xka.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/bus.png)
static final String libStaticImgBusPng = 'lib/static/img/bus.png';
/// ![](http://127.0.0.1:2227/lib/static/img/classall.png)
static final String libStaticImgClassallPng = 'lib/static/img/classall.png';
/// ![](http://127.0.0.1:2227/lib/static/img/yy.jpg)
static final String libStaticImgYyJpg = 'lib/static/img/yy.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/ll.jpg)
static final String libStaticImgLlJpg = 'lib/static/img/ll.jpg';
}

View File

@@ -0,0 +1 @@
0b03739f-aaf6-4d6d-8363-6fa78ae45389

View File

@@ -0,0 +1,5 @@
import 'package:event_bus/event_bus.dart';
class Application {
static EventBus eventBus;
}

View File

@@ -0,0 +1 @@
# 全局公共函数和事件

View File

@@ -0,0 +1 @@
9ed5090f-3c1a-46ba-b640-4cbc40d1dff0

View File

@@ -0,0 +1 @@
# App 全局的基本配置

View File

@@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:flutter_app/view/components/WebViewWidget.dart';
class Config {
// default 默认布局twoColumn 两栏布局
static String indexLayout = "default";
// 未激活时候底部tabbar 样式
static const List<Icon> tabImages = [
Icon(Icons.home, size: 25.0, color: Colors.grey,),
Icon(Icons.view_quilt, size: 25.0, color: Colors.grey,),
Icon(Icons.favorite_border, size: 25.0, color: Colors.grey,),
Icon(Icons.person_outline, size: 25.0, color: Colors.grey,),
];
// 激活时候底部tabbar 样式
static const List<Icon> tabSelectedImages = [
Icon(Icons.home, size: 25.0, color: Colors.orange,),
Icon(Icons.view_module, size: 25.0, color: Colors.orange,),
Icon(Icons.favorite, size: 25.0, color: Colors.orange,),
Icon(Icons.pperson, size: 25.0, color: Colors.orange,),
];
// 默认 白天模式
static bool dark = false;
// 默认返回 白天模式
static ThemeData themeData = getThemeData(dark);
static ThemeData themeDataDark = new ThemeData.dark();
// 返回白天还是黑夜模式
static getThemeData(bool dark){
if(dark){
return themeDataDark;
}else{
return themeDataLight;
}
}
// 默认白天模式的配置
static ThemeData themeDataLight = new ThemeData(
primarySwatch: Colors.orange,
primaryColor: Colors.orange,
accentColor: Colors.white,
primaryColorBrightness: Brightness.light,
);
// 启动页面配置
static const Map Welcome = {
"title": "夜色社区",
"img": "lib/static/img/logo.png",
"waitTime": 4,
"loadingText": "Waiting"
};
// 路由配置
static final Map<String, WidgetBuilder> routers = {
"/about": (_) => new WebViewWidget('https://github.com/helpcode', 'GitHub'),
};
static final publivKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9v"+
"e9enk6heGj/JbcvHVOwFYw2qCNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i"+
"943uSudTkqT+guv03jTzvLy2TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpF"+
"JnzyW/fOYQjboRz7nwIDAQAB";
}

View File

@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9ve9enk6heGj/JbcvHVOwFYw2q
CNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i943uSudTkqT+guv03jTzvLy2
TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpFJnzyW/fOYQjboRz7nwIDAQAB
AoGADgMCfDFSTSauBwoG3oG8mXSGxHJLf74b80vlEljJAAL2b+0s0cnip8EOfo0p
4tHHnPekw5eL1zGXYJHWQmeO/3ymZS/nnVq1K5YRM+AtYyUMAiChIt/zWOGXPN6k
yUARaTK/cRZNY2XPPDK0H44eLF2RDE/SObPD0BZ0u9m92aECQQDYSIrYw0klyGJe
ePaV0+2ZtVVhDYN+eYmWHu9/T+aOIPFS5ePUonBftSfcp7pTeJZ3O/eI/4W6pdzz
13MRseUZAkEA1ImPvtbL39A8OtciY16LgDX5O5Vkm5p5+TKRhG5B38bgnOQQHu2d
oJKvxjEJcWDfiJ6/ThHsFHqyvViJ+cIFdwJBAIWlpe62FdA8F9UK6EzDLXIq5DxZ
rmSL06IpMZM5G12+K4EvP26YhdoORjiKiI+l10yMiLRmOQuSDIu9GYTYqZkCQEQ5
/Ij4ju3D/PGuif14JjP8H4u/A1LoHeufDhODCWZ6gzQaCgrDoGwhaoemyi85N8i1
nRfErRJN6P7bYz9nxzUCQDC8yEIcgKczxFIo20k4R+CINyJTB5S6dsVW6gmpiHZK
6+MWkDut4o/Fibwp4jm5Fh9zau597aP5Xnt8mA2LRc8=
-----END RSA PRIVATE KEY-----

View File

@@ -0,0 +1,6 @@
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9v
e9enk6heGj/JbcvHVOwFYw2qCNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i
943uSudTkqT+guv03jTzvLy2TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpF
JnzyW/fOYQjboRz7nwIDAQAB
-----END PUBLIC KEY-----

View File

@@ -0,0 +1 @@
942611d3-0164-477c-9494-5287a340012f

View File

@@ -0,0 +1,91 @@
import 'dart:io';
// ignore: non_constant_identifier_names
var preview_server_port = 2227;
void main() async {
bool working = false;
var pubSpec = new File('pubspec.yaml');
var pubLines = pubSpec.readAsLinesSync();
var newLines = <String>[];
var resource = <String>[];
for (var line in pubLines) {
if (line.contains('begin') && line.contains('#') && line.contains('assets')) {
working = true;
newLines.add(line);
}
if (line.contains('end') && line.contains('#') && line.contains('assets')) working = false;
if (working) {
if (line.trim().startsWith('#') && line.trim().endsWith('*')) {
newLines.add(line);
var directory = new Directory(line.replaceAll('#', '').replaceAll('*', '').trim());
if (directory.existsSync()) {
var list = directory.listSync(recursive: true);
resource.add("/// 静态资源配置,程序自动生成,请勿手动修改");
for (var file in list) {
if (new File(file.path)
.statSync()
.type == FileSystemEntityType.file) {
var path = file.path.replaceAll('\\', '/');
var varName = path.replaceAll('/', '_').replaceAll('.', '_').toLowerCase();
var pos = 0;
String char;
while (true) {
pos = varName.indexOf('_', pos);
if (pos == -1) break;
char = varName.substring(pos + 1, pos + 2);
varName = varName.replaceFirst('_$char', '_${char.toUpperCase()}');
pos++;
}
varName = varName.replaceAll('_', '');
resource.add("/// ![](http://127.0.0.1:$preview_server_port/$path)");
resource.add("static final String $varName = '$path';");
newLines.add(' - $path');
}
}
} else {
throw new FileSystemException('Directory wrong');
}
}
} else {
newLines.add(line);
}
}
var r = new File('lib/R.dart');
if (r.existsSync()) {
r.deleteSync();
}
r.createSync();
var content = 'class R {\n';
for (var line in resource) {
content = '$content $line\n';
}
content = '$content}\n';
r.writeAsStringSync(content);
var spec = '';
for (var line in newLines) {
spec = '$spec$line\n';
}
pubSpec.writeAsStringSync(spec);
var ser;
try {
ser = await HttpServer.bind('127.0.0.1', preview_server_port);
print('成功启动图片预览服务器于本机<$preview_server_port>端口');
ser.listen(
(req) {
var index = req.uri.path.lastIndexOf('.');
var subType = req.uri.path.substring(index);
req.response
..headers.contentType = new ContentType('image', subType)
..add(new File('.${req.uri.path}').readAsBytesSync())
..close();
},
);
} catch (e) {
print('图片预览服务器已启动或端口被占用');
}
}

View File

@@ -0,0 +1 @@
# App 开发环境下的一些代码

View File

@@ -0,0 +1 @@
0cbcbc38-50fe-4a58-aa48-e8d658c4fe89

View File

@@ -0,0 +1 @@
# 全局事件 事件总线控制,进行页面主体间通讯

View File

@@ -0,0 +1,6 @@
// ignore: camel_case_types
class indexLayoutChangeEvent {
// ignore: non_constant_identifier_names
String LayoutStyle;
indexLayoutChangeEvent(this.LayoutStyle);
}

View File

@@ -0,0 +1,5 @@
// ignore: camel_case_types
class themeChangeEvent {
bool dark;
themeChangeEvent(this.dark);
}

View File

@@ -0,0 +1 @@
6237ef09-050e-435b-85f4-d9966c31c525

View File

@@ -0,0 +1,6 @@
// ignore: camel_case_types
class config {
static const String BASE_URL = "http://192.168.0.104:3000";
//static const String BASE_URL = "https://www.geekhelp.cn";
static const String testUrl = "/index";
}

View File

@@ -0,0 +1,5 @@
# 基于dio的HTTP请求封装
- 1: config.dart 网络请求的基本配置
- 2: dio的主体封装

View File

@@ -0,0 +1,89 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/http/config.dart';
import 'package:bot_toast/bot_toast.dart';
class Http {
Dio _dio;
Http() {
this._dio = new Dio(new BaseOptions(
baseUrl: config.BASE_URL,
connectTimeout: 3000,
receiveTimeout: 3000,
));
this._dio.interceptors.add(InterceptorsWrapper(
onRequest:(RequestOptions options){
/// 请求发送前拦截,对 queryParameters 参数进行RSA公钥加密放到token中发送给后端
/// 后端私钥解密,查询数据,然后通过私钥加密数据再返回给前端
///options.headers = options.queryParameters;
///print(options.headers);
return options;
},
onResponse:(Response response) {
/// 响应拦截器,将数据返回给前端之前先使用公钥解密后端的数据,然后将解密后明文给前端
// 在返回响应数据之前做一些预处理
return response;
},
onError: (DioError e) {
return e;
}
));
}
/***
* get 请求
* url 请求地址
* params 请求参数
*/
get (String url, Object params) async {
Response response;
try {
response = await this._dio.get(url, queryParameters: params);
return response.data;
} on DioError catch (e) {
if (CancelToken.isCancel(e)) {
BotToast.showSimpleNotification(
title: 'GET请求取消',
subTitle: e.message,
hideCloseButton: true
);
}
BotToast.showSimpleNotification(
title: 'GET请求错误',
subTitle: e.message,
hideCloseButton: true
);
print(e.message);
}
}
/***
* post 请求
* url 请求地址
* params 请求参数
*/
post (String url, Object params) async {
Response response;
try {
response = await this._dio.post(url, data: params);
return response.data;
} on DioError catch (e) {
if (CancelToken.isCancel(e)) {
BotToast.showSimpleNotification(
title: 'POST请求取消',
subTitle: e.message,
hideCloseButton: true
);
}
BotToast.showSimpleNotification(
title: 'POST请求错误',
subTitle: e.message,
hideCloseButton: true
);
}
}
}

View File

@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
// 事件总控
import 'package:event_bus/event_bus.dart';
// shared_preferences 离线数据存储
import 'package:shared_preferences/shared_preferences.dart';
// 主题切换事件
import 'package:flutter_app/event/themeChangeEvent.dart';
// 全局 event_bus 事件
import 'package:flutter_app/common/Application.dart';
// 启动欢迎组件
import 'package:flutter_app/view/components/WelcomeWidget.dart';
// 全局配置类
import 'package:flutter_app/config/index.dart';
import 'package:bot_toast/bot_toast.dart';
// 主入口
void main () async {
// 获取主题,传递给初 initApp 类
WidgetsFlutterBinding.ensureInitialized();
runApp(new initApp());
}
// ignore: camel_case_types
class initApp extends StatefulWidget {
@override
State<StatefulWidget> createState() => StartApp();
}
class StartApp extends State<initApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "Flutter App",
builder: BotToastInit(), //1. call BotToastInit
navigatorObservers: [BotToastNavigatorObserver()],
theme: Config.getThemeData(false),
home: WelcomeWidget(true),
routes: Config.routers,
);
}
@override
void dispose() {
super.dispose();
Application.eventBus.destroy();
}
}

View File

@@ -0,0 +1 @@
983f8dc4-232f-4709-9b17-c4279f8f0f14

View File

@@ -0,0 +1,40 @@
class StyleModel {
final int status;
final int length;
final String copyright;
final List<Infos> data;
StyleModel({ this.status, this.length, this.copyright, this.data });
factory StyleModel.fromJson(Map<String, dynamic> parsedJson){
var list = parsedJson['data'] as List;
List<Infos> imageinfo = list.map((i) => Infos.fromJson(i)).toList();
return StyleModel(
status: parsedJson['status'],
length: parsedJson['name'],
copyright: parsedJson['copyright'],
data: imageinfo,
);
}
}
class Infos {
final String title;
final String imgurl;
final String href;
final String view;
final String comments;
Infos({ this.title, this.imgurl, this.href, this.view, this.comments });
factory Infos.fromJson(Map<String, dynamic> parsedJson){
return Infos(
title: parsedJson['title'] as String,
imgurl: parsedJson['imgurl'] as String,
href: parsedJson['href'] as String,
view: parsedJson['view'] as String,
comments: parsedJson['comments'] as String,
);
}
}

View File

@@ -0,0 +1,44 @@
class Index {
int status;
List<Body> body;
Index({this.status, this.body});
Index.fromJson(Map<String, dynamic> json) {
status = json['status'];
if (json['body'] != null) {
body = new List<Body>();
json['body'].forEach((v) {
body.add(new Body.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
if (this.body != null) {
data['body'] = this.body.map((v) => v.toJson()).toList();
}
return data;
}
}
class Body {
int id;
String text;
Body({this.id, this.text});
Body.fromJson(Map<String, dynamic> json) {
id = json['id'];
text = json['text'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['text'] = this.text;
return data;
}
}

View File

@@ -0,0 +1,3 @@
# JSON数据序列化
序列化的数据和接口数据返回的格式进行对应

View File

@@ -0,0 +1 @@
f37eb8c2-4099-4d47-9831-8291d72c4472

View File

@@ -0,0 +1 @@
# 数据请求的具体方法和view中页面分开更好解耦

View File

@@ -0,0 +1,16 @@
import 'package:flutter_app/http/config.dart';
import 'package:flutter_app/http/index.dart';
import 'package:flutter_app/model/IndexModel.dart';
class ServiceMethods {
Http _http;
ServiceMethods() {
this._http = new Http();
}
/// 获取视频数据
Future getImageList(data) async {
return new Index.fromJson(await this._http.get(config.testUrl, data));
}
}

View File

@@ -0,0 +1 @@
3fd47dee-4bcb-496c-9bb9-035c127f379f

View File

@@ -0,0 +1 @@
ad709ed6-6be2-4f94-9fe3-b24adc4cc9da

Binary file not shown.

View File

@@ -0,0 +1 @@
# App的静态资源

View File

@@ -0,0 +1 @@
3dcd5737-edd8-4571-909d-79b89a930d9e

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

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