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 @@
b8c19708-4e09-4001-98bf-0834f16fc12c

View File

@@ -0,0 +1,512 @@
import 'dart:convert';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:peach/config/Index.dart';
import 'package:peach/config/_.dart';
import 'package:peach/entity/_.dart';
import 'package:peach/service/_.dart';
import 'package:peach/utils/_.dart';
import 'package:peach/widget/Empty.dart';
import 'package:peach/widget/_.dart';
/*
* 首页
*/
class Index extends StatefulWidget {
final Function clickHead;
const Index({Key key, this.clickHead}) : super(key: key);
@override
_Index createState() => _Index(this.clickHead);
}
class _Index extends State<Index> with SingleTickerProviderStateMixin {
final Function clickHead;
_Index(this.clickHead);
final List<String> _tabValues = ['推荐', '排行', '关注'];
List<List<dynamic>> tabsResult = [[], [], []];
int index = 0;
List<PageEntity> pageList = [
PageEntity(),
PageEntity(),
PageEntity(),
];
PageController _controller;
TabController _tabController;
EasyRefreshController _easyRefreshController;
BoxDecoration decoration = BoxDecoration(color: ColorConfig.WhiteBackColor);
UserInfoPersonalEntityData userInfo = UserInfoPersonalEntityData.fromJson(
jsonDecode(SPreferences().getString("onUserInfo")));
@override
void initState() {
super.initState();
_controller = PageController();
_tabController = new TabController(length: _tabValues.length, vsync: this);
_easyRefreshController = EasyRefreshController();
getOpusRecommend();
opusRanking();
getFollow();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
leading: leading(),
toolbarHeight: Screen.setHeight(82),
backgroundColor: ColorConfig.ThemeColor,
title: title(),
bottom: bottom(),
),
body: Container(
height: Screen.height(context) - Screen.setHeight(132) - Config.top,
margin: EdgeInsets.only(top: 2, bottom: 2),
child: PageView(
controller: _controller,
children: <Widget>[
indexView(),
rankingView(),
userViewList(),
],
onPageChanged: (e) => {
this.setState(() {
index = e;
})
},
),
),
);
}
// 推荐item样式
_createGridViewItem(int e) {
return GestureDetector(
onTap: () {
Modular.to.pushNamed("/worksInfo/${this.tabsResult[0][e].opusId}");
},
child: Container(
height: Screen.width(context) / 2,
width: Screen.width(context) / 2,
// decoration: BoxDecoration(
// image: DecorationImage(
// image: NetworkImage(this.tabsResult[0][e].opusImg),
// fit: BoxFit.cover,
// ),
// ),
child: CachedNetworkImage(
imageUrl: tabsResult[0][e].opusImg,
placeholder: (context, url) => new Container(
child: new Center(
child: new CircularProgressIndicator(),
),
width: 160.0,
height: 90.0,
),
errorWidget: (context, url, error) => new Icon(Icons.error),
fit: BoxFit.cover,
),
),
);
}
Widget leading() {
return Align(
alignment: Alignment.center,
child: GestureDetector(
onTapDown: (TapDownDetails tapDownDetails) {
clickHead();
},
child: Container(
margin: EdgeInsets.only(left: 10),
child: ClipRRect(
borderRadius: BorderRadius.circular(30),
child: ClipOval(
child: Image.network(
userInfo.userHeadImg,
width: Screen.setWidth(38),
height: Screen.setWidth(38),
fit: BoxFit.cover,
),
),
),
),
),
);
}
Widget title() {
return Row(
children: <Widget>[
// indexSearch
Expanded(
flex: 3,
child: GestureDetector(
onTap: () {
Navigator.of(context).pushNamed("/indexSearch");
},
child: ExhibitionSearch(),
),
),
Expanded(
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
children: [
Icon(Icons.person),
Text(
"好友",
style: TextStyle(fontSize: 12),
)
],
),
SizedBox(
width: 5,
),
Column(
children: [
Icon(Icons.group),
Text(
"群聊",
style: TextStyle(fontSize: 12),
)
],
),
],
),
),
],
);
}
Widget bottom() {
return PreferredSize(
preferredSize: Size.fromHeight(10),
child: Container(
height: Screen.setHeight(38),
width: Screen.width(context),
decoration: BoxDecoration(color: ColorConfig.WhiteBackColor),
child: Align(
child: TabBar(
tabs: _tabValues
.asMap()
.keys
.map((e) => Tab(
child: Container(
decoration: index == e
? BoxDecoration(
color: ColorConfig.ThemeColor,
borderRadius:
BorderRadius.all(Radius.circular(25.0)),
)
: decoration,
padding: EdgeInsets.only(
left: 16, right: 16, top: 6, bottom: 6),
child: Text(_tabValues[e],
style: TextStyle(
fontSize: 14,
color: index == e
? Colors.white
: Color(0XFF7c7c7c))),
),
))
.toList(),
indicatorColor: ColorConfig.WhiteBackColor,
indicatorSize: TabBarIndicatorSize.tab,
isScrollable: true,
controller: _tabController,
labelColor: ColorConfig.ThemeColor,
labelPadding: EdgeInsets.only(right: 30, left: 30),
unselectedLabelColor: Colors.black,
indicatorWeight: 0.1,
onTap: (int i) {
setState(() {
index = i;
_controller.jumpToPage(i);
});
},
),
),
),
);
}
// 下拉刷新上啦加载
Widget easyRefresh(Widget child) {
return EasyRefresh(
header: BezierCircleHeader(backgroundColor: ColorConfig.ThemeColor),
footer: BezierBounceFooter(backgroundColor: ColorConfig.ThemeColor),
enableControlFinishRefresh: false,
enableControlFinishLoad: true,
controller: _easyRefreshController,
child: child,
bottomBouncing: true,
onRefresh: () async {
this.pageList[index].page = 1;
this.pageList[index].isLoad = false;
this.tabsResult[index] = [];
await requestType(index);
_easyRefreshController.finishRefresh(success: true);
},
onLoad: () async {
_easyRefreshController.finishRefresh();
if (!this.pageList[index].isLoad) {
this.pageList[index].page++;
await requestType(index);
} else {
await requestType(index);
// _easyRefreshController.finishLoad(noMore: true);
}
_easyRefreshController.finishLoad();
},
);
}
Widget indexView() {
return easyRefresh(tabsResult[0].length == 0
? Container(
height: MediaQuery.of(context).size.height / 2,
child: Center(
child: SpinKitWave(
color: ColorConfig.ThemeColor, itemCount: 3, size: 40),
),
)
: ListView(
shrinkWrap: true,
physics: BouncingScrollPhysics(),
children: [
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemCount: tabsResult[0].length,
itemBuilder: (BuildContext context, int index) {
return _createGridViewItem(index);
})
]));
}
// 排行
Widget rankingView() {
return Empty(
isShow: tabsResult[1].length <= 0,
child: easyRefresh(
ListView(
children: [
...tabsResult[1]
.asMap()
.keys
.map((e) => _rankingItemView(tabsResult[1][e]))
.toList()
],
),
),
);
}
// 排行
Widget _rankingItemView(OpusRankingEntity data) {
return GestureDetector(
onTap: () {
Modular.to.pushNamed("/worksInfo/${data.opusId}");
},
child: Column(
children: [
Container(
height: Screen.setHeight(200),
// decoration: BoxDecoration(
// image: DecorationImage(
// image: NetworkImage(data.opusImg),
// fit: BoxFit.cover,
// ),
// ),
child: CachedNetworkImage(
imageUrl: data.opusImg,
height: Screen.setHeight(200),
width: Screen.width(context),
placeholder: (context, url) => new Container(
child: new Center(
child: new CircularProgressIndicator(),
),
width: 160.0,
height: 90.0,
),
errorWidget: (context, url, error) => new Icon(Icons.error),
fit: BoxFit.cover,
),
),
ListTile(
leading: Container(
height: Screen.setHeight(45),
width: 45,
child: ClipRRect(
borderRadius: BorderRadius.circular(30),
child: ClipOval(
child: Image.network(
data.userHeadImg,
width: Screen.setWidth(38),
height: Screen.setWidth(38),
fit: BoxFit.cover,
),
),
),
),
title: Text(data.userNickname),
subtitle: Text(
data.userAutograph,
maxLines: 1,
style: TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
),
trailing: Container(
width: Screen.setWidth(40),
alignment: Alignment.centerRight,
child: Row(
children: [
Icon(
Icons.thumb_up,
size: 18,
),
SizedBox(
width: 5,
),
Text(data.opusSatisfied.toString())
],
),
),
),
Line(),
],
),
);
}
// 关注列表view
Widget userViewList() {
return Empty(
isShow: tabsResult[2].length <= 0,
child: easyRefresh(
GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
children: [
...tabsResult[2].asMap().keys.map((e) => userView(e)).toList()
],
),
),
);
}
// 关注列表
Widget userView(int e) {
return GestureDetector(
onTap: () {
Modular.to.pushNamed("/worksInfo/${tabsResult[2][e].opusId}");
},
child: Container(
height: Screen.width(context) / 2,
width: Screen.width(context) / 2,
// decoration: BoxDecoration(
// image: DecorationImage(
// image: NetworkImage(tabsResult[2][e].opusImg),
// fit: BoxFit.cover,
// ),
// ),
child: CachedNetworkImage(
imageUrl: tabsResult[2][e].opusImg,
placeholder: (context, url) => new Container(
child: new Center(
child: new CircularProgressIndicator(),
),
width: 160.0,
height: 90.0,
),
errorWidget: (context, url, error) => new Icon(Icons.error),
fit: BoxFit.cover,
),
),
);
}
// 根据当前不同下标调用不用接口
requestType(int e) async {
if (e == 0) {
return await getOpusRecommend();
} else if (e == 1) {
return await opusRanking();
} else {
return await getFollow();
}
}
// 推荐
getOpusRecommend() async {
OpusRecommendData res = await OpusService.getOpusRecommend({
"page": this.pageList[0].page,
"count": this.pageList[0].count,
});
if (res == null) {
setState(() {
this.pageList[0].isLoad = true;
});
return;
}
setState(() {
this.tabsResult[0] = [...this.tabsResult[0], ...res.result];
});
}
// 排行列表
opusRanking() async {
OpusRankingEntityData res = await OpusService.opusRanking({
"page": this.pageList[1].page,
"count": this.pageList[1].count,
});
if (res == null) {
setState(() {
this.pageList[1].isLoad = true;
});
return;
}
setState(() {
this.tabsResult[1] = [...this.tabsResult[1], ...res.result];
});
}
// 关注列表
getFollow() async {
FollowData res = await OpusService.getFollow({
"page": this.pageList[2].page,
"count": this.pageList[2].count,
});
if (res == null) {
setState(() {
this.pageList[2].isLoad = true;
});
return;
}
setState(() {
this.tabsResult[2] = [...this.tabsResult[2], ...res.result];
});
}
}

View File

@@ -0,0 +1,384 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:peach/config/_.dart';
import 'package:peach/entity/_.dart';
import 'package:peach/service/_.dart';
import 'package:peach/utils/_.dart';
import 'package:peach/views/Index/Index.dart';
import 'package:peach/widget/Empty.dart';
import 'package:peach/widget/_.dart';
import 'dart:convert';
/*
* 搜索结果列表页
*/
class IndexResultsList extends StatefulWidget {
final String affKeyword;
final int afferentType;
const IndexResultsList({this.affKeyword, this.afferentType = 0});
@override
_IndexResultsList createState() =>
_IndexResultsList(affKeyword, afferentType);
}
class _IndexResultsList extends State<IndexResultsList>
with SingleTickerProviderStateMixin {
final String affKeyword;
final int afferentType;
TextEditingController _controller;
TabController _tabController;
PageController _pageController;
EasyRefreshController _easyRefreshController;
// 当前搜索类型
int type = 0;
List<String> typeList = ['opus', 'user', 'tag'];
// 搜索值
String keyword = '';
List<PageEntity> page = [PageEntity(), PageEntity(), PageEntity()];
List<List<dynamic>> listData = [[], [], []];
bool lock = false;
_IndexResultsList(this.affKeyword, this.afferentType);
bool loading = true;
@override
void initState() {
//初始化,这个函数在生命周期中只调用一次
super.initState();
_tabController =
TabController(initialIndex: this.afferentType, length: 3, vsync: this);
_pageController = PageController(initialPage: this.afferentType);
type = this.afferentType;
_easyRefreshController = EasyRefreshController();
_controller = TextEditingController();
httpCall();
}
@override
Widget build(BuildContext context) {
if (loading) return Loading();
return Scaffold(
appBar: AppBar(
title: search(),
centerTitle: true,
backgroundColor: ColorConfig.ThemeColor,
bottom: PreferredSize(
preferredSize: Size.fromHeight(48),
child: Material(
//这里设置tab的背景色
color: ColorConfig.WhiteBackColor,
child: TabBar(
controller: _tabController,
tabs: [Tab(text: "作品"), Tab(text: "用户"), Tab(text: "标签")],
isScrollable: true,
indicatorColor: ColorConfig.ThemeColor,
indicatorWeight: 2,
// indicatorPadding: EdgeInsets.only(left: 20, right: 20),
// in
indicatorSize: TabBarIndicatorSize.tab,
labelColor: ColorConfig.ThemeColor,
labelStyle: TextStyle(fontSize: 15),
labelPadding:
EdgeInsets.only(left: 50, top: 0, right: 50, bottom: 0),
unselectedLabelColor: ColorConfig.TextColor,
unselectedLabelStyle: TextStyle(fontSize: 15),
onTap: (index) {
setType(index);
_pageController.jumpToPage(index);
},
),
),
),
),
body: Container(
height: Screen.height(context) - Config.top,
margin: EdgeInsets.only(top: 2, bottom: 2),
child: PageView(
controller: _pageController,
children: <Widget>[
indexView(),
userViewList(),
tagView(),
],
onPageChanged: (index) {
// setType(index);
_tabController.animateTo(index);
},
),
),
);
;
}
Widget search() {
return Container(
width: Screen.width(context),
height: Screen.setHeight(28),
decoration: BoxDecoration(
color: ColorConfig.WhiteBackColor,
borderRadius: BorderRadius.all(Radius.circular(28.0)),
),
child: TextField(
controller: _controller,
textInputAction: TextInputAction.search,
onSubmitted: (res) {
keyword = res;
page[0].page = 1;
page[1].page = 1;
page[2].page = 1;
listData[0] = [];
listData[1] = [];
listData[2] = [];
opusSearch();
},
decoration: InputDecoration(
isDense: true,
hintText: "请输入关键字",
prefixIcon: Icon(
Icons.search,
color: ColorConfig.TextColor,
size: 20,
),
fillColor: ColorConfig.ThemeColor,
labelStyle: TextStyle(color: ColorConfig.ThemeColor),
enabledBorder: UnderlineInputBorder(
//选中时下边框颜色
borderSide: BorderSide(color: ColorConfig.ThemeColor),
),
focusedBorder: UnderlineInputBorder(
//选中时下边框颜色
borderSide: BorderSide(color: ColorConfig.ThemeColor),
),
),
),
);
}
// 下拉刷新上啦加载
Widget easyRefresh(Widget child) {
return EasyRefresh(
header: BezierCircleHeader(backgroundColor: ColorConfig.ThemeColor),
footer: BezierBounceFooter(backgroundColor: ColorConfig.ThemeColor),
enableControlFinishRefresh: false,
enableControlFinishLoad: true,
controller: _easyRefreshController,
child: child,
bottomBouncing: true,
onRefresh: () async {
page[type].page = 1;
listData[type] = [];
await opusSearch();
_easyRefreshController.finishRefresh(success: true);
},
onLoad: () async {
_easyRefreshController.finishRefresh();
if (!page[type].isLoad) {
page[type].page++;
await opusSearch();
_easyRefreshController.finishLoad();
} else {
new Future.delayed(Duration(seconds: 1), () {
_easyRefreshController.finishLoad();
});
}
},
);
}
Widget indexView() {
return Empty(
isShow: listData[0].length <= 0,
child: easyRefresh(
GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
children: [
...listData[0]
.asMap()
.keys
.map((e) => _createGridViewItem(listData[0][e]))
.toList()
],
),
),
);
}
Widget tagView() {
return Empty(
isShow: listData[2].length <= 0,
child: easyRefresh(
GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
children: [
...listData[2]
.asMap()
.keys
.map((e) => _createGridViewItem(listData[2][e]))
.toList()
],
),
),
);
}
// 用户列表view
Widget userViewList() {
return Empty(
isShow: listData[1].length <= 0,
child: easyRefresh(ListView(
children: [
...listData[1]
.asMap()
.keys
.map((e) => userView(listData[1][e]))
.toList()
],
)),
);
}
Widget userView(OpusSearchUserEntityResult data) {
return Column(
children: [
Panel(
child: Row(
children: [
GestureDetector(
onTap: () {
Navigator.of(context).pushNamed("/personal/${data.userId}");
},
child: ClipRRect(
borderRadius: BorderRadius.circular(40),
child: ClipOval(
child: Image.network(
data.userHeadImg,
width: Screen.setWidth(40),
height: Screen.setWidth(40),
fit: BoxFit.cover,
),
),
),
),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
Navigator.of(context).pushNamed("/personal/${data.userId}");
},
child: Container(
margin: EdgeInsets.only(left: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("${data.userNickname}"),
Text(
"${data.userAutograph}",
),
],
),
),
),
),
// ElevatedButton(
// style: ButtonStyle(
// backgroundColor: MaterialStateProperty.resolveWith((states) {
// //默认不使用背景颜色
// return ColorConfig.ThemeColor;
// }),
// ),
// child: Text('关注'),
// onPressed: () {},
// ),
],
),
),
Divider()
],
);
}
// 推荐item样式
_createGridViewItem(OpusSearchTagEntityResult data) {
return GestureDetector(
onTap: () {
Modular.to.pushNamed("/worksInfo/${data.opusId}");
},
child: Container(
height: Screen.width(context) / 2,
width: Screen.width(context) / 2,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(data.opusImg),
fit: BoxFit.cover,
),
),
),
);
}
httpCall() async {
keyword = affKeyword;
_controller.text = affKeyword;
await this.opusSearch();
setState(() {
loading = false;
});
}
setType(int i) async {
type = i;
if (listData[type].length <= 0) {
await opusSearch();
}
}
opusSearch() async {
var content = utf8.encode(keyword);
var digest = base64Encode(content);
dynamic res = await OpusService.opusSearch({
"keyword": digest,
"type": typeList[type],
"page": page[type].page,
"count": page[type].count,
});
dynamic rel;
if (type == 0) {
rel = OpusSearchTagEntityList.fromJson(res).data;
} else if (type == 1) {
rel = OpusSearchUserEntityList.fromJson(res).data;
} else if (type == 2) {
rel = OpusSearchTagEntityList.fromJson(res).data;
}
if (rel == null) {
return;
}
listData[type] = [...listData[type], ...rel.result];
if (rel.result.length < page[type].count) {
page[type].isLoad = true;
}
setState(() {});
}
}

View File

@@ -0,0 +1,211 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:peach/config/_.dart';
import 'package:peach/entity/_.dart';
import 'package:peach/service/TagService.dart';
import 'package:peach/utils/_.dart';
import 'package:peach/views/Dynamic/Topic.dart';
import 'package:peach/widget/Panel.dart';
import 'dart:convert';
import 'dart:convert' as convert;
import 'package:peach/widget/_.dart';
/*
* 首页搜索页
*/
class IndexSearch extends StatefulWidget {
final Function clickHead;
const IndexSearch({Key key, this.clickHead}) : super(key: key);
@override
_IndexSearch createState() => _IndexSearch();
}
class _IndexSearch extends State<IndexSearch>
with SingleTickerProviderStateMixin {
TextEditingController _controller;
List<TagRecommendTagEntityData> recommendTagList = [];
List<String> historyList = [];
@override
void initState() {
super.initState();
// SharedPreferences 初始化
SPreferences.init();
getHistory();
_controller = TextEditingController(text: "");
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: future(),
builder: (context, snapshot) {
return Scaffold(
appBar: AppBar(
title: search(),
toolbarHeight: Screen.setHeight(40),
centerTitle: true,
backgroundColor: ColorConfig.ThemeColor,
),
body: Container(
height: Screen.height(context) - Screen.setHeight(45) - Config.top,
width: Screen.width(context),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: Screen.setHeight(140),
child: Topic(
topicList: recommendTagList,
onTap: (rel) {
setHistory(rel);
Modular.to.pushNamed("/indexResultsList/$rel/0");
}),
),
Container(
height: Screen.setHeight(200),
child: titleSection(
"历史搜索",
Wrap(
crossAxisAlignment: WrapCrossAlignment.end,
runSpacing: 5,
spacing: 10,
children: [
...historyList
.asMap()
.keys
.map(
(e) => GestureDetector(
onTap: () {
String res = historyList[e];
setHistory(res);
Modular.to.pushNamed(
"/indexResultsList/${res}/0",
);
},
child: Text(
historyList[e],
style: TextStyle(
color: ColorConfig.ThemeColor,
fontSize: 16),
),
),
)
.toList(),
],
)),
)
],
),
),
);
},
);
}
Widget search() {
return Container(
width: Screen.width(context),
height: Screen.setHeight(28),
decoration: BoxDecoration(
color: ColorConfig.WhiteBackColor,
borderRadius: BorderRadius.all(Radius.circular(28.0)),
),
child: TextField(
controller: _controller,
textInputAction: TextInputAction.search,
onSubmitted: (res) {
_controller.text = "";
setHistory(res);
Modular.to.pushNamed("/indexResultsList/$res/0");
},
decoration: InputDecoration(
isDense: true,
hintText: "请输入关键字",
prefixIcon: Icon(
Icons.search,
color: ColorConfig.TextColor,
size: 20,
),
fillColor: ColorConfig.ThemeColor,
labelStyle: TextStyle(color: ColorConfig.ThemeColor),
enabledBorder: UnderlineInputBorder(
//选中时下边框颜色
borderSide: BorderSide(color: ColorConfig.ThemeColor),
),
focusedBorder: UnderlineInputBorder(
//选中时下边框颜色
borderSide: BorderSide(color: ColorConfig.ThemeColor),
),
),
),
);
}
Widget titleSection(String title, Widget child) {
return Panel(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, //分析 2
children: [
Container(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
title,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
Expanded(
child: child,
),
],
),
);
}
future() async {
await tagRecommendTag();
}
tagRecommendTag() async {
List<TagRecommendTagEntityData> res = await TagService.tagRecommendTag({});
if (res != null) {
recommendTagList = res.take(5).toList();
}
}
setHistory(String value) {
int index = historyList.indexOf(value);
if (index == -1) {
setHistoryList(value);
return;
}
historyList.remove(value);
setHistoryList(value);
}
getHistory() {
String res = SPreferences().getString("historyList");
print(res);
if (res != null) {
List<String> res =
jsonDecode(SPreferences().getString("historyList")).cast<String>();
historyList = res;
}
}
setHistoryList(String value) {
historyList = [value, ...historyList];
SPreferences().setString("historyList", convert.jsonEncode(historyList));
setState(() {});
}
}

View File

@@ -0,0 +1,156 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:peach/config/Colors.dart';
import 'package:peach/entity/_.dart';
import 'package:peach/service/_.dart';
import 'package:peach/utils/_.dart';
import 'package:peach/widget/PersonalpTitle.dart';
/*
* 首页
*/
class PersonalpPop extends StatefulWidget {
@override
_PersonalpPop createState() => _PersonalpPop();
}
class _PersonalpPop extends State<PersonalpPop>
with SingleTickerProviderStateMixin {
UserInfoPersonalEntityData userInfo = UserInfoPersonalEntityData.fromJson(
jsonDecode(SPreferences().getString("onUserInfo")));
@override
Widget build(BuildContext context) {
return Drawer(
child: Container(
color: ColorConfig.WhiteBackColor,
child: Column(
children: [
Expanded(
flex: 1,
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: PersonalpTitle(
imgHead: userInfo.userHeadImg,
nickname: userInfo.userNickname,
autograph: userInfo.userAutograph,
fansNums: userInfo.fansNums,
satisfiedNums: userInfo.satisfiedNums,
followNums: userInfo.followNums,
userId: userInfo.userId),
),
GestureDetector(
onTap: () {
Navigator.of(context)
.pushNamed("/personal/${userInfo.userId}");
},
child: ListTile(
leading: Icon(Icons.grade),
title: Text('个人空间'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).pushNamed("/publishingWorks");
},
child: ListTile(
leading: Icon(Icons.add_photo_alternate),
title: Text('发布作品'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
),
ListTile(
leading: Icon(Icons.record_voice_over),
title: Text('我要约稿'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
ListTile(
leading: Icon(Icons.accessibility_new),
title: Text('我要接稿'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
ListTile(
leading: Icon(Icons.paid),
title: Text('创作激励'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
ListTile(
leading: Icon(Icons.grading),
title: Text('投稿管理'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
ListTile(
leading: Icon(Icons.favorite),
title: Text('我的收藏'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
ListTile(
leading: Icon(Icons.settings_phone),
title: Text('联系客服'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 18,
),
),
],
)),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Row(
children: [
Expanded(
flex: 1,
child: InkWell(
onTap: () => {
Modular.to.pushNamed("/setting")
},
child: Column(
children: [Icon(Icons.settings), Text("设置")],
),
)
),
Expanded(
flex: 1,
child: Column(
children: [Icon(Icons.color_lens), Text("主题")],
)),
Expanded(
flex: 1,
child: Column(
children: [Icon(Icons.brightness_4), Text("夜间")],
)),
],
),
)
],
)),
);
}
}