feat: 我的&媒体页面合并
This commit is contained in:
@ -1,8 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pilipala/pages/mine/index.dart';
|
||||||
import '../../pages/dynamics/index.dart';
|
import '../../pages/dynamics/index.dart';
|
||||||
import '../../pages/home/index.dart';
|
import '../../pages/home/index.dart';
|
||||||
import '../../pages/media/index.dart';
|
|
||||||
import '../../pages/rank/index.dart';
|
import '../../pages/rank/index.dart';
|
||||||
|
|
||||||
List defaultNavigationBars = [
|
List defaultNavigationBars = [
|
||||||
@ -51,15 +50,15 @@ List defaultNavigationBars = [
|
|||||||
{
|
{
|
||||||
'id': 3,
|
'id': 3,
|
||||||
'icon': const Icon(
|
'icon': const Icon(
|
||||||
Icons.video_collection_outlined,
|
Icons.person_outline,
|
||||||
size: 20,
|
size: 20,
|
||||||
),
|
),
|
||||||
'selectIcon': const Icon(
|
'selectIcon': const Icon(
|
||||||
Icons.video_collection,
|
Icons.person,
|
||||||
size: 21,
|
size: 21,
|
||||||
),
|
),
|
||||||
'label': "媒体库",
|
'label': "我的",
|
||||||
'count': 0,
|
'count': 0,
|
||||||
'page': const MediaPage(),
|
'page': const MinePage(),
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/pages/mine/index.dart';
|
import 'package:pilipala/pages/main/index.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import './controller.dart';
|
import './controller.dart';
|
||||||
|
|
||||||
@ -19,6 +19,8 @@ class HomePage extends StatefulWidget {
|
|||||||
class _HomePageState extends State<HomePage>
|
class _HomePageState extends State<HomePage>
|
||||||
with AutomaticKeepAliveClientMixin, TickerProviderStateMixin {
|
with AutomaticKeepAliveClientMixin, TickerProviderStateMixin {
|
||||||
final HomeController _homeController = Get.put(HomeController());
|
final HomeController _homeController = Get.put(HomeController());
|
||||||
|
final MainController mainController = Get.put(MainController());
|
||||||
|
|
||||||
List videoList = [];
|
List videoList = [];
|
||||||
late Stream<bool> stream;
|
late Stream<bool> stream;
|
||||||
|
|
||||||
@ -33,15 +35,14 @@ class _HomePageState extends State<HomePage>
|
|||||||
|
|
||||||
showUserBottomSheet() {
|
showUserBottomSheet() {
|
||||||
feedBack();
|
feedBack();
|
||||||
showModalBottomSheet(
|
final MainController mainController = Get.put(MainController());
|
||||||
context: context,
|
if (mainController.navigationBars
|
||||||
builder: (_) => const SizedBox(
|
.where((item) => item['label'] == "我的")
|
||||||
height: 450,
|
.isNotEmpty) {
|
||||||
child: MinePage(),
|
mainController.pageController.jumpToPage(2);
|
||||||
),
|
} else {
|
||||||
clipBehavior: Clip.hardEdge,
|
Get.toNamed('/mine');
|
||||||
isScrollControlled: true,
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/pages/mine/view.dart';
|
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
@ -54,19 +53,9 @@ class HomeAppBar extends StatelessWidget {
|
|||||||
// icon: const Icon(CupertinoIcons.bell, size: 22),
|
// icon: const Icon(CupertinoIcons.bell, size: 22),
|
||||||
// ),
|
// ),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
|
|
||||||
/// TODO
|
|
||||||
if (userInfo != null) ...[
|
if (userInfo != null) ...[
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => showModalBottomSheet(
|
onTap: () => Get.toNamed('/mine'),
|
||||||
context: context,
|
|
||||||
builder: (_) => const SizedBox(
|
|
||||||
height: 450,
|
|
||||||
child: MinePage(),
|
|
||||||
),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
isScrollControlled: true,
|
|
||||||
),
|
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
type: 'avatar',
|
type: 'avatar',
|
||||||
width: 32,
|
width: 32,
|
||||||
@ -77,15 +66,7 @@ class HomeAppBar extends StatelessWidget {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
] else ...[
|
] else ...[
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => showModalBottomSheet(
|
onPressed: () => Get.toNamed('/mine'),
|
||||||
context: context,
|
|
||||||
builder: (_) => const SizedBox(
|
|
||||||
height: 450,
|
|
||||||
child: MinePage(),
|
|
||||||
),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
isScrollControlled: true,
|
|
||||||
),
|
|
||||||
icon: const Icon(CupertinoIcons.person, size: 22),
|
icon: const Icon(CupertinoIcons.person, size: 22),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:pilipala/models/common/dynamic_badge_mode.dart';
|
import 'package:pilipala/models/common/dynamic_badge_mode.dart';
|
||||||
import 'package:pilipala/pages/dynamics/index.dart';
|
import 'package:pilipala/pages/dynamics/index.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/pages/home/index.dart';
|
||||||
import 'package:pilipala/pages/media/index.dart';
|
import 'package:pilipala/pages/mine/index.dart';
|
||||||
import 'package:pilipala/pages/rank/index.dart';
|
import 'package:pilipala/pages/rank/index.dart';
|
||||||
import 'package:pilipala/utils/event_bus.dart';
|
import 'package:pilipala/utils/event_bus.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
@ -25,7 +25,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
final HomeController _homeController = Get.put(HomeController());
|
final HomeController _homeController = Get.put(HomeController());
|
||||||
final RankController _rankController = Get.put(RankController());
|
final RankController _rankController = Get.put(RankController());
|
||||||
final DynamicsController _dynamicController = Get.put(DynamicsController());
|
final DynamicsController _dynamicController = Get.put(DynamicsController());
|
||||||
final MediaController _mediaController = Get.put(MediaController());
|
final MineController _mineController = Get.put(MineController());
|
||||||
|
|
||||||
int? _lastSelectTime; //上次点击时间
|
int? _lastSelectTime; //上次点击时间
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@ -90,8 +90,9 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
_dynamicController.flag = false;
|
_dynamicController.flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPage is MediaPage) {
|
if (currentPage is MinePage) {
|
||||||
_mediaController.queryFavFolder();
|
_mineController.queryFavFolder();
|
||||||
|
_mineController.queryUserInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,65 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:pilipala/http/user.dart';
|
|
||||||
import 'package:pilipala/models/user/fav_folder.dart';
|
|
||||||
import 'package:pilipala/utils/storage.dart';
|
|
||||||
|
|
||||||
class MediaController extends GetxController {
|
|
||||||
Rx<FavFolderData> favFolderData = FavFolderData().obs;
|
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
|
||||||
RxBool userLogin = false.obs;
|
|
||||||
List list = [
|
|
||||||
{
|
|
||||||
'icon': Icons.file_download_outlined,
|
|
||||||
'title': '离线缓存',
|
|
||||||
'onTap': () {
|
|
||||||
SmartDialog.showToast('功能开发中');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'icon': Icons.history,
|
|
||||||
'title': '观看记录',
|
|
||||||
'onTap': () => Get.toNamed('/history'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'icon': Icons.star_border,
|
|
||||||
'title': '我的收藏',
|
|
||||||
'onTap': () => Get.toNamed('/fav'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'icon': Icons.subscriptions_outlined,
|
|
||||||
'title': '我的订阅',
|
|
||||||
'onTap': () => Get.toNamed('/subscription'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'icon': Icons.watch_later_outlined,
|
|
||||||
'title': '稍后再看',
|
|
||||||
'onTap': () => Get.toNamed('/later'),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
var userInfo;
|
|
||||||
int? mid;
|
|
||||||
final ScrollController scrollController = ScrollController();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onInit() {
|
|
||||||
super.onInit();
|
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
|
||||||
userLogin.value = userInfo != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<dynamic> queryFavFolder() async {
|
|
||||||
if (!userLogin.value) {
|
|
||||||
return {'status': false, 'data': [], 'msg': '未登录'};
|
|
||||||
}
|
|
||||||
var res = await await UserHttp.userfavFolder(
|
|
||||||
pn: 1,
|
|
||||||
ps: 5,
|
|
||||||
mid: mid ?? GStrorage.userInfo.get('userInfoCache').mid,
|
|
||||||
);
|
|
||||||
favFolderData.value = res['data'];
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
library media;
|
|
||||||
|
|
||||||
export './controller.dart';
|
|
||||||
export './view.dart';
|
|
||||||
@ -1,296 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
|
||||||
import 'package:pilipala/models/user/fav_folder.dart';
|
|
||||||
import 'package:pilipala/pages/media/index.dart';
|
|
||||||
import 'package:pilipala/utils/utils.dart';
|
|
||||||
|
|
||||||
class MediaPage extends StatefulWidget {
|
|
||||||
const MediaPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MediaPage> createState() => _MediaPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MediaPageState extends State<MediaPage>
|
|
||||||
with AutomaticKeepAliveClientMixin {
|
|
||||||
late MediaController mediaController;
|
|
||||||
late Future _futureBuilderFuture;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool get wantKeepAlive => true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
mediaController = Get.put(MediaController());
|
|
||||||
_futureBuilderFuture = mediaController.queryFavFolder();
|
|
||||||
mediaController.userLogin.listen((status) {
|
|
||||||
setState(() {
|
|
||||||
_futureBuilderFuture = mediaController.queryFavFolder();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
mediaController.scrollController.removeListener(() {});
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
super.build(context);
|
|
||||||
Color primary = Theme.of(context).colorScheme.primary;
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(toolbarHeight: 30),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
controller: mediaController.scrollController,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
ListTile(
|
|
||||||
leading: null,
|
|
||||||
title: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 20),
|
|
||||||
child: Text(
|
|
||||||
'媒体库',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: Theme.of(context).textTheme.titleLarge!.fontSize,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
for (var i in mediaController.list) ...[
|
|
||||||
ListTile(
|
|
||||||
onTap: () => i['onTap'](),
|
|
||||||
dense: true,
|
|
||||||
leading: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 15),
|
|
||||||
child: Icon(
|
|
||||||
i['icon'],
|
|
||||||
color: primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.only(left: 15, top: 2, bottom: 2),
|
|
||||||
minLeadingWidth: 0,
|
|
||||||
title: Text(
|
|
||||||
i['title'],
|
|
||||||
style: const TextStyle(fontSize: 15),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
Obx(() => mediaController.userLogin.value
|
|
||||||
? favFolder(mediaController, context)
|
|
||||||
: const SizedBox()),
|
|
||||||
SizedBox(
|
|
||||||
height: MediaQuery.of(context).padding.bottom +
|
|
||||||
kBottomNavigationBarHeight,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget favFolder(mediaController, context) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Divider(
|
|
||||||
height: 35,
|
|
||||||
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
onTap: () => Get.toNamed('/fav'),
|
|
||||||
leading: null,
|
|
||||||
dense: true,
|
|
||||||
title: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 10),
|
|
||||||
child: Obx(
|
|
||||||
() => Text.rich(
|
|
||||||
TextSpan(
|
|
||||||
children: [
|
|
||||||
TextSpan(
|
|
||||||
text: '收藏夹 ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize:
|
|
||||||
Theme.of(context).textTheme.titleMedium!.fontSize,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
if (mediaController.favFolderData.value.count != null)
|
|
||||||
TextSpan(
|
|
||||||
text: mediaController.favFolderData.value.count
|
|
||||||
.toString(),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize:
|
|
||||||
Theme.of(context).textTheme.titleSmall!.fontSize,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_futureBuilderFuture = mediaController.queryFavFolder();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.refresh,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// const SizedBox(height: 10),
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
height: MediaQuery.textScalerOf(context).scale(200),
|
|
||||||
child: FutureBuilder(
|
|
||||||
future: _futureBuilderFuture,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
if (snapshot.data == null) {
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
Map data = snapshot.data as Map;
|
|
||||||
if (data['status']) {
|
|
||||||
List favFolderList =
|
|
||||||
mediaController.favFolderData.value.list!;
|
|
||||||
int favFolderCount =
|
|
||||||
mediaController.favFolderData.value.count!;
|
|
||||||
bool flag = favFolderCount > favFolderList.length;
|
|
||||||
return Obx(() => ListView.builder(
|
|
||||||
itemCount:
|
|
||||||
mediaController.favFolderData.value.list!.length +
|
|
||||||
(flag ? 1 : 0),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
if (flag && index == favFolderList.length) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
right: 14, bottom: 35),
|
|
||||||
child: Center(
|
|
||||||
child: IconButton(
|
|
||||||
style: ButtonStyle(
|
|
||||||
padding: MaterialStateProperty.all(
|
|
||||||
EdgeInsets.zero),
|
|
||||||
backgroundColor:
|
|
||||||
MaterialStateProperty.resolveWith(
|
|
||||||
(states) {
|
|
||||||
return Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primaryContainer
|
|
||||||
.withOpacity(0.5);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
onPressed: () => Get.toNamed('/fav'),
|
|
||||||
icon: Icon(
|
|
||||||
Icons.arrow_forward_ios,
|
|
||||||
size: 18,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
return FavFolderItem(
|
|
||||||
item: mediaController
|
|
||||||
.favFolderData.value.list![index],
|
|
||||||
index: index);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
return SizedBox(
|
|
||||||
height: 160,
|
|
||||||
child: Center(child: Text(data['msg'])),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 骨架屏
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FavFolderItem extends StatelessWidget {
|
|
||||||
const FavFolderItem({super.key, this.item, this.index});
|
|
||||||
final FavFolderItemData? item;
|
|
||||||
final int? index;
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
String heroTag = Utils.makeHeroTag(item!.fid);
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: 14),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () => Get.toNamed('/favDetail', arguments: item, parameters: {
|
|
||||||
'mediaId': item!.id.toString(),
|
|
||||||
'heroTag': heroTag,
|
|
||||||
'isOwner': '1',
|
|
||||||
}),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Container(
|
|
||||||
width: 180,
|
|
||||||
height: 110,
|
|
||||||
margin: const EdgeInsets.only(bottom: 8),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
|
||||||
offset: const Offset(4, -12), // 阴影与容器的距离
|
|
||||||
blurRadius: 0.0, // 高斯的标准偏差与盒子的形状卷积。
|
|
||||||
spreadRadius: 0.0, // 在应用模糊之前,框应该膨胀的量。
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, BoxConstraints box) {
|
|
||||||
return Hero(
|
|
||||||
tag: heroTag,
|
|
||||||
child: NetworkImgLayer(
|
|
||||||
src: item!.cover,
|
|
||||||
width: box.maxWidth,
|
|
||||||
height: box.maxHeight,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
' ${item!.title}',
|
|
||||||
overflow: TextOverflow.fade,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
' 共${item!.mediaCount}条视频',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.labelSmall!
|
|
||||||
.copyWith(color: Theme.of(context).colorScheme.outline),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,22 +4,45 @@ import 'package:get/get.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/models/common/theme_type.dart';
|
import 'package:pilipala/models/common/theme_type.dart';
|
||||||
|
import 'package:pilipala/models/user/fav_folder.dart';
|
||||||
import 'package:pilipala/models/user/info.dart';
|
import 'package:pilipala/models/user/info.dart';
|
||||||
import 'package:pilipala/models/user/stat.dart';
|
import 'package:pilipala/models/user/stat.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
class MineController extends GetxController {
|
class MineController extends GetxController {
|
||||||
// 用户信息 头像、昵称、lv
|
RxBool userLogin = false.obs;
|
||||||
Rx<UserInfoData> userInfo = UserInfoData().obs;
|
|
||||||
// 用户状态 动态、关注、粉丝
|
// 用户状态 动态、关注、粉丝
|
||||||
Rx<UserStat> userStat = UserStat().obs;
|
Rx<UserStat> userStat = UserStat().obs;
|
||||||
RxBool userLogin = false.obs;
|
// 用户信息 头像、昵称、lv
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Rx<UserInfoData> userInfo = UserInfoData().obs;
|
||||||
Box setting = GStrorage.setting;
|
|
||||||
Rx<ThemeType> themeType = ThemeType.system.obs;
|
Rx<ThemeType> themeType = ThemeType.system.obs;
|
||||||
|
Rx<FavFolderData> favFolderData = FavFolderData().obs;
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
|
List menuList = [
|
||||||
|
{
|
||||||
|
'icon': Icons.history,
|
||||||
|
'title': '观看记录',
|
||||||
|
'onTap': () => Get.toNamed('/history'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'icon': Icons.star_border,
|
||||||
|
'title': '我的收藏',
|
||||||
|
'onTap': () => Get.toNamed('/fav'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'icon': Icons.subscriptions_outlined,
|
||||||
|
'title': '我的订阅',
|
||||||
|
'onTap': () => Get.toNamed('/subscription'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'icon': Icons.watch_later_outlined,
|
||||||
|
'title': '稍后再看',
|
||||||
|
'onTap': () => Get.toNamed('/later'),
|
||||||
|
},
|
||||||
|
];
|
||||||
@override
|
@override
|
||||||
onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
|
||||||
if (userInfoCache.get('userInfoCache') != null) {
|
if (userInfoCache.get('userInfoCache') != null) {
|
||||||
@ -109,7 +132,10 @@ class MineController extends GetxController {
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Get.toNamed('/follow?mid=${userInfo.value.mid}', preventDuplicates: false);
|
Get.toNamed(
|
||||||
|
'/follow?mid=${userInfo.value.mid}',
|
||||||
|
preventDuplicates: false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushFans() {
|
pushFans() {
|
||||||
@ -117,7 +143,10 @@ class MineController extends GetxController {
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Get.toNamed('/fan?mid=${userInfo.value.mid}', preventDuplicates: false);
|
Get.toNamed(
|
||||||
|
'/fan?mid=${userInfo.value.mid}',
|
||||||
|
preventDuplicates: false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushDynamic() {
|
pushDynamic() {
|
||||||
@ -125,7 +154,22 @@ class MineController extends GetxController {
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Get.toNamed('/memberDynamics?mid=${userInfo.value.mid}',
|
Get.toNamed(
|
||||||
preventDuplicates: false);
|
'/memberDynamics?mid=${userInfo.value.mid}',
|
||||||
|
preventDuplicates: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<dynamic> queryFavFolder() async {
|
||||||
|
if (!userLogin.value) {
|
||||||
|
return {'status': false, 'data': [], 'msg': '未登录'};
|
||||||
|
}
|
||||||
|
var res = await await UserHttp.userfavFolder(
|
||||||
|
pn: 1,
|
||||||
|
ps: 5,
|
||||||
|
mid: userInfo.value.mid!,
|
||||||
|
);
|
||||||
|
favFolderData.value = res['data'];
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
// ignore_for_file: no_leading_underscores_for_local_identifiers
|
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/models/common/theme_type.dart';
|
import 'package:pilipala/models/user/fav_folder.dart';
|
||||||
import 'package:pilipala/models/user/info.dart';
|
import 'package:pilipala/models/user/info.dart';
|
||||||
|
import 'package:pilipala/models/user/stat.dart';
|
||||||
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class MinePage extends StatefulWidget {
|
class MinePage extends StatefulWidget {
|
||||||
@ -16,19 +16,23 @@ class MinePage extends StatefulWidget {
|
|||||||
State<MinePage> createState() => _MinePageState();
|
State<MinePage> createState() => _MinePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MinePageState extends State<MinePage> {
|
class _MinePageState extends State<MinePage>
|
||||||
final MineController mineController = Get.put(MineController());
|
with AutomaticKeepAliveClientMixin {
|
||||||
|
final MineController ctr = Get.put(MineController());
|
||||||
late Future _futureBuilderFuture;
|
late Future _futureBuilderFuture;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_futureBuilderFuture = mineController.queryUserInfo();
|
_futureBuilderFuture = ctr.queryUserInfo();
|
||||||
|
ctr.queryFavFolder();
|
||||||
mineController.userLogin.listen((status) {
|
ctr.userLogin.listen((status) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_futureBuilderFuture = mineController.queryUserInfo();
|
_futureBuilderFuture = ctr.queryUserInfo();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -36,50 +40,25 @@ class _MinePageState extends State<MinePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
super.build(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
scrolledUnderElevation: 0,
|
|
||||||
elevation: 0,
|
|
||||||
toolbarHeight: kTextTabBarHeight + 20,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
centerTitle: false,
|
|
||||||
title: const Text(
|
|
||||||
'PLPL',
|
|
||||||
style: TextStyle(
|
|
||||||
height: 2.8,
|
|
||||||
fontSize: 17,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontFamily: 'Jura-Bold',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => mineController.onChangeTheme(),
|
icon: const Icon(Icons.dark_mode_outlined),
|
||||||
icon: Icon(
|
onPressed: () => ctr.onChangeTheme(),
|
||||||
mineController.themeType.value == ThemeType.dark
|
|
||||||
? CupertinoIcons.sun_max
|
|
||||||
: CupertinoIcons.moon,
|
|
||||||
size: 22,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
icon: const Icon(Icons.settings_outlined),
|
||||||
onPressed: () => Get.toNamed('/setting', preventDuplicates: false),
|
onPressed: () => Get.toNamed('/setting', preventDuplicates: false),
|
||||||
icon: const Icon(
|
|
||||||
CupertinoIcons.slider_horizontal_3,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 22),
|
||||||
const SizedBox(width: 10),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: LayoutBuilder(
|
body: SingleChildScrollView(
|
||||||
builder: (context, constraint) {
|
|
||||||
return SingleChildScrollView(
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
child: SizedBox(
|
|
||||||
height: constraint.maxHeight,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
Obx(() => _buildProfileSection(context, ctr.userInfo.value)),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
@ -90,141 +69,125 @@ class _MinePageState extends State<MinePage> {
|
|||||||
}
|
}
|
||||||
if (snapshot.data['status']) {
|
if (snapshot.data['status']) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => userInfoBuild(mineController, context));
|
() => _buildStatsSection(
|
||||||
} else {
|
context,
|
||||||
return userInfoBuild(mineController, context);
|
ctr.userStat.value,
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return userInfoBuild(mineController, context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return _buildStatsSection(
|
||||||
|
context,
|
||||||
|
ctr.userStat.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return _buildStatsSection(
|
||||||
|
context,
|
||||||
|
ctr.userStat.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
_buildMenuSection(context),
|
||||||
|
Divider(
|
||||||
|
height: 25,
|
||||||
|
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
||||||
|
),
|
||||||
|
Obx(
|
||||||
|
() => ctr.userLogin.value
|
||||||
|
? _buildFavoritesSection(context)
|
||||||
|
: const SizedBox(),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).padding.bottom +
|
||||||
|
kBottomNavigationBarHeight,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget userInfoBuild(_mineController, context) {
|
Widget _buildProfileSection(BuildContext context, UserInfoData userInfo) {
|
||||||
return Column(
|
return InkWell(
|
||||||
|
onTap: () => ctr.onLogin(),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(24, 10, 30, 10),
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 5),
|
userInfo.face != null
|
||||||
GestureDetector(
|
? NetworkImgLayer(
|
||||||
onTap: () => _mineController.onLogin(),
|
src: userInfo.face,
|
||||||
child: ClipOval(
|
|
||||||
child: Container(
|
|
||||||
width: 85,
|
width: 85,
|
||||||
height: 85,
|
height: 85,
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
type: 'avatar',
|
||||||
child: Center(
|
)
|
||||||
child: _mineController.userInfo.value.face != null
|
: ClipOval(
|
||||||
? NetworkImgLayer(
|
child: SizedBox(
|
||||||
src: _mineController.userInfo.value.face,
|
|
||||||
width: 85,
|
width: 85,
|
||||||
height: 85)
|
height: 85,
|
||||||
: Image.asset('assets/images/noface.jpeg'),
|
child: Image.asset('assets/images/noface.jpeg'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 12),
|
||||||
),
|
Column(
|
||||||
const SizedBox(height: 10),
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
_mineController.userInfo.value.uname ?? '点击头像登录',
|
userInfo.uname ?? '去登录',
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
maxLines: 1,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
const SizedBox(width: 4),
|
|
||||||
Image.asset(
|
|
||||||
'assets/images/lv/lv${_mineController.userInfo.value.levelInfo != null ? _mineController.userInfo.value.levelInfo!.currentLevel : '0'}.png',
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 5),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text.rich(TextSpan(children: [
|
|
||||||
TextSpan(
|
|
||||||
text: '硬币: ',
|
|
||||||
style:
|
|
||||||
TextStyle(color: Theme.of(context).colorScheme.outline)),
|
|
||||||
TextSpan(
|
|
||||||
text: (_mineController.userInfo.value.money ?? 'pilipala')
|
|
||||||
.toString(),
|
|
||||||
style:
|
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary)),
|
|
||||||
]))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
if (_mineController.userInfo.value.levelInfo != null) ...[
|
|
||||||
LayoutBuilder(
|
|
||||||
builder: (context, BoxConstraints box) {
|
|
||||||
LevelInfo levelInfo = _mineController.userInfo.value.levelInfo;
|
|
||||||
return SizedBox(
|
|
||||||
width: box.maxWidth,
|
|
||||||
height: 24,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Positioned(
|
|
||||||
top: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: Container(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
height: 24,
|
|
||||||
constraints:
|
|
||||||
const BoxConstraints(minWidth: 100), // 设置最小宽度为100
|
|
||||||
width: box.maxWidth *
|
|
||||||
(1 - (levelInfo.currentExp! / levelInfo.nextExp!)),
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
'${levelInfo.currentExp!}/${levelInfo.nextExp!}',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onPrimary,
|
fontSize: 17,
|
||||||
fontSize: 12,
|
fontWeight: FontWeight.bold,
|
||||||
|
color: userInfo.vipStatus == 1
|
||||||
|
? const Color.fromARGB(255, 251, 100, 163)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/lv/lv${userInfo.levelInfo != null ? userInfo.levelInfo!.currentLevel : '0'}.png',
|
||||||
|
height: 12,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
if (userInfo.vipType != 0 && userInfo.vipStatus == 1) ...[
|
||||||
|
Image.network(
|
||||||
|
userInfo.vipLabel!['img_label_uri_hans_static'],
|
||||||
|
height: 22,
|
||||||
),
|
),
|
||||||
Positioned(
|
const SizedBox(height: 2),
|
||||||
top: 23,
|
],
|
||||||
left: 0,
|
Text(
|
||||||
bottom: 0,
|
'硬币: ${userInfo.money ?? '-'}',
|
||||||
child: Container(
|
style: TextStyle(
|
||||||
width: box.maxWidth *
|
color: Theme.of(context).colorScheme.outline,
|
||||||
(_mineController
|
|
||||||
.userInfo.value.levelInfo!.currentExp! /
|
|
||||||
_mineController
|
|
||||||
.userInfo.value.levelInfo!.nextExp!),
|
|
||||||
height: 1,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Icon(
|
||||||
|
Icons.keyboard_arrow_right_rounded,
|
||||||
|
size: 28,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
),
|
|
||||||
],
|
Widget _buildStatsSection(BuildContext context, UserStat userStat) {
|
||||||
const SizedBox(height: 30),
|
return Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.only(left: 30, right: 30),
|
||||||
padding: const EdgeInsets.only(left: 12, right: 12),
|
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
TextStyle style = TextStyle(
|
|
||||||
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
fontWeight: FontWeight.bold);
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: constraints.maxWidth / 3 * 0.6,
|
height: constraints.maxWidth / 3 * 0.6,
|
||||||
child: GridView.count(
|
child: GridView.count(
|
||||||
@ -233,134 +196,313 @@ class _MinePageState extends State<MinePage> {
|
|||||||
crossAxisCount: 3,
|
crossAxisCount: 3,
|
||||||
childAspectRatio: 1.67,
|
childAspectRatio: 1.67,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
InkWell(
|
_buildStatItem(
|
||||||
onTap: () => _mineController.pushDynamic(),
|
context,
|
||||||
borderRadius: StyleString.mdRadius,
|
(userStat.dynamicCount ?? '-').toString(),
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 400),
|
|
||||||
transitionBuilder:
|
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
(_mineController.userStat.value.dynamicCount ??
|
|
||||||
'-')
|
|
||||||
.toString(),
|
|
||||||
key: ValueKey<String>(_mineController
|
|
||||||
.userStat.value.dynamicCount
|
|
||||||
.toString()),
|
|
||||||
style: style),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
'动态',
|
'动态',
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
ctr.pushDynamic,
|
||||||
),
|
),
|
||||||
],
|
_buildStatItem(
|
||||||
),
|
context,
|
||||||
),
|
(userStat.following ?? '-').toString(),
|
||||||
InkWell(
|
|
||||||
onTap: () => _mineController.pushFollow(),
|
|
||||||
borderRadius: StyleString.mdRadius,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 400),
|
|
||||||
transitionBuilder:
|
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
(_mineController.userStat.value.following ??
|
|
||||||
'-')
|
|
||||||
.toString(),
|
|
||||||
key: ValueKey<String>(_mineController
|
|
||||||
.userStat.value.following
|
|
||||||
.toString()),
|
|
||||||
style: style),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
'关注',
|
'关注',
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
ctr.pushFollow,
|
||||||
|
),
|
||||||
|
_buildStatItem(
|
||||||
|
context,
|
||||||
|
(userStat.follower ?? '-').toString(),
|
||||||
|
'粉丝',
|
||||||
|
ctr.pushFans,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
InkWell(
|
);
|
||||||
onTap: () => _mineController.pushFans(),
|
}
|
||||||
|
|
||||||
|
Widget _buildStatItem(
|
||||||
|
BuildContext context,
|
||||||
|
String count,
|
||||||
|
String label,
|
||||||
|
Function onTap,
|
||||||
|
) {
|
||||||
|
TextStyle style = TextStyle(
|
||||||
|
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
||||||
|
fontWeight: FontWeight.bold);
|
||||||
|
return InkWell(
|
||||||
|
onTap: () => onTap(),
|
||||||
|
// onTap: () {},
|
||||||
borderRadius: StyleString.mdRadius,
|
borderRadius: StyleString.mdRadius,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
AnimatedSwitcher(
|
Text(count, style: style),
|
||||||
duration: const Duration(milliseconds: 400),
|
const SizedBox(height: 2),
|
||||||
transitionBuilder:
|
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
(_mineController.userStat.value.follower ?? '-')
|
|
||||||
.toString(),
|
|
||||||
key: ValueKey<String>(_mineController
|
|
||||||
.userStat.value.follower
|
|
||||||
.toString()),
|
|
||||||
style: style),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
Text(
|
||||||
'粉丝',
|
label,
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
||||||
),
|
color: Theme.of(context).colorScheme.outline,
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMenuSection(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
|
return SizedBox(
|
||||||
|
height: constraints.maxWidth / 4 * 0.85,
|
||||||
|
child: GridView.count(
|
||||||
|
primary: false,
|
||||||
|
crossAxisCount: 4,
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
childAspectRatio: 1.2,
|
||||||
|
children: [
|
||||||
|
...ctr.menuList.map((element) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
if (!ctr.userLogin.value) {
|
||||||
|
SmartDialog.showToast('账号未登录');
|
||||||
|
} else {
|
||||||
|
element['onTap']();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
borderRadius: StyleString.mdRadius,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Icon(
|
||||||
|
element['icon'],
|
||||||
|
size: 21,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(element['title'])
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFavoritesSection(context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
_buildFavoritesTitle(context, 'fav', '收藏夹'),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: MediaQuery.textScalerOf(context).scale(110),
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: ctr.queryFavFolder(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
Map data = snapshot.data as Map;
|
||||||
|
if (data['status']) {
|
||||||
|
List favFolderList = ctr.favFolderData.value.list!;
|
||||||
|
int favFolderCount = ctr.favFolderData.value.count!;
|
||||||
|
bool flag = favFolderCount > favFolderList.length;
|
||||||
|
return Obx(
|
||||||
|
() => ListView.builder(
|
||||||
|
itemCount:
|
||||||
|
ctr.favFolderData.value.list!.length + (flag ? 1 : 0),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (flag && index == favFolderList.length) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 14),
|
||||||
|
child: Center(
|
||||||
|
child: IconButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(
|
||||||
|
EdgeInsets.zero),
|
||||||
|
backgroundColor:
|
||||||
|
MaterialStateProperty.resolveWith(
|
||||||
|
(states) {
|
||||||
|
return Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primaryContainer
|
||||||
|
.withOpacity(0.5);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
onPressed: () => Get.toNamed('/fav'),
|
||||||
|
icon: Icon(
|
||||||
|
Icons.arrow_forward_ios,
|
||||||
|
size: 18,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return FavFolderItem(
|
||||||
|
item: ctr.favFolderData.value.list![index],
|
||||||
|
index: index,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return SizedBox(
|
||||||
|
height: 110,
|
||||||
|
child: Center(child: Text(data['msg'])),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 骨架屏
|
||||||
|
return Obx(
|
||||||
|
() => ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: ctr.favFolderData.value.list!.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return FavFolderItem(
|
||||||
|
item: ctr.favFolderData.value.list![index],
|
||||||
|
index: index,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildFavoritesTitle(
|
||||||
|
BuildContext context,
|
||||||
|
String type,
|
||||||
|
String title,
|
||||||
|
) {
|
||||||
|
return ListTile(
|
||||||
|
onTap: () {},
|
||||||
|
leading: null,
|
||||||
|
dense: true,
|
||||||
|
title: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 10),
|
||||||
|
child: Text.rich(
|
||||||
|
TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const TextSpan(text: ' '),
|
||||||
|
TextSpan(
|
||||||
|
text: '20',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// trailing: IconButton(
|
||||||
|
// onPressed: () {},
|
||||||
|
// icon: const Icon(
|
||||||
|
// Icons.refresh,
|
||||||
|
// size: 20,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ActionItem extends StatelessWidget {
|
class FavFolderItem extends StatelessWidget {
|
||||||
final Icon? icon;
|
const FavFolderItem({super.key, this.item, this.index});
|
||||||
final Function? onTap;
|
final FavFolderItemData? item;
|
||||||
final String? text;
|
final int? index;
|
||||||
|
|
||||||
const ActionItem({
|
|
||||||
Key? key,
|
|
||||||
this.icon,
|
|
||||||
this.onTap,
|
|
||||||
this.text,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
String heroTag = Utils.makeHeroTag(item!.fid);
|
||||||
onTap: () {},
|
return Container(
|
||||||
|
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: 14),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => Get.toNamed('/favDetail', arguments: item, parameters: {
|
||||||
|
'mediaId': item!.id.toString(),
|
||||||
|
'heroTag': heroTag,
|
||||||
|
'isOwner': '1',
|
||||||
|
}),
|
||||||
borderRadius: StyleString.mdRadius,
|
borderRadius: StyleString.mdRadius,
|
||||||
child: Column(
|
child: Stack(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Icon(icon!.icon!),
|
NetworkImgLayer(
|
||||||
const SizedBox(height: 8),
|
src: item!.cover,
|
||||||
Text(
|
width: 175,
|
||||||
text!,
|
height: 110,
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
),
|
||||||
|
// 渐变
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
top: 60,
|
||||||
|
bottom: 0,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.only(bottom: 8, left: 10, right: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: StyleString.mdRadius,
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [
|
||||||
|
Colors.black.withOpacity(0),
|
||||||
|
Colors.black.withOpacity(0.6),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
RichText(
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
text: TextSpan(
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleSmall!
|
||||||
|
.copyWith(color: Colors.white),
|
||||||
|
children: [
|
||||||
|
TextSpan(text: item!.title!),
|
||||||
|
const TextSpan(text: ' '),
|
||||||
|
if (item!.mediaCount! > 0)
|
||||||
|
TextSpan(
|
||||||
|
text: item!.mediaCount!.toString(),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/models/common/tab_type.dart';
|
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
import '../../../models/common/nav_bar_config.dart';
|
import '../../../models/common/nav_bar_config.dart';
|
||||||
@ -23,7 +22,7 @@ class _NavigationbarSetPageState extends State<NavigationBarSetPage> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
defaultNavTabs = defaultNavigationBars;
|
defaultNavTabs = defaultNavigationBars;
|
||||||
navBarSort = settingStorage
|
navBarSort = settingStorage
|
||||||
.get(SettingBoxKey.navBarSort, defaultValue: [0, 1, 2, 3]);
|
.get(SettingBoxKey.navBarSort, defaultValue: [0, 1, 2, 3, 4]);
|
||||||
// 对 tabData 进行排序
|
// 对 tabData 进行排序
|
||||||
defaultNavTabs.sort((a, b) {
|
defaultNavTabs.sort((a, b) {
|
||||||
int indexA = navBarSort.indexOf(a['id']);
|
int indexA = navBarSort.indexOf(a['id']);
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:pilipala/http/init.dart';
|
import 'package:pilipala/http/init.dart';
|
||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/pages/home/index.dart';
|
||||||
import 'package:pilipala/pages/media/index.dart';
|
|
||||||
import 'package:pilipala/utils/cookie.dart';
|
import 'package:pilipala/utils/cookie.dart';
|
||||||
import 'package:pilipala/utils/event_bus.dart';
|
import 'package:pilipala/utils/event_bus.dart';
|
||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import 'package:pilipala/pages/message/at/index.dart';
|
|||||||
import 'package:pilipala/pages/message/like/index.dart';
|
import 'package:pilipala/pages/message/like/index.dart';
|
||||||
import 'package:pilipala/pages/message/reply/index.dart';
|
import 'package:pilipala/pages/message/reply/index.dart';
|
||||||
import 'package:pilipala/pages/message/system/index.dart';
|
import 'package:pilipala/pages/message/system/index.dart';
|
||||||
|
import 'package:pilipala/pages/mine/index.dart';
|
||||||
import 'package:pilipala/pages/setting/pages/logs.dart';
|
import 'package:pilipala/pages/setting/pages/logs.dart';
|
||||||
|
|
||||||
import '../pages/about/index.dart';
|
import '../pages/about/index.dart';
|
||||||
@ -27,7 +28,6 @@ import '../pages/html/index.dart';
|
|||||||
import '../pages/later/index.dart';
|
import '../pages/later/index.dart';
|
||||||
import '../pages/live_room/view.dart';
|
import '../pages/live_room/view.dart';
|
||||||
import '../pages/login/index.dart';
|
import '../pages/login/index.dart';
|
||||||
import '../pages/media/index.dart';
|
|
||||||
import '../pages/member/index.dart';
|
import '../pages/member/index.dart';
|
||||||
import '../pages/member_archive/index.dart';
|
import '../pages/member_archive/index.dart';
|
||||||
import '../pages/member_coin/index.dart';
|
import '../pages/member_coin/index.dart';
|
||||||
@ -75,8 +75,6 @@ class Routes {
|
|||||||
// 设置
|
// 设置
|
||||||
CustomGetPage(name: '/setting', page: () => const SettingPage()),
|
CustomGetPage(name: '/setting', page: () => const SettingPage()),
|
||||||
//
|
//
|
||||||
CustomGetPage(name: '/media', page: () => const MediaPage()),
|
|
||||||
//
|
|
||||||
CustomGetPage(name: '/fav', page: () => const FavPage()),
|
CustomGetPage(name: '/fav', page: () => const FavPage()),
|
||||||
//
|
//
|
||||||
CustomGetPage(name: '/favDetail', page: () => const FavDetailPage()),
|
CustomGetPage(name: '/favDetail', page: () => const FavDetailPage()),
|
||||||
@ -183,6 +181,8 @@ class Routes {
|
|||||||
// 系统通知
|
// 系统通知
|
||||||
CustomGetPage(
|
CustomGetPage(
|
||||||
name: '/messageSystem', page: () => const MessageSystemPage()),
|
name: '/messageSystem', page: () => const MessageSystemPage()),
|
||||||
|
// 我的
|
||||||
|
CustomGetPage(name: '/mine', page: () => const MinePage()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/pages/dynamics/index.dart';
|
import 'package:pilipala/pages/dynamics/index.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/pages/home/index.dart';
|
||||||
import 'package:pilipala/pages/media/index.dart';
|
|
||||||
import 'package:pilipala/pages/mine/index.dart';
|
import 'package:pilipala/pages/mine/index.dart';
|
||||||
import 'package:pilipala/utils/cookie.dart';
|
import 'package:pilipala/utils/cookie.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
@ -31,9 +30,6 @@ class LoginUtils {
|
|||||||
|
|
||||||
DynamicsController dynamicsCtr = Get.find<DynamicsController>();
|
DynamicsController dynamicsCtr = Get.find<DynamicsController>();
|
||||||
dynamicsCtr.userLogin.value = status;
|
dynamicsCtr.userLogin.value = status;
|
||||||
|
|
||||||
MediaController mediaCtr = Get.find<MediaController>();
|
|
||||||
mediaCtr.userLogin.value = status;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
SmartDialog.showToast('refreshLoginStatus error: ${err.toString()}');
|
SmartDialog.showToast('refreshLoginStatus error: ${err.toString()}');
|
||||||
}
|
}
|
||||||
@ -84,8 +80,6 @@ class LoginUtils {
|
|||||||
final HomeController homeCtr = Get.find<HomeController>();
|
final HomeController homeCtr = Get.find<HomeController>();
|
||||||
homeCtr.updateLoginStatus(true);
|
homeCtr.updateLoginStatus(true);
|
||||||
homeCtr.userFace.value = result['data'].face;
|
homeCtr.userFace.value = result['data'].face;
|
||||||
final MediaController mediaCtr = Get.find<MediaController>();
|
|
||||||
mediaCtr.mid = result['data'].mid;
|
|
||||||
await LoginUtils.refreshLoginStatus(true);
|
await LoginUtils.refreshLoginStatus(true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
SmartDialog.show(builder: (BuildContext context) {
|
SmartDialog.show(builder: (BuildContext context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user