Merge branch 'feature-minePage'
This commit is contained in:
@ -593,6 +593,12 @@ class Api {
|
|||||||
static const String liveRoomEntry =
|
static const String liveRoomEntry =
|
||||||
'${HttpString.liveBaseUrl}/xlive/web-room/v1/index/roomEntryAction';
|
'${HttpString.liveBaseUrl}/xlive/web-room/v1/index/roomEntryAction';
|
||||||
|
|
||||||
|
/// 用户信息
|
||||||
|
static const String accountInfo = '/x/member/web/account';
|
||||||
|
|
||||||
|
/// 更新用户信息
|
||||||
|
static const String updateAccountInfo = '/x/member/web/update';
|
||||||
|
|
||||||
/// 删除评论
|
/// 删除评论
|
||||||
static const String replyDel = '/x/v2/reply/del';
|
static const String replyDel = '/x/v2/reply/del';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:html/parser.dart';
|
import 'package:html/parser.dart';
|
||||||
import 'package:pilipala/models/video/later.dart';
|
import 'package:pilipala/models/video/later.dart';
|
||||||
import '../models/model_hot_video_item.dart';
|
import '../models/model_hot_video_item.dart';
|
||||||
@ -465,4 +467,53 @@ class UserHttp {
|
|||||||
.toList()
|
.toList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future getAccountInfo() async {
|
||||||
|
var res = await Request().get(
|
||||||
|
Api.accountInfo,
|
||||||
|
data: {'web_location': 333.33},
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': res.data['data'],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'data': {},
|
||||||
|
'mag': res.data['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future updateAccountInfo({
|
||||||
|
required String uname,
|
||||||
|
required String sign,
|
||||||
|
required String sex,
|
||||||
|
required String birthday,
|
||||||
|
}) async {
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.updateAccountInfo,
|
||||||
|
data: {
|
||||||
|
'uname': uname,
|
||||||
|
'usersign': sign,
|
||||||
|
'sex': sex,
|
||||||
|
'birthday': birthday,
|
||||||
|
'csrf': await Request.getCsrf(),
|
||||||
|
},
|
||||||
|
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'msg': '更新成功',
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'msg': res.data['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,
|
int mineItemIndex = mainController.navigationBars
|
||||||
builder: (_) => const SizedBox(
|
.indexWhere((item) => item['label'] == "我的");
|
||||||
height: 450,
|
if (mineItemIndex != -1) {
|
||||||
child: MinePage(),
|
mainController.pageController.jumpToPage(mineItemIndex);
|
||||||
),
|
} 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),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/http/common.dart';
|
import 'package:pilipala/http/common.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
@ -25,6 +26,7 @@ class MainController extends GetxController {
|
|||||||
late PageController pageController;
|
late PageController pageController;
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
|
dynamic userInfo;
|
||||||
RxBool userLogin = false.obs;
|
RxBool userLogin = false.obs;
|
||||||
late Rx<DynamicBadgeMode> dynamicBadgeType = DynamicBadgeMode.number.obs;
|
late Rx<DynamicBadgeMode> dynamicBadgeType = DynamicBadgeMode.number.obs;
|
||||||
late bool enableGradientBg;
|
late bool enableGradientBg;
|
||||||
@ -38,7 +40,7 @@ class MainController extends GetxController {
|
|||||||
}
|
}
|
||||||
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: false);
|
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: false);
|
||||||
|
|
||||||
var userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
userLogin.value = userInfo != null;
|
userLogin.value = userInfo != null;
|
||||||
dynamicBadgeType.value = DynamicBadgeMode.values[setting.get(
|
dynamicBadgeType.value = DynamicBadgeMode.values[setting.get(
|
||||||
SettingBoxKey.dynamicBadgeMode,
|
SettingBoxKey.dynamicBadgeMode,
|
||||||
@ -73,12 +75,20 @@ class MainController extends GetxController {
|
|||||||
}
|
}
|
||||||
int dynamicItemIndex =
|
int dynamicItemIndex =
|
||||||
navigationBars.indexWhere((item) => item['label'] == "动态");
|
navigationBars.indexWhere((item) => item['label'] == "动态");
|
||||||
|
int mineItemIndex =
|
||||||
|
navigationBars.indexWhere((item) => item['label'] == "我的");
|
||||||
var res = await CommonHttp.unReadDynamic();
|
var res = await CommonHttp.unReadDynamic();
|
||||||
var data = res['data'];
|
var data = res['data'];
|
||||||
if (dynamicItemIndex != -1) {
|
if (dynamicItemIndex != -1) {
|
||||||
navigationBars[dynamicItemIndex]['count'] =
|
navigationBars[dynamicItemIndex]['count'] =
|
||||||
data == null ? 0 : data.length; // 修改 count 属性为新的值
|
data == null ? 0 : data.length; // 修改 count 属性为新的值
|
||||||
}
|
}
|
||||||
|
if (mineItemIndex != -1 && userInfo != null) {
|
||||||
|
Widget avatar = NetworkImgLayer(
|
||||||
|
width: 28, height: 28, src: userInfo.face, type: 'avatar');
|
||||||
|
navigationBars[mineItemIndex]['icon'] = avatar;
|
||||||
|
navigationBars[mineItemIndex]['selectIcon'] = avatar;
|
||||||
|
}
|
||||||
navigationBars.refresh();
|
navigationBars.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,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';
|
||||||
@ -27,7 +27,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
late HomeController _homeController;
|
late HomeController _homeController;
|
||||||
RankController? _rankController;
|
RankController? _rankController;
|
||||||
late DynamicsController _dynamicController;
|
late DynamicsController _dynamicController;
|
||||||
late MediaController _mediaController;
|
late MineController _mineController;
|
||||||
|
|
||||||
int? _lastSelectTime; //上次点击时间
|
int? _lastSelectTime; //上次点击时间
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@ -93,24 +93,22 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void controllerInit() {
|
void controllerInit() {
|
||||||
_homeController = Get.put(HomeController());
|
_homeController = Get.put(HomeController());
|
||||||
_dynamicController = Get.put(DynamicsController());
|
_dynamicController = Get.put(DynamicsController());
|
||||||
_mediaController = Get.put(MediaController());
|
_mineController = Get.put(MineController());
|
||||||
if (_mainController.pagesIds.contains(1)) {
|
if (_mainController.pagesIds.contains(1)) {
|
||||||
_rankController = Get.put(RankController());
|
_rankController = Get.put(RankController());
|
||||||
}
|
}
|
||||||
if (_mainController.pagesIds.contains(2)) {
|
if (_mainController.pagesIds.contains(2)) {
|
||||||
_dynamicController = Get.put(DynamicsController());
|
_dynamicController = Get.put(DynamicsController());
|
||||||
}
|
}
|
||||||
if (_mainController.pagesIds.contains(3)) {
|
|
||||||
_mediaController = Get.put(MediaController());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -207,20 +205,21 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
destinations: <Widget>[
|
destinations: <Widget>[
|
||||||
..._mainController.navigationBars.map((e) {
|
..._mainController.navigationBars.map((e) {
|
||||||
return NavigationDestination(
|
return NavigationDestination(
|
||||||
icon: Badge(
|
icon: _mainController
|
||||||
label: _mainController
|
.dynamicBadgeType.value ==
|
||||||
.dynamicBadgeType.value ==
|
DynamicBadgeMode.number
|
||||||
DynamicBadgeMode.number
|
? Badge(
|
||||||
? Text(e['count'].toString())
|
label: Text(e['count'].toString()),
|
||||||
: null,
|
padding: const EdgeInsets.fromLTRB(
|
||||||
padding:
|
6, 0, 6, 0),
|
||||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
isLabelVisible: _mainController
|
||||||
isLabelVisible: _mainController
|
.dynamicBadgeType
|
||||||
.dynamicBadgeType.value !=
|
.value !=
|
||||||
DynamicBadgeMode.hidden &&
|
DynamicBadgeMode.hidden &&
|
||||||
e['count'] > 0,
|
e['count'] > 0,
|
||||||
child: e['icon'],
|
child: e['icon'],
|
||||||
),
|
)
|
||||||
|
: e['icon'],
|
||||||
selectedIcon: e['selectIcon'],
|
selectedIcon: e['selectIcon'],
|
||||||
label: e['label'],
|
label: e['label'],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -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,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),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +1,9 @@
|
|||||||
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/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/models/live/item.dart';
|
import 'package:pilipala/models/live/item.dart';
|
||||||
import 'package:pilipala/models/member/info.dart';
|
import 'package:pilipala/models/member/info.dart';
|
||||||
|
import 'package:pilipala/plugin/pl_gallery/index.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
class ProfilePanel extends StatelessWidget {
|
class ProfilePanel extends StatelessWidget {
|
||||||
@ -71,11 +71,27 @@ class ProfilePanel extends StatelessWidget {
|
|||||||
tag: ctr.heroTag!,
|
tag: ctr.heroTag!,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
NetworkImgLayer(
|
InkWell(
|
||||||
width: 90,
|
onTap: () {
|
||||||
height: 90,
|
Navigator.of(context).push(
|
||||||
type: 'avatar',
|
HeroDialogRoute<void>(
|
||||||
src: !loadingStatus ? memberInfo.face : ctr.face.value,
|
builder: (BuildContext context) =>
|
||||||
|
InteractiveviewerGallery(
|
||||||
|
sources: [
|
||||||
|
!loadingStatus ? memberInfo.face : ctr.face.value
|
||||||
|
],
|
||||||
|
initIndex: 0,
|
||||||
|
onPageChanged: (int pageIndex) {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: NetworkImgLayer(
|
||||||
|
width: 90,
|
||||||
|
height: 90,
|
||||||
|
type: 'avatar',
|
||||||
|
src: !loadingStatus ? memberInfo.face : ctr.face.value,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (!loadingStatus &&
|
if (!loadingStatus &&
|
||||||
memberInfo.liveRoom != null &&
|
memberInfo.liveRoom != null &&
|
||||||
@ -237,7 +253,7 @@ class ProfilePanel extends StatelessWidget {
|
|||||||
Widget buildEditProfileButton(BuildContext context) {
|
Widget buildEditProfileButton(BuildContext context) {
|
||||||
return TextButton(
|
return TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
SmartDialog.showToast('功能开发中 💪');
|
Get.toNamed('/mineEdit');
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 80),
|
padding: const EdgeInsets.symmetric(horizontal: 80),
|
||||||
|
|||||||
@ -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,13 @@
|
|||||||
// 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/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 +17,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 +41,44 @@ 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,
|
scrolledUnderElevation: 0,
|
||||||
elevation: 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.search_outlined),
|
||||||
icon: Icon(
|
onPressed: () => Get.toNamed('/search'),
|
||||||
mineController.themeType.value == ThemeType.dark
|
|
||||||
? CupertinoIcons.sun_max
|
|
||||||
: CupertinoIcons.moon,
|
|
||||||
size: 22,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => Get.toNamed('/setting', preventDuplicates: false),
|
icon: Icon(
|
||||||
icon: const Icon(
|
ctr.themeType.value == ThemeType.dark
|
||||||
CupertinoIcons.slider_horizontal_3,
|
? Icons.wb_sunny_outlined
|
||||||
|
: Icons.dark_mode_outlined,
|
||||||
),
|
),
|
||||||
|
onPressed: () => ctr.onChangeTheme(),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
IconButton(
|
||||||
|
icon: const Icon(Icons.settings_outlined),
|
||||||
|
onPressed: () => Get.toNamed('/setting', preventDuplicates: false),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 22),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: LayoutBuilder(
|
body: RefreshIndicator(
|
||||||
builder: (context, constraint) {
|
onRefresh: () async {
|
||||||
return SingleChildScrollView(
|
await ctr.queryUserInfo();
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
},
|
||||||
child: SizedBox(
|
child: SingleChildScrollView(
|
||||||
height: constraint.maxHeight,
|
physics: const AlwaysScrollableScrollPhysics(
|
||||||
|
parent: BouncingScrollPhysics()),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 110),
|
||||||
|
child: Expanded(
|
||||||
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,275 +89,424 @@ class _MinePageState extends State<MinePage> {
|
|||||||
}
|
}
|
||||||
if (snapshot.data['status']) {
|
if (snapshot.data['status']) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => userInfoBuild(mineController, context));
|
() => _buildStatsSection(
|
||||||
|
context,
|
||||||
|
ctr.userStat.value,
|
||||||
|
),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return userInfoBuild(mineController, context);
|
return _buildStatsSection(
|
||||||
|
context,
|
||||||
|
ctr.userStat.value,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return userInfoBuild(mineController, context);
|
return _buildStatsSection(
|
||||||
|
context,
|
||||||
|
ctr.userStat.value,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
_buildMenuSection(context),
|
||||||
|
Obx(
|
||||||
|
() => Visibility(
|
||||||
|
visible: ctr.userLogin.value,
|
||||||
|
child: 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 _buildProfileSection(BuildContext context, UserInfoData userInfo) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () => ctr.onLogin(),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(24, 10, 30, 10),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
userInfo.face != null
|
||||||
|
? NetworkImgLayer(
|
||||||
|
src: userInfo.face,
|
||||||
|
width: 85,
|
||||||
|
height: 85,
|
||||||
|
type: 'avatar',
|
||||||
|
)
|
||||||
|
: ClipOval(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 85,
|
||||||
|
height: 85,
|
||||||
|
child: Image.asset('assets/images/noface.jpeg'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
userInfo.uname ?? '去登录',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
],
|
||||||
|
Text.rich(
|
||||||
|
TextSpan(children: [
|
||||||
|
TextSpan(
|
||||||
|
text: '硬币: ',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline)),
|
||||||
|
TextSpan(
|
||||||
|
text: (userInfo.money ?? '-').toString(),
|
||||||
|
style: TextStyle(
|
||||||
|
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) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 30, right: 30),
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
return SizedBox(
|
||||||
|
height: constraints.maxWidth / 3 * 0.6,
|
||||||
|
child: GridView.count(
|
||||||
|
primary: false,
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
crossAxisCount: 3,
|
||||||
|
childAspectRatio: 1.67,
|
||||||
|
children: <Widget>[
|
||||||
|
_buildStatItem(
|
||||||
|
context,
|
||||||
|
(userStat.dynamicCount ?? '-').toString(),
|
||||||
|
'动态',
|
||||||
|
ctr.pushDynamic,
|
||||||
|
),
|
||||||
|
_buildStatItem(
|
||||||
|
context,
|
||||||
|
(userStat.following ?? '-').toString(),
|
||||||
|
'关注',
|
||||||
|
ctr.pushFollow,
|
||||||
|
),
|
||||||
|
_buildStatItem(
|
||||||
|
context,
|
||||||
|
(userStat.follower ?? '-').toString(),
|
||||||
|
'粉丝',
|
||||||
|
ctr.pushFans,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget userInfoBuild(_mineController, context) {
|
Widget _buildStatItem(
|
||||||
return Column(
|
BuildContext context,
|
||||||
children: [
|
String count,
|
||||||
const SizedBox(height: 5),
|
String label,
|
||||||
GestureDetector(
|
Function onTap,
|
||||||
onTap: () => _mineController.onLogin(),
|
) {
|
||||||
child: ClipOval(
|
TextStyle style = TextStyle(
|
||||||
child: Container(
|
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
||||||
width: 85,
|
fontWeight: FontWeight.bold);
|
||||||
height: 85,
|
return InkWell(
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
onTap: () => onTap(),
|
||||||
child: Center(
|
// onTap: () {},
|
||||||
child: _mineController.userInfo.value.face != null
|
borderRadius: StyleString.mdRadius,
|
||||||
? NetworkImgLayer(
|
child: Column(
|
||||||
src: _mineController.userInfo.value.face,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
width: 85,
|
children: [
|
||||||
height: 85)
|
Text(count, style: style),
|
||||||
: Image.asset('assets/images/noface.jpeg'),
|
const SizedBox(height: 2),
|
||||||
),
|
Text(
|
||||||
),
|
label,
|
||||||
),
|
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
||||||
),
|
color: Theme.of(context).colorScheme.outline,
|
||||||
const SizedBox(height: 10),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
_mineController.userInfo.value.uname ?? '点击头像登录',
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
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(
|
|
||||||
color: Theme.of(context).colorScheme.onPrimary,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 23,
|
|
||||||
left: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: Container(
|
|
||||||
width: box.maxWidth *
|
|
||||||
(_mineController
|
|
||||||
.userInfo.value.levelInfo!.currentExp! /
|
|
||||||
_mineController
|
|
||||||
.userInfo.value.levelInfo!.nextExp!),
|
|
||||||
height: 1,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 30),
|
),
|
||||||
Padding(
|
);
|
||||||
padding: const EdgeInsets.only(left: 12, right: 12),
|
}
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
Widget _buildMenuSection(BuildContext context) {
|
||||||
TextStyle style = TextStyle(
|
return Padding(
|
||||||
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||||
color: Theme.of(context).colorScheme.primary,
|
child: LayoutBuilder(
|
||||||
fontWeight: FontWeight.bold);
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: constraints.maxWidth / 3 * 0.6,
|
height: constraints.maxWidth / 4 * 0.85,
|
||||||
child: GridView.count(
|
child: GridView.count(
|
||||||
primary: false,
|
primary: false,
|
||||||
padding: const EdgeInsets.all(0),
|
crossAxisCount: 4,
|
||||||
crossAxisCount: 3,
|
padding: const EdgeInsets.all(0),
|
||||||
childAspectRatio: 1.67,
|
childAspectRatio: 1.2,
|
||||||
children: <Widget>[
|
children: [
|
||||||
InkWell(
|
...ctr.menuList.map((element) {
|
||||||
onTap: () => _mineController.pushDynamic(),
|
return InkWell(
|
||||||
borderRadius: StyleString.mdRadius,
|
onTap: () {
|
||||||
child: Column(
|
if (!ctr.userLogin.value) {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
SmartDialog.showToast('账号未登录');
|
||||||
children: [
|
} else {
|
||||||
AnimatedSwitcher(
|
element['onTap']();
|
||||||
duration: const Duration(milliseconds: 400),
|
}
|
||||||
transitionBuilder:
|
},
|
||||||
(Widget child, Animation<double> animation) {
|
borderRadius: StyleString.mdRadius,
|
||||||
return ScaleTransition(
|
child: Column(
|
||||||
scale: animation, child: child);
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
},
|
children: [
|
||||||
child: Text(
|
Padding(
|
||||||
(_mineController.userStat.value.dynamicCount ??
|
padding: const EdgeInsets.all(10),
|
||||||
'-')
|
child: Icon(
|
||||||
.toString(),
|
element['icon'],
|
||||||
key: ValueKey<String>(_mineController
|
size: 21,
|
||||||
.userStat.value.dynamicCount
|
color: Theme.of(context).colorScheme.primary,
|
||||||
.toString()),
|
|
||||||
style: style),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
),
|
||||||
Text(
|
const SizedBox(height: 4),
|
||||||
'动态',
|
Text(element['title'])
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
],
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
InkWell(
|
);
|
||||||
onTap: () => _mineController.pushFollow(),
|
}).toList(),
|
||||||
borderRadius: StyleString.mdRadius,
|
],
|
||||||
child: Column(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
);
|
||||||
children: [
|
},
|
||||||
AnimatedSwitcher(
|
),
|
||||||
duration: const Duration(milliseconds: 400),
|
);
|
||||||
transitionBuilder:
|
}
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
Widget _buildFavoritesSection(context) {
|
||||||
scale: animation, child: child);
|
return Column(
|
||||||
},
|
children: [
|
||||||
child: Text(
|
_buildFavoritesTitle(context, 'fav', '收藏夹'),
|
||||||
(_mineController.userStat.value.following ??
|
const SizedBox(height: 4),
|
||||||
'-')
|
SizedBox(
|
||||||
.toString(),
|
width: double.infinity,
|
||||||
key: ValueKey<String>(_mineController
|
height: MediaQuery.textScalerOf(context).scale(180),
|
||||||
.userStat.value.following
|
child: FutureBuilder(
|
||||||
.toString()),
|
future: ctr.queryFavFolder(),
|
||||||
style: style),
|
builder: (context, snapshot) {
|
||||||
),
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
const SizedBox(height: 8),
|
Map? data = snapshot.data;
|
||||||
Text(
|
if (data != null && data['status']) {
|
||||||
'关注',
|
List favFolderList = ctr.favFolderData.value.list!;
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
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,
|
||||||
),
|
),
|
||||||
InkWell(
|
);
|
||||||
onTap: () => _mineController.pushFans(),
|
} else {
|
||||||
borderRadius: StyleString.mdRadius,
|
return SizedBox(
|
||||||
child: Column(
|
height: 110,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Center(child: Text(data?['msg'] ?? '')),
|
||||||
children: [
|
);
|
||||||
AnimatedSwitcher(
|
}
|
||||||
duration: const Duration(milliseconds: 400),
|
} else {
|
||||||
transitionBuilder:
|
// 骨架屏
|
||||||
(Widget child, Animation<double> animation) {
|
return Obx(
|
||||||
return ScaleTransition(
|
() => ctr.favFolderData.value.list != null
|
||||||
scale: animation, child: child);
|
? ListView.builder(
|
||||||
},
|
scrollDirection: Axis.horizontal,
|
||||||
child: Text(
|
itemCount: ctr.favFolderData.value.list!.length,
|
||||||
(_mineController.userStat.value.follower ?? '-')
|
itemBuilder: (context, index) {
|
||||||
.toString(),
|
return FavFolderItem(
|
||||||
key: ValueKey<String>(_mineController
|
item: ctr.favFolderData.value.list![index],
|
||||||
.userStat.value.follower
|
index: index,
|
||||||
.toString()),
|
);
|
||||||
style: style),
|
},
|
||||||
),
|
)
|
||||||
const SizedBox(height: 8),
|
: const SizedBox(),
|
||||||
Text(
|
);
|
||||||
'粉丝',
|
}
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildFavoritesTitle(
|
||||||
|
BuildContext context,
|
||||||
|
String type,
|
||||||
|
String title,
|
||||||
|
) {
|
||||||
|
return ListTile(
|
||||||
|
onTap: () => Get.toNamed('/fav'),
|
||||||
|
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(
|
||||||
borderRadius: StyleString.mdRadius,
|
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: 14),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Icon(icon!.icon!),
|
InkWell(
|
||||||
|
onTap: () =>
|
||||||
|
Get.toNamed('/favDetail', arguments: item, parameters: {
|
||||||
|
'mediaId': item!.id.toString(),
|
||||||
|
'heroTag': heroTag,
|
||||||
|
'isOwner': '1',
|
||||||
|
}),
|
||||||
|
borderRadius: StyleString.mdRadius,
|
||||||
|
child: Hero(
|
||||||
|
tag: heroTag,
|
||||||
|
child: NetworkImgLayer(
|
||||||
|
src: item!.cover,
|
||||||
|
width: 180,
|
||||||
|
height: 110,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
text!,
|
' ${item!.title}',
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
overflow: TextOverflow.fade,
|
||||||
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
|
Text(
|
||||||
|
' 共${item!.mediaCount}条视频',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelSmall!
|
||||||
|
.copyWith(color: Theme.of(context).colorScheme.outline),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
45
lib/pages/mine_edit/controller.dart
Normal file
45
lib/pages/mine_edit/controller.dart
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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/utils/storage.dart';
|
||||||
|
|
||||||
|
class MineEditController extends GetxController {
|
||||||
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
|
final formKey = GlobalKey<FormState>();
|
||||||
|
final TextEditingController unameCtr = TextEditingController();
|
||||||
|
final TextEditingController useridCtr = TextEditingController();
|
||||||
|
final TextEditingController signCtr = TextEditingController();
|
||||||
|
final TextEditingController birthdayCtr = TextEditingController();
|
||||||
|
String? sex;
|
||||||
|
dynamic userInfo;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future getAccountInfo() async {
|
||||||
|
var res = await UserHttp.getAccountInfo();
|
||||||
|
if (res['status']) {
|
||||||
|
unameCtr.text = res['data']['uname'];
|
||||||
|
useridCtr.text = res['data']['userid'];
|
||||||
|
signCtr.text = res['data']['sign'];
|
||||||
|
birthdayCtr.text = res['data']['birthday'];
|
||||||
|
sex = res['data']['sex'];
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future updateAccountInfo() async {
|
||||||
|
var res = await UserHttp.updateAccountInfo(
|
||||||
|
uname: unameCtr.text,
|
||||||
|
sign: signCtr.text,
|
||||||
|
sex: sex!,
|
||||||
|
birthday: birthdayCtr.text,
|
||||||
|
);
|
||||||
|
SmartDialog.showToast(res['status'] ? res['msg'] : "更新失败:${res['msg']}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
library media;
|
library mine_edit;
|
||||||
|
|
||||||
export './controller.dart';
|
export './controller.dart';
|
||||||
export './view.dart';
|
export './view.dart';
|
||||||
177
lib/pages/mine_edit/view.dart
Normal file
177
lib/pages/mine_edit/view.dart
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import 'controller.dart';
|
||||||
|
|
||||||
|
class MineEditPage extends StatefulWidget {
|
||||||
|
const MineEditPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MineEditPage> createState() => _MineEditPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MineEditPageState extends State<MineEditPage> {
|
||||||
|
final MineEditController ctr = Get.put(MineEditController());
|
||||||
|
late Future _futureBuilderFuture;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_futureBuilderFuture = ctr.getAccountInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('编辑资料'),
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: _futureBuilderFuture,
|
||||||
|
builder: ((context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
if (snapshot.data == null) {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
if (snapshot.data['status']) {
|
||||||
|
return Form(
|
||||||
|
key: ctr.formKey,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// 用户头像
|
||||||
|
// InkWell(
|
||||||
|
// onTap: () {},
|
||||||
|
// child: CircleAvatar(
|
||||||
|
// radius: 50,
|
||||||
|
// backgroundColor: Colors.transparent,
|
||||||
|
// backgroundImage:
|
||||||
|
// NetworkImage(ctr.userInfo.face), // 替换为实际的头像路径
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
const SizedBox(height: 24.0),
|
||||||
|
// 昵称
|
||||||
|
TextFormField(
|
||||||
|
controller: ctr.unameCtr,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: '昵称',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return '请输入昵称';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
// 用户名
|
||||||
|
TextFormField(
|
||||||
|
controller: ctr.useridCtr,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: '用户名',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
readOnly: true,
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return '请输入用户名';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
// 签名
|
||||||
|
TextFormField(
|
||||||
|
controller: ctr.signCtr,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: '签名',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return '请输入签名';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
// 性别
|
||||||
|
DropdownButtonFormField<String>(
|
||||||
|
value: ctr.sex,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: '性别',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
items: ['男', '女', '保密'].map((String value) {
|
||||||
|
return DropdownMenuItem<String>(
|
||||||
|
value: value,
|
||||||
|
child: Text(value),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (newValue) {
|
||||||
|
ctr.sex = newValue;
|
||||||
|
},
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return '请选择性别';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
// 出生日期
|
||||||
|
TextFormField(
|
||||||
|
controller: ctr.birthdayCtr,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: '出生日期',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
enabled: false,
|
||||||
|
readOnly: true,
|
||||||
|
onTap: () async {
|
||||||
|
// DateTime? pickedDate = await showDatePicker(
|
||||||
|
// context: context,
|
||||||
|
// initialDate: DateTime(1995, 12, 23),
|
||||||
|
// firstDate: DateTime(1900),
|
||||||
|
// lastDate: DateTime(2100),
|
||||||
|
// );
|
||||||
|
// if (pickedDate != null) {
|
||||||
|
// ctr.birthdayCtr.text =
|
||||||
|
// "${pickedDate.toLocal()}".split(' ')[0];
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return '请选择出生日期';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30.0),
|
||||||
|
// 提交按钮
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (ctr.formKey.currentState!.validate()) {
|
||||||
|
// 处理表单提交
|
||||||
|
ctr.updateAccountInfo();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text('提交'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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']);
|
||||||
|
|||||||
@ -10,6 +10,8 @@ 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/mine_edit/index.dart';
|
||||||
import 'package:pilipala/pages/opus/index.dart';
|
import 'package:pilipala/pages/opus/index.dart';
|
||||||
import 'package:pilipala/pages/read/index.dart';
|
import 'package:pilipala/pages/read/index.dart';
|
||||||
import 'package:pilipala/pages/setting/pages/logs.dart';
|
import 'package:pilipala/pages/setting/pages/logs.dart';
|
||||||
@ -31,7 +33,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';
|
||||||
@ -79,8 +80,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()),
|
||||||
@ -187,6 +186,8 @@ class Routes {
|
|||||||
// 系统通知
|
// 系统通知
|
||||||
CustomGetPage(
|
CustomGetPage(
|
||||||
name: '/messageSystem', page: () => const MessageSystemPage()),
|
name: '/messageSystem', page: () => const MessageSystemPage()),
|
||||||
|
// 我的
|
||||||
|
CustomGetPage(name: '/mine', page: () => const MinePage()),
|
||||||
// 收藏夹编辑
|
// 收藏夹编辑
|
||||||
CustomGetPage(name: '/favEdit', page: () => const FavEditPage()),
|
CustomGetPage(name: '/favEdit', page: () => const FavEditPage()),
|
||||||
|
|
||||||
@ -196,6 +197,8 @@ class Routes {
|
|||||||
// 用户专栏
|
// 用户专栏
|
||||||
CustomGetPage(
|
CustomGetPage(
|
||||||
name: '/memberArticle', page: () => const MemberArticlePage()),
|
name: '/memberArticle', page: () => const MemberArticlePage()),
|
||||||
|
// 用户信息编辑
|
||||||
|
CustomGetPage(name: '/mineEdit', page: () => const MineEditPage()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -287,18 +287,18 @@ class PiliSchame {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'following':
|
case 'following':
|
||||||
if (path.startsWith('/detail')) {
|
if (path.startsWith('/detail')) {
|
||||||
var opusId = path.split('/').last;
|
var opusId = path.split('/').last;
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/webview',
|
'/webview',
|
||||||
parameters: {
|
parameters: {
|
||||||
'url': 'https://m.bilibili.com/opus/$opusId',
|
'url': 'https://m.bilibili.com/opus/$opusId',
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
'pageTitle': ''
|
'pageTitle': ''
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SmartDialog.showToast('未匹配地址,请联系开发者');
|
SmartDialog.showToast('未匹配地址,请联系开发者');
|
||||||
Clipboard.setData(ClipboardData(text: value.toJson().toString()));
|
Clipboard.setData(ClipboardData(text: value.toJson().toString()));
|
||||||
|
|||||||
@ -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