first commit
This commit is contained in:
1
moehu/moehu_fontend/lib/views/Personal/.pydio
Normal file
1
moehu/moehu_fontend/lib/views/Personal/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
d7f8112d-aaec-40d5-825a-b15602506e25
|
||||
500
moehu/moehu_fontend/lib/views/Personal/Personal.dart
Normal file
500
moehu/moehu_fontend/lib/views/Personal/Personal.dart
Normal file
@@ -0,0 +1,500 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:bot_toast/bot_toast.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/BlankPage.dart';
|
||||
import 'package:peach/views/Dynamic/DynamicItem.dart';
|
||||
import 'package:peach/widget/Empty.dart';
|
||||
import 'package:peach/widget/_.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
/*
|
||||
* 个人空间
|
||||
*/
|
||||
class Personal extends StatefulWidget {
|
||||
final int userId;
|
||||
|
||||
const Personal({this.userId});
|
||||
|
||||
@override
|
||||
_Personal createState() => _Personal(this.userId);
|
||||
}
|
||||
|
||||
class _Personal extends State<Personal> with SingleTickerProviderStateMixin {
|
||||
final int userId;
|
||||
|
||||
ScrollController nestedScrollViewController;
|
||||
|
||||
List<String> _tabValues = [
|
||||
'动态',
|
||||
'投稿',
|
||||
'收藏',
|
||||
];
|
||||
TabController _tabController;
|
||||
|
||||
double textHeight = 20;
|
||||
|
||||
List<PageEntity> page = [
|
||||
PageEntity(),
|
||||
PageEntity(),
|
||||
PageEntity(),
|
||||
];
|
||||
|
||||
List<DynamicPersonalDynamicEntity> dynamicList = [];
|
||||
|
||||
List<CollectionOpusListEntityResult> collectionOpusList = [];
|
||||
|
||||
List<OpusListEntityResult> opusList = [];
|
||||
|
||||
UserInfoPersonalEntityData userInfo;
|
||||
|
||||
_Personal(this.userId);
|
||||
|
||||
bool loading = true;
|
||||
|
||||
EasyRefreshController _easyRefreshController;
|
||||
|
||||
UserInfo _userInfo =
|
||||
UserInfo.fromJson(jsonDecode(SPreferences().getString("userInfo")));
|
||||
|
||||
bool isCheckUser = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
///初始化,这个函数在生命周期中只调用一次
|
||||
super.initState();
|
||||
nestedScrollViewController = ScrollController();
|
||||
_easyRefreshController = EasyRefreshController();
|
||||
_tabController = TabController(length: _tabValues.length, vsync: this);
|
||||
future();
|
||||
|
||||
nestedScrollViewController.addListener(() {
|
||||
if (nestedScrollViewController.position.pixels ==
|
||||
nestedScrollViewController.position.maxScrollExtent) {
|
||||
rollingToTheBottom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (loading) return Loading();
|
||||
return Scaffold(
|
||||
body: NestedScrollView(
|
||||
controller: nestedScrollViewController,
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
expandedHeight: Screen.setHeight(210) + textHeight,
|
||||
// collapsedHeight: Screen.setHeight(20) + Config.top,
|
||||
backgroundColor: ColorConfig.ThemeColor,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: Container(
|
||||
color: ColorConfig.WhiteBackColor,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: Screen.setHeight(90),
|
||||
decoration: new BoxDecoration(
|
||||
image: new DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
"https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1770575461,2828994027&fm=26&gp=0.jpg"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: Screen.setHeight(155),
|
||||
child: Panel(
|
||||
child: PersonalpTitle(
|
||||
headImgHeight: 80,
|
||||
isEditing: true,
|
||||
textHeight: textHeight,
|
||||
isOpenFollow: _userInfo.userId != userId,
|
||||
isFollow: isCheckUser,
|
||||
isText: textHeight > 20 ? true : false,
|
||||
imgHead: userInfo.userHeadImg,
|
||||
nickname: userInfo.userNickname,
|
||||
autograph: userInfo.userAutograph,
|
||||
fansNums: userInfo.fansNums,
|
||||
satisfiedNums: userInfo.satisfiedNums,
|
||||
followNums: userInfo.followNums,
|
||||
userId: userInfo.userId,
|
||||
onExpand: (height) {
|
||||
setState(
|
||||
() {
|
||||
textHeight = height;
|
||||
},
|
||||
);
|
||||
},
|
||||
opusFollowUser: () {
|
||||
opusFollowUser(userId);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 10),
|
||||
child: CircleTransparentIcon(
|
||||
icon: Icon(
|
||||
Icons.search,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 10),
|
||||
child: CircleTransparentIcon(
|
||||
icon: Transform.rotate(
|
||||
//旋转90度
|
||||
angle: math.pi / 2,
|
||||
child: Icon(Icons.more_horiz),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SliverPersistentHeader(
|
||||
delegate: _SliverTabBarDelegate(
|
||||
Container(
|
||||
child: CustomTabBar(
|
||||
tabController: _tabController,
|
||||
tabValues: _tabValues,
|
||||
),
|
||||
),
|
||||
),
|
||||
pinned: true,
|
||||
),
|
||||
];
|
||||
},
|
||||
body: Container(
|
||||
height: Screen.height(context) - Screen.setHeight(400) - Config.top,
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
dynamicView(),
|
||||
contributionList(),
|
||||
_collectionList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 动态列表
|
||||
Widget dynamicView() {
|
||||
return Empty(
|
||||
isShow: dynamicList.length <= 0,
|
||||
child: MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
removeBottom: true,
|
||||
child: ListView(
|
||||
children: [
|
||||
...dynamicList
|
||||
.asMap()
|
||||
.keys
|
||||
.map(
|
||||
(e) => DynamicItem(
|
||||
dynamicData: dynamicList[0],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
page[0].isLoad ? loadingComplete() : null
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 投稿列表
|
||||
Widget contributionList() {
|
||||
return Empty(
|
||||
isShow: opusList.length <= 0,
|
||||
child: MediaQuery.removePadding(
|
||||
removeTop: true,
|
||||
context: context,
|
||||
child: GridView(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
),
|
||||
children: [
|
||||
...opusList
|
||||
.asMap()
|
||||
.keys
|
||||
.map(
|
||||
(e) => GestureDetector(
|
||||
onTap: () {
|
||||
Modular.to.pushNamed("/worksInfo/${opusList[e].opusId}");
|
||||
},
|
||||
child: Container(
|
||||
height: Screen.width(context) / 2,
|
||||
width: Screen.width(context) / 2,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
opusList[e].opusImg,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 收藏列表
|
||||
Widget _collectionList() {
|
||||
return Empty(
|
||||
isShow: collectionOpusList.length <= 0,
|
||||
child: MediaQuery.removePadding(
|
||||
removeTop: true,
|
||||
context: context,
|
||||
child: GridView(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
),
|
||||
children: [
|
||||
...collectionOpusList
|
||||
.asMap()
|
||||
.keys
|
||||
.map(
|
||||
(e) => GestureDetector(
|
||||
onTap: () {
|
||||
Modular.to.pushNamed(
|
||||
"/worksInfo/${collectionOpusList[e].opusId}");
|
||||
},
|
||||
child: Container(
|
||||
height: Screen.width(context) / 2,
|
||||
width: Screen.width(context) / 2,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
collectionOpusList[e].opusImg,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 加载完成
|
||||
loadingComplete() {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
),
|
||||
child: Text(
|
||||
"再这么找也没有啦",
|
||||
style: TextStyle(
|
||||
color: ColorConfig.TextColor,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
future() async {
|
||||
await dynamicPersonalDynamic();
|
||||
await getUserInfo();
|
||||
await getCollectionOpusList();
|
||||
await getOpusList();
|
||||
await isCheckUserIsFollow(userId);
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 滚动触底时触发
|
||||
rollingToTheBottom() async {
|
||||
int index = _tabController.index;
|
||||
if (index == 0) {
|
||||
if (page[0].isLoad) return;
|
||||
page[0].page++;
|
||||
dynamicPersonalDynamic();
|
||||
} else if (index == 2) {
|
||||
if (page[2].isLoad) return;
|
||||
page[2].page++;
|
||||
getCollectionOpusList();
|
||||
}
|
||||
}
|
||||
|
||||
// 动态列表
|
||||
dynamicPersonalDynamic() async {
|
||||
print(userId);
|
||||
DynamicPersonalDynamicEntityData res =
|
||||
await DynamicService.dynamicPersonalDynamic(
|
||||
{
|
||||
"page": page[0].page,
|
||||
"count": page[0].count,
|
||||
"userid": userId,
|
||||
},
|
||||
);
|
||||
if (res == null) return;
|
||||
if (res.result.length < page[0].count) {
|
||||
page[0].isLoad = true;
|
||||
}
|
||||
setState(() {
|
||||
dynamicList = [...dynamicList, ...res.result];
|
||||
});
|
||||
}
|
||||
|
||||
// 个人信息
|
||||
getUserInfo() async {
|
||||
UserInfoPersonalEntityData res = await UserService.UserInfo({
|
||||
'user_id': userId,
|
||||
});
|
||||
setState(() {
|
||||
userInfo = res;
|
||||
});
|
||||
}
|
||||
|
||||
// 设置关注
|
||||
opusFollowUser(int id) async {
|
||||
Null res = await OpusService.opusFollowUser({
|
||||
"user_to_id": id,
|
||||
});
|
||||
if (isCheckUser) {
|
||||
BotToast.showText(text: "取消关注");
|
||||
} else {
|
||||
BotToast.showText(text: "关注成功");
|
||||
}
|
||||
await isCheckUserIsFollow(id);
|
||||
this.setState(() {});
|
||||
}
|
||||
|
||||
isCheckUserIsFollow(int id) async {
|
||||
bool res = await OpusService.isCheckUserIsFollow({
|
||||
"user_to_id": id,
|
||||
});
|
||||
isCheckUser = res;
|
||||
}
|
||||
|
||||
// 收藏列表
|
||||
getCollectionOpusList() async {
|
||||
CollectionOpusListEntityData res = await OpusService.collectionOpusList({
|
||||
'userid': userId,
|
||||
"page": page[2].page,
|
||||
"count": page[2].count,
|
||||
});
|
||||
if (res == null) return;
|
||||
if (res.result.length < page[2].count) {
|
||||
page[2].isLoad = true;
|
||||
}
|
||||
setState(() {
|
||||
collectionOpusList = res.result;
|
||||
});
|
||||
}
|
||||
|
||||
getOpusList() async {
|
||||
OpusListEntityData res = await OpusService.getOpusList({
|
||||
'userid': userId,
|
||||
"page": page[1].page,
|
||||
"count": page[1].count,
|
||||
});
|
||||
if (res == null) return;
|
||||
if (res.result.length < page[1].count) {
|
||||
page[1].isLoad = true;
|
||||
}
|
||||
setState(() {
|
||||
opusList = res.result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class CustomTabBar extends StatefulWidget {
|
||||
final TabController tabController;
|
||||
final List<String> tabValues;
|
||||
|
||||
CustomTabBar({Key key, this.tabController, this.tabValues}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CustomTabBarState createState() => _CustomTabBarState();
|
||||
}
|
||||
|
||||
class _CustomTabBarState extends State<CustomTabBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PreferredSize(
|
||||
preferredSize: Size.fromHeight(30),
|
||||
child: Container(
|
||||
width: Screen.width(context),
|
||||
height: Screen.setHeight(40),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConfig.WhiteBackColor,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: ColorConfig.LineColor, width: 1),
|
||||
),
|
||||
),
|
||||
child: TabBar(
|
||||
unselectedLabelColor: ColorConfig.TextColor,
|
||||
labelColor: ColorConfig.ThemeColor,
|
||||
indicatorColor: ColorConfig.ThemeColor,
|
||||
indicatorPadding: EdgeInsets.only(left: 30, right: 30),
|
||||
controller: widget.tabController,
|
||||
tabs: widget.tabValues
|
||||
.asMap()
|
||||
.keys
|
||||
.map(
|
||||
(e) => Tab(
|
||||
child: Text(
|
||||
widget.tabValues[e],
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
final widget;
|
||||
|
||||
_SliverTabBarDelegate(this.widget);
|
||||
|
||||
@override
|
||||
double get minExtent => 40.0;
|
||||
|
||||
@override
|
||||
double get maxExtent => 40.0;
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return widget;
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRebuild(_SliverTabBarDelegate oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
362
moehu/moehu_fontend/lib/views/Personal/PersonalSpace.dart
Normal file
362
moehu/moehu_fontend/lib/views/Personal/PersonalSpace.dart
Normal file
@@ -0,0 +1,362 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.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/BlankPage.dart';
|
||||
import 'package:peach/views/Dynamic/DynamicItem.dart';
|
||||
import 'package:peach/widget/_.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
/*
|
||||
* 个人空间
|
||||
*/
|
||||
class Personal extends StatefulWidget {
|
||||
final String isLeading;
|
||||
|
||||
const Personal({this.isLeading = '0'});
|
||||
|
||||
@override
|
||||
_Personal createState() => _Personal(this.isLeading);
|
||||
}
|
||||
|
||||
class _Personal extends State<Personal> with SingleTickerProviderStateMixin {
|
||||
final String isLeading;
|
||||
|
||||
List<String> _tabValues = [
|
||||
'动态',
|
||||
'投稿',
|
||||
'收藏',
|
||||
];
|
||||
TabController _tabController;
|
||||
|
||||
double textHeight = 20;
|
||||
|
||||
PageEntity page = PageEntity();
|
||||
|
||||
List<DynamicPersonalDynamicEntity> dynamicList = [];
|
||||
|
||||
UserInfo _userInfo =
|
||||
UserInfo.fromJson(jsonDecode(SPreferences().getString("userInfo")));
|
||||
|
||||
_Personal(this.isLeading);
|
||||
|
||||
bool loading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
///初始化,这个函数在生命周期中只调用一次
|
||||
super.initState();
|
||||
_tabController = TabController(length: _tabValues.length, vsync: this);
|
||||
future();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (loading) return Loading();
|
||||
return Scaffold(
|
||||
body: NestedScrollView(
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
expandedHeight: Screen.setHeight(190) + textHeight,
|
||||
collapsedHeight: Screen.setHeight(20) + Config.top,
|
||||
backgroundColor: ColorConfig.ThemeColor,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: Container(
|
||||
color: ColorConfig.WhiteBackColor,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: Screen.setHeight(90),
|
||||
decoration: new BoxDecoration(
|
||||
image: new DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
"https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1770575461,2828994027&fm=26&gp=0.jpg"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: Screen.setHeight(140),
|
||||
child: Panel(
|
||||
child: PersonalpTitle(
|
||||
headImgHeight: 80,
|
||||
isEditing: true,
|
||||
textHeight: textHeight,
|
||||
isText: textHeight > 20 ? true : false,
|
||||
onExpand: (height) {
|
||||
setState(
|
||||
() {
|
||||
textHeight = height;
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
leading: isLeading == '1'
|
||||
? null
|
||||
: Container(
|
||||
width: 1,
|
||||
height: 1,
|
||||
),
|
||||
actions: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 10),
|
||||
child: CircleTransparentIcon(
|
||||
icon: Icon(
|
||||
Icons.search,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(right: 10),
|
||||
child: CircleTransparentIcon(
|
||||
icon: Transform.rotate(
|
||||
//旋转90度
|
||||
angle: math.pi / 2,
|
||||
child: Icon(Icons.more_horiz),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SliverPersistentHeader(
|
||||
delegate: _SliverTabBarDelegate(
|
||||
Container(
|
||||
child: CustomTabBar(
|
||||
tabController: _tabController,
|
||||
tabValues: _tabValues,
|
||||
),
|
||||
),
|
||||
),
|
||||
pinned: true,
|
||||
),
|
||||
];
|
||||
},
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
removeBottom: true,
|
||||
child: ListView(
|
||||
children: [
|
||||
...dynamicList
|
||||
.asMap()
|
||||
.keys
|
||||
.map(
|
||||
(e) => DynamicItem(
|
||||
dynamicData: dynamicList[0],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
Container(
|
||||
height: 80,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
BlankPage(),
|
||||
_collectionList()
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 推荐item样式
|
||||
Widget _collectionList() {
|
||||
return MediaQuery.removePadding(
|
||||
removeTop: true,
|
||||
context: context,
|
||||
child: GridView(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
),
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// Navigator.of(context).pushNamed(
|
||||
// "/worksInfo",
|
||||
// arguments: WorksInfoProps(this.tabsResult[index][e].opusId),
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
height: Screen.width(context) / 2,
|
||||
width: Screen.width(context) / 2,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
"https://upload.jianshu.io/users/upload_avatars/5685558/23e20d58-c5e1-4fd6-90d4-a3752cbe7d6a",
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// Navigator.of(context).pushNamed(
|
||||
// "/worksInfo",
|
||||
// arguments: WorksInfoProps(this.tabsResult[index][e].opusId),
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
height: Screen.width(context) / 2,
|
||||
width: Screen.width(context) / 2,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
"https://upload.jianshu.io/users/upload_avatars/5685558/23e20d58-c5e1-4fd6-90d4-a3752cbe7d6a",
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// Navigator.of(context).pushNamed(
|
||||
// "/worksInfo",
|
||||
// arguments: WorksInfoProps(this.tabsResult[index][e].opusId),
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
height: Screen.width(context) / 2,
|
||||
width: Screen.width(context) / 2,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
"https://upload.jianshu.io/users/upload_avatars/5685558/23e20d58-c5e1-4fd6-90d4-a3752cbe7d6a",
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// Navigator.of(context).pushNamed(
|
||||
// "/worksInfo",
|
||||
// arguments: WorksInfoProps(this.tabsResult[index][e].opusId),
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
height: Screen.width(context) / 2,
|
||||
width: Screen.width(context) / 2,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
"https://upload.jianshu.io/users/upload_avatars/5685558/23e20d58-c5e1-4fd6-90d4-a3752cbe7d6a",
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
future() async {
|
||||
await dynamicPersonalDynamic();
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
dynamicPersonalDynamic() async {
|
||||
DynamicPersonalDynamicEntityData res =
|
||||
await DynamicService.dynamicPersonalDynamic(
|
||||
{
|
||||
"page": page.page,
|
||||
"count": page.count,
|
||||
"userid": _userInfo.userId,
|
||||
},
|
||||
);
|
||||
dynamicList = res.result;
|
||||
}
|
||||
}
|
||||
|
||||
class CustomTabBar extends StatefulWidget {
|
||||
final TabController tabController;
|
||||
final List<String> tabValues;
|
||||
|
||||
CustomTabBar({Key key, this.tabController, this.tabValues}) : super(key: key);
|
||||
|
||||
@override
|
||||
_CustomTabBarState createState() => _CustomTabBarState();
|
||||
}
|
||||
|
||||
class _CustomTabBarState extends State<CustomTabBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PreferredSize(
|
||||
preferredSize: Size.fromHeight(30),
|
||||
child: Container(
|
||||
width: Screen.width(context),
|
||||
height: Screen.setHeight(40),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConfig.WhiteBackColor,
|
||||
border: Border(
|
||||
bottom: BorderSide(color: ColorConfig.LineColor, width: 1),
|
||||
),
|
||||
),
|
||||
child: TabBar(
|
||||
unselectedLabelColor: ColorConfig.TextColor,
|
||||
labelColor: ColorConfig.ThemeColor,
|
||||
indicatorColor: ColorConfig.ThemeColor,
|
||||
indicatorPadding: EdgeInsets.only(left: 30, right: 30),
|
||||
controller: widget.tabController,
|
||||
tabs: widget.tabValues
|
||||
.asMap()
|
||||
.keys
|
||||
.map(
|
||||
(e) => Tab(
|
||||
child: Text(
|
||||
widget.tabValues[e],
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
final widget;
|
||||
|
||||
_SliverTabBarDelegate(this.widget);
|
||||
|
||||
@override
|
||||
double get minExtent => 40.0;
|
||||
|
||||
@override
|
||||
double get maxExtent => 40.0;
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return widget;
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRebuild(_SliverTabBarDelegate oldDelegate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
236
moehu/moehu_fontend/lib/views/Personal/Setting.dart
Normal file
236
moehu/moehu_fontend/lib/views/Personal/Setting.dart
Normal file
@@ -0,0 +1,236 @@
|
||||
import 'dart:io';
|
||||
|
||||
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/config/Index.dart';
|
||||
import 'package:peach/utils/_.dart';
|
||||
import 'package:peach/widget/CellWidget.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
class Setting extends StatefulWidget {
|
||||
@override
|
||||
_Setting createState() => _Setting();
|
||||
}
|
||||
|
||||
class _Setting extends State<Setting> {
|
||||
String cacheSize = "0.00B";
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
ComputeCache();
|
||||
}
|
||||
|
||||
Future<void> ComputeCache() async {
|
||||
String size = await ClearCache.loadCache();
|
||||
setState(() {
|
||||
cacheSize = size;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0.0,
|
||||
title: Text("设置", style: TextStyle(color: ColorConfig.BlackBackColor),),
|
||||
centerTitle: true,
|
||||
backgroundColor: ColorConfig.WhiteBackColor,
|
||||
leading: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Icon(
|
||||
Icons.arrow_back,
|
||||
color: ColorConfig.BlackBackColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
physics: BouncingScrollPhysics(),
|
||||
child: Container(
|
||||
color: ColorConfig.LineColor,
|
||||
child: Column(
|
||||
children: [
|
||||
CellWidget(
|
||||
leftText: Text("账号设置", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("个人资料", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("安全隐私", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Container(
|
||||
height: 18,
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("推送设置", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("消息设置", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("屏蔽设置", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("清理缓存", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
rightText: Text(cacheSize,style: TextStyle(fontSize: Screen.setFontSize(12),color: Color.fromARGB(87, 0, 0, 0))),
|
||||
onTap: () async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: AlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(Icons.delete),
|
||||
Text("清除缓存")
|
||||
],
|
||||
),
|
||||
content: Container(
|
||||
height: Screen.setHeight(50),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("此操作将删除您的App的所有缓存数据"),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text('取消', style: TextStyle(color: ColorConfig.ThemeColor),),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("清除", style: TextStyle(color: ColorConfig.NoActiveColor),),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
bool status = await ClearCache.clearCache();
|
||||
await ComputeCache();
|
||||
if (status) {
|
||||
Toast.show("清除成功", context, duration: Toast.LENGTH_SHORT, gravity: Toast.BOTTOM);
|
||||
}
|
||||
}
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("其他设置", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Container(
|
||||
height: 18,
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("意见反馈", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
onTap: () {
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Divider(height: 1),
|
||||
CellWidget(
|
||||
leftText: Text("检查更新", style: TextStyle(fontSize: Screen.setFontSize(14),color: ColorConfig.TextColor)),
|
||||
rightText: Text("v"+Config.packageInfo.version,style: TextStyle(fontSize: Screen.setFontSize(12),color: Color.fromARGB(87, 0, 0, 0))),
|
||||
onTap: () async {
|
||||
bool status = await CheckUpdate().check(context);
|
||||
if (!status) {
|
||||
Toast.show("已是最新版", context, duration: Toast.LENGTH_SHORT, gravity: Toast.BOTTOM);
|
||||
}
|
||||
// Modular.to.pushNamed('');
|
||||
},
|
||||
),
|
||||
Container(
|
||||
height: 18,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: AlertDialog(
|
||||
title: Text("退出登录"),
|
||||
content: Container(
|
||||
height: Screen.setHeight(40),
|
||||
child: Column(
|
||||
children: [
|
||||
Text("退出后无法再接受到好友消息,您确定退出此次登录吗?"),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
FlatButton(
|
||||
child: Text('取消', style: TextStyle(color: ColorConfig.ThemeColor),),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("确定", style: TextStyle(color: ColorConfig.NoActiveColor),),
|
||||
onPressed: () async {
|
||||
await SPreferences().setBool("isLogin", false);
|
||||
Modular.to.pushReplacementNamed('/signUp');
|
||||
}
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: 48,
|
||||
alignment: Alignment.center,
|
||||
color: ColorConfig.WhiteBackColor,
|
||||
width: Screen.width(context),
|
||||
child: Text("退出登录", style: TextStyle(fontSize: Screen.setFontSize(15)),),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user