Merge branch 'main' into feature-sponsorBlock
This commit is contained in:
BIN
assets/images/pay/alipay.jpg
Normal file
BIN
assets/images/pay/alipay.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 143 KiB |
BIN
assets/images/pay/wechat.png
Normal file
BIN
assets/images/pay/wechat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 106 KiB |
@ -29,6 +29,8 @@ PODS:
|
|||||||
- Flutter
|
- Flutter
|
||||||
- GT3Captcha-iOS
|
- GT3Captcha-iOS
|
||||||
- GT3Captcha-iOS (0.15.8.3)
|
- GT3Captcha-iOS (0.15.8.3)
|
||||||
|
- image_picker_ios (0.0.1):
|
||||||
|
- Flutter
|
||||||
- media_kit_libs_ios_video (1.0.4):
|
- media_kit_libs_ios_video (1.0.4):
|
||||||
- Flutter
|
- Flutter
|
||||||
- media_kit_native_event_loop (1.0.0):
|
- media_kit_native_event_loop (1.0.0):
|
||||||
@ -80,6 +82,7 @@ DEPENDENCIES:
|
|||||||
- flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`)
|
- flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`)
|
||||||
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
|
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
|
||||||
- gt3_flutter_plugin (from `.symlinks/plugins/gt3_flutter_plugin/ios`)
|
- gt3_flutter_plugin (from `.symlinks/plugins/gt3_flutter_plugin/ios`)
|
||||||
|
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||||
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
|
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
|
||||||
- media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`)
|
- media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`)
|
||||||
- media_kit_video (from `.symlinks/plugins/media_kit_video/ios`)
|
- media_kit_video (from `.symlinks/plugins/media_kit_video/ios`)
|
||||||
@ -129,6 +132,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/fluttertoast/ios"
|
:path: ".symlinks/plugins/fluttertoast/ios"
|
||||||
gt3_flutter_plugin:
|
gt3_flutter_plugin:
|
||||||
:path: ".symlinks/plugins/gt3_flutter_plugin/ios"
|
:path: ".symlinks/plugins/gt3_flutter_plugin/ios"
|
||||||
|
image_picker_ios:
|
||||||
|
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||||
media_kit_libs_ios_video:
|
media_kit_libs_ios_video:
|
||||||
:path: ".symlinks/plugins/media_kit_libs_ios_video/ios"
|
:path: ".symlinks/plugins/media_kit_libs_ios_video/ios"
|
||||||
media_kit_native_event_loop:
|
media_kit_native_event_loop:
|
||||||
@ -179,6 +184,7 @@ SPEC CHECKSUMS:
|
|||||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||||
gt3_flutter_plugin: 5bd2c08d3c19cbb6ee3b08f4358439e54c8ab2ee
|
gt3_flutter_plugin: 5bd2c08d3c19cbb6ee3b08f4358439e54c8ab2ee
|
||||||
GT3Captcha-iOS: 5e3b1077834d8a9d6f4d64a447a30af3e14affe6
|
GT3Captcha-iOS: 5e3b1077834d8a9d6f4d64a447a30af3e14affe6
|
||||||
|
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
|
||||||
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
|
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
|
||||||
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
|
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
|
||||||
media_kit_video: 5da63f157170e5bf303bf85453b7ef6971218a2e
|
media_kit_video: 5da63f157170e5bf303bf85453b7ef6971218a2e
|
||||||
|
|||||||
@ -15,6 +15,4 @@ class Constants {
|
|||||||
// 59b43e04ad6965f34319062b478f83dd TV端
|
// 59b43e04ad6965f34319062b478f83dd TV端
|
||||||
static const String appSec = '59b43e04ad6965f34319062b478f83dd';
|
static const String appSec = '59b43e04ad6965f34319062b478f83dd';
|
||||||
static const String thirdSign = '04224646d1fea004e79606d3b038c84a';
|
static const String thirdSign = '04224646d1fea004e79606d3b038c84a';
|
||||||
static const String thirdApi =
|
|
||||||
'https://www.mcbbs.net/template/mcbbs/image/special_photo_bg.png';
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,35 +1,266 @@
|
|||||||
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:get/get.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:scrollable_positioned_list/scrollable_positioned_list.dart';
|
import 'package:pilipala/models/video_detail_res.dart';
|
||||||
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
import 'package:scrollview_observer/scrollview_observer.dart';
|
||||||
import '../models/common/video_episode_type.dart';
|
import '../models/common/video_episode_type.dart';
|
||||||
|
import 'widgets/badge.dart';
|
||||||
|
import 'widgets/stat/danmu.dart';
|
||||||
|
import 'widgets/stat/view.dart';
|
||||||
|
|
||||||
class EpisodeBottomSheet {
|
class EpisodeBottomSheet {
|
||||||
final List<dynamic> episodes;
|
final List<dynamic> episodes;
|
||||||
final int currentCid;
|
final int currentCid;
|
||||||
final dynamic dataType;
|
final dynamic dataType;
|
||||||
final BuildContext context;
|
|
||||||
final Function changeFucCall;
|
final Function changeFucCall;
|
||||||
final int? cid;
|
final int? cid;
|
||||||
final double? sheetHeight;
|
final double? sheetHeight;
|
||||||
bool isFullScreen = false;
|
bool isFullScreen = false;
|
||||||
|
final UgcSeason? ugcSeason;
|
||||||
|
|
||||||
EpisodeBottomSheet({
|
EpisodeBottomSheet({
|
||||||
required this.episodes,
|
required this.episodes,
|
||||||
required this.currentCid,
|
required this.currentCid,
|
||||||
required this.dataType,
|
required this.dataType,
|
||||||
required this.context,
|
|
||||||
required this.changeFucCall,
|
required this.changeFucCall,
|
||||||
this.cid,
|
this.cid,
|
||||||
this.sheetHeight,
|
this.sheetHeight,
|
||||||
this.isFullScreen = false,
|
this.isFullScreen = false,
|
||||||
|
this.ugcSeason,
|
||||||
});
|
});
|
||||||
|
|
||||||
Widget buildEpisodeListItem(
|
Widget buildShowContent() {
|
||||||
dynamic episode,
|
return PagesBottomSheet(
|
||||||
int index,
|
episodes: episodes,
|
||||||
bool isCurrentIndex,
|
currentCid: currentCid,
|
||||||
) {
|
dataType: dataType,
|
||||||
|
changeFucCall: changeFucCall,
|
||||||
|
cid: cid,
|
||||||
|
sheetHeight: sheetHeight,
|
||||||
|
isFullScreen: isFullScreen,
|
||||||
|
ugcSeason: ugcSeason,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
PersistentBottomSheetController show(BuildContext context) {
|
||||||
|
final PersistentBottomSheetController btmSheetCtr = showBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return buildShowContent();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return btmSheetCtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PagesBottomSheet extends StatefulWidget {
|
||||||
|
const PagesBottomSheet({
|
||||||
|
super.key,
|
||||||
|
required this.episodes,
|
||||||
|
required this.currentCid,
|
||||||
|
required this.dataType,
|
||||||
|
required this.changeFucCall,
|
||||||
|
this.cid,
|
||||||
|
this.sheetHeight,
|
||||||
|
this.isFullScreen = false,
|
||||||
|
this.ugcSeason,
|
||||||
|
});
|
||||||
|
|
||||||
|
final List<dynamic> episodes;
|
||||||
|
final int currentCid;
|
||||||
|
final dynamic dataType;
|
||||||
|
final Function changeFucCall;
|
||||||
|
final int? cid;
|
||||||
|
final double? sheetHeight;
|
||||||
|
final bool isFullScreen;
|
||||||
|
final UgcSeason? ugcSeason;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PagesBottomSheet> createState() => _PagesBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PagesBottomSheetState extends State<PagesBottomSheet> {
|
||||||
|
final ScrollController _listScrollController = ScrollController();
|
||||||
|
late ListObserverController _listObserverController;
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
late int currentIndex;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
currentIndex =
|
||||||
|
widget.episodes.indexWhere((dynamic e) => e.cid == widget.currentCid);
|
||||||
|
_listObserverController =
|
||||||
|
ListObserverController(controller: _listScrollController);
|
||||||
|
if (widget.dataType == VideoEpidoesType.videoEpisode) {
|
||||||
|
_listObserverController.initialIndexModel = ObserverIndexPositionModel(
|
||||||
|
index: currentIndex,
|
||||||
|
isFixedHeight: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (widget.dataType != VideoEpidoesType.videoEpisode) {
|
||||||
|
double itemHeight = (widget.isFullScreen
|
||||||
|
? 400
|
||||||
|
: Get.size.width - 3 * StyleString.safeSpace) /
|
||||||
|
5.2;
|
||||||
|
double offset = ((currentIndex - 1) / 2).ceil() * itemHeight;
|
||||||
|
_scrollController.jumpTo(offset);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
String prefix() {
|
||||||
|
switch (widget.dataType) {
|
||||||
|
case VideoEpidoesType.videoEpisode:
|
||||||
|
return '选集';
|
||||||
|
case VideoEpidoesType.videoPart:
|
||||||
|
return '分集';
|
||||||
|
case VideoEpidoesType.bangumiEpisode:
|
||||||
|
return '选集';
|
||||||
|
}
|
||||||
|
return '选集';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_listObserverController.controller?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
|
return SizedBox(
|
||||||
|
height: widget.sheetHeight,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TitleBar(
|
||||||
|
title: '${prefix()}(${widget.episodes.length})',
|
||||||
|
isFullScreen: widget.isFullScreen,
|
||||||
|
),
|
||||||
|
if (widget.ugcSeason != null) ...[
|
||||||
|
UgcSeasonBuild(ugcSeason: widget.ugcSeason!),
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
child: Material(
|
||||||
|
child: widget.dataType == VideoEpidoesType.videoEpisode
|
||||||
|
? ListViewObserver(
|
||||||
|
controller: _listObserverController,
|
||||||
|
child: ListView.builder(
|
||||||
|
controller: _listScrollController,
|
||||||
|
itemCount: widget.episodes.length + 1,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
bool isLastItem = index == widget.episodes.length;
|
||||||
|
bool isCurrentIndex = currentIndex == index;
|
||||||
|
return isLastItem
|
||||||
|
? SizedBox(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).padding.bottom +
|
||||||
|
20,
|
||||||
|
)
|
||||||
|
: EpisodeListItem(
|
||||||
|
episode: widget.episodes[index],
|
||||||
|
index: index,
|
||||||
|
isCurrentIndex: isCurrentIndex,
|
||||||
|
dataType: widget.dataType,
|
||||||
|
changeFucCall: widget.changeFucCall,
|
||||||
|
isFullScreen: widget.isFullScreen,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12.0), // 设置左右间距为12
|
||||||
|
child: GridView.count(
|
||||||
|
controller: _scrollController,
|
||||||
|
crossAxisCount: 2,
|
||||||
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
|
childAspectRatio: 2.6,
|
||||||
|
children: List.generate(
|
||||||
|
widget.episodes.length,
|
||||||
|
(index) {
|
||||||
|
bool isCurrentIndex = currentIndex == index;
|
||||||
|
return EpisodeGridItem(
|
||||||
|
episode: widget.episodes[index],
|
||||||
|
index: index,
|
||||||
|
isCurrentIndex: isCurrentIndex,
|
||||||
|
dataType: widget.dataType,
|
||||||
|
changeFucCall: widget.changeFucCall,
|
||||||
|
isFullScreen: widget.isFullScreen,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TitleBar extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final bool isFullScreen;
|
||||||
|
|
||||||
|
const TitleBar({
|
||||||
|
Key? key,
|
||||||
|
required this.title,
|
||||||
|
required this.isFullScreen,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppBar(
|
||||||
|
toolbarHeight: 45,
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
centerTitle: false,
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
actions: !isFullScreen
|
||||||
|
? [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close, size: 20),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14),
|
||||||
|
]
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EpisodeListItem extends StatelessWidget {
|
||||||
|
final dynamic episode;
|
||||||
|
final int index;
|
||||||
|
final bool isCurrentIndex;
|
||||||
|
final dynamic dataType;
|
||||||
|
final Function changeFucCall;
|
||||||
|
final bool isFullScreen;
|
||||||
|
|
||||||
|
const EpisodeListItem({
|
||||||
|
Key? key,
|
||||||
|
required this.episode,
|
||||||
|
required this.index,
|
||||||
|
required this.isCurrentIndex,
|
||||||
|
required this.dataType,
|
||||||
|
required this.changeFucCall,
|
||||||
|
required this.isFullScreen,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
Color primary = Theme.of(context).colorScheme.primary;
|
Color primary = Theme.of(context).colorScheme.primary;
|
||||||
Color onSurface = Theme.of(context).colorScheme.onSurface;
|
Color onSurface = Theme.of(context).colorScheme.onSurface;
|
||||||
|
|
||||||
@ -45,128 +276,308 @@ class EpisodeBottomSheet {
|
|||||||
title = '第${episode.title}话 ${episode.longTitle!}';
|
title = '第${episode.title}话 ${episode.longTitle!}';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isFullScreen || episode?.cover == null || episode?.cover == ''
|
return isFullScreen || episode?.cover == null || episode?.cover == ''
|
||||||
? ListTile(
|
? _buildListTile(context, title, primary, onSurface)
|
||||||
onTap: () {
|
: _buildInkWell(context, title, primary, onSurface);
|
||||||
SmartDialog.showToast('切换至「$title」');
|
}
|
||||||
changeFucCall.call(episode, index);
|
|
||||||
},
|
Widget _buildListTile(
|
||||||
dense: false,
|
BuildContext context, String title, Color primary, Color onSurface) {
|
||||||
leading: isCurrentIndex
|
return ListTile(
|
||||||
? Image.asset(
|
onTap: () {
|
||||||
'assets/images/live.gif',
|
if (isCurrentIndex) {
|
||||||
color: primary,
|
return;
|
||||||
height: 12,
|
}
|
||||||
|
SmartDialog.showToast('切换至「$title」');
|
||||||
|
changeFucCall.call(episode, index);
|
||||||
|
},
|
||||||
|
dense: false,
|
||||||
|
leading: isCurrentIndex
|
||||||
|
? Image.asset(
|
||||||
|
'assets/images/live.gif',
|
||||||
|
color: primary,
|
||||||
|
height: 12,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: isCurrentIndex ? primary : onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildInkWell(
|
||||||
|
BuildContext context, String title, Color primary, Color onSurface) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
if (isCurrentIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SmartDialog.showToast('切换至「$title」');
|
||||||
|
changeFucCall.call(episode, index);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(
|
||||||
|
StyleString.safeSpace, 6, StyleString.safeSpace, 6),
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (BuildContext context, BoxConstraints boxConstraints) {
|
||||||
|
const double width = 160;
|
||||||
|
return Container(
|
||||||
|
constraints: const BoxConstraints(minHeight: 88),
|
||||||
|
height: width / StyleString.aspectRatio,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
AspectRatio(
|
||||||
|
aspectRatio: StyleString.aspectRatio,
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (BuildContext context,
|
||||||
|
BoxConstraints boxConstraints) {
|
||||||
|
final double maxWidth = boxConstraints.maxWidth;
|
||||||
|
final double maxHeight = boxConstraints.maxHeight;
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
NetworkImgLayer(
|
||||||
|
src: episode?.cover ?? '',
|
||||||
|
width: maxWidth,
|
||||||
|
height: maxHeight,
|
||||||
|
),
|
||||||
|
if (episode.duration != 0)
|
||||||
|
PBadge(
|
||||||
|
text: Utils.timeFormat(episode.duration!),
|
||||||
|
right: 6.0,
|
||||||
|
bottom: 6.0,
|
||||||
|
type: 'gray',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(10, 2, 6, 0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
episode.title as String,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: isCurrentIndex ? primary : onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
if (dataType != VideoEpidoesType.videoPart) ...[
|
||||||
|
if (episode?.pubdate != null ||
|
||||||
|
episode.pubTime != null)
|
||||||
|
Text(
|
||||||
|
Utils.dateFormat(
|
||||||
|
episode?.pubdate ?? episode.pubTime),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
if (episode.stat != null)
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
StatView(view: episode.stat.view),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
StatDanMu(danmu: episode.stat.danmaku),
|
||||||
|
const Spacer(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: null,
|
],
|
||||||
title: Text(title,
|
),
|
||||||
style: TextStyle(
|
);
|
||||||
fontSize: 14,
|
},
|
||||||
color: isCurrentIndex ? primary : onSurface,
|
),
|
||||||
)))
|
),
|
||||||
: InkWell(
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EpisodeGridItem extends StatelessWidget {
|
||||||
|
final dynamic episode;
|
||||||
|
final int index;
|
||||||
|
final bool isCurrentIndex;
|
||||||
|
final dynamic dataType;
|
||||||
|
final Function changeFucCall;
|
||||||
|
final bool isFullScreen;
|
||||||
|
|
||||||
|
const EpisodeGridItem({
|
||||||
|
Key? key,
|
||||||
|
required this.episode,
|
||||||
|
required this.index,
|
||||||
|
required this.isCurrentIndex,
|
||||||
|
required this.dataType,
|
||||||
|
required this.changeFucCall,
|
||||||
|
required this.isFullScreen,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||||
|
TextStyle textStyle = TextStyle(
|
||||||
|
color: isCurrentIndex ? colorScheme.primary : colorScheme.onSurface,
|
||||||
|
fontSize: 14,
|
||||||
|
);
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
margin: const EdgeInsets.only(top: StyleString.safeSpace),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isCurrentIndex
|
||||||
|
? colorScheme.primaryContainer.withOpacity(0.6)
|
||||||
|
: colorScheme.onInverseSurface.withOpacity(0.6),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(
|
||||||
|
color: isCurrentIndex
|
||||||
|
? colorScheme.primary.withOpacity(0.8)
|
||||||
|
: Colors.transparent,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
SmartDialog.showToast('切换至「$title」');
|
if (isCurrentIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SmartDialog.showToast('切换至「${episode.title}」');
|
||||||
changeFucCall.call(episode, index);
|
changeFucCall.call(episode, index);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||||
const EdgeInsets.only(left: 14, right: 14, top: 8, bottom: 8),
|
child: Column(
|
||||||
child: Row(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
NetworkImgLayer(
|
Text(
|
||||||
width: 130, height: 75, src: episode?.cover ?? ''),
|
dataType == VideoEpidoesType.bangumiEpisode
|
||||||
const SizedBox(width: 10),
|
? '第${index + 1}话'
|
||||||
Expanded(
|
: '第${index + 1}p',
|
||||||
child: Text(
|
style: textStyle),
|
||||||
title,
|
const SizedBox(height: 1),
|
||||||
maxLines: 2,
|
Text(
|
||||||
style: TextStyle(
|
episode.title,
|
||||||
fontSize: 14,
|
maxLines: 1,
|
||||||
color: isCurrentIndex ? primary : onSurface,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
style: textStyle,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildTitle() {
|
|
||||||
return AppBar(
|
|
||||||
toolbarHeight: 45,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
centerTitle: false,
|
|
||||||
title: Text(
|
|
||||||
'合集(${episodes.length})',
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
actions: !isFullScreen
|
|
||||||
? [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.close, size: 20),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 14),
|
|
||||||
]
|
|
||||||
: null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildShowContent(BuildContext context) {
|
|
||||||
final ItemScrollController itemScrollController = ItemScrollController();
|
|
||||||
int currentIndex = episodes.indexWhere((dynamic e) => e.cid == currentCid);
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
itemScrollController.jumpTo(index: currentIndex);
|
|
||||||
});
|
|
||||||
return Container(
|
|
||||||
height: sheetHeight,
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
buildTitle(),
|
|
||||||
Expanded(
|
|
||||||
child: Material(
|
|
||||||
child: PageStorage(
|
|
||||||
bucket: PageStorageBucket(),
|
|
||||||
child: ScrollablePositionedList.builder(
|
|
||||||
itemScrollController: itemScrollController,
|
|
||||||
itemCount: episodes.length + 1,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
bool isLastItem = index == episodes.length;
|
|
||||||
bool isCurrentIndex = currentIndex == index;
|
|
||||||
return isLastItem
|
|
||||||
? SizedBox(
|
|
||||||
height:
|
|
||||||
MediaQuery.of(context).padding.bottom + 20,
|
|
||||||
)
|
|
||||||
: buildEpisodeListItem(
|
|
||||||
episodes[index],
|
|
||||||
index,
|
|
||||||
isCurrentIndex,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
if (dataType == VideoEpidoesType.bangumiEpisode &&
|
||||||
});
|
episode.badge != '' &&
|
||||||
}
|
episode.badge != null)
|
||||||
|
Positioned(
|
||||||
/// The [BuildContext] of the widget that calls the bottom sheet.
|
right: 8,
|
||||||
PersistentBottomSheetController show(BuildContext context) {
|
top: 18,
|
||||||
final PersistentBottomSheetController btmSheetCtr = showBottomSheet(
|
child: Text(
|
||||||
context: context,
|
episode.badge,
|
||||||
builder: (BuildContext context) {
|
style: const TextStyle(fontSize: 11, color: Color(0xFFFF6699)),
|
||||||
return buildShowContent(context);
|
),
|
||||||
},
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UgcSeasonBuild extends StatelessWidget {
|
||||||
|
final UgcSeason ugcSeason;
|
||||||
|
|
||||||
|
const UgcSeasonBuild({
|
||||||
|
Key? key,
|
||||||
|
required this.ugcSeason,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||||
|
color: Theme.of(context).colorScheme.surface,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: 1,
|
||||||
|
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
'合集:${ugcSeason.title}',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
if (ugcSeason.intro != null && ugcSeason.intro != '') ...[
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(ugcSeason.intro ?? '',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline)),
|
||||||
|
),
|
||||||
|
// SizedBox(
|
||||||
|
// height: 32,
|
||||||
|
// child: FilledButton.tonal(
|
||||||
|
// onPressed: () {},
|
||||||
|
// style: ButtonStyle(
|
||||||
|
// padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
|
// ),
|
||||||
|
// child: const Text('订阅'),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(width: 6),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text.rich(
|
||||||
|
TextSpan(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.view)}播放'),
|
||||||
|
const TextSpan(text: ' · '),
|
||||||
|
TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.danmaku)}弹幕'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: 1,
|
||||||
|
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return btmSheetCtr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,14 +3,9 @@ import 'package:pilipala/common/constants.dart';
|
|||||||
|
|
||||||
import 'skeleton.dart';
|
import 'skeleton.dart';
|
||||||
|
|
||||||
class MediaBangumiSkeleton extends StatefulWidget {
|
class MediaBangumiSkeleton extends StatelessWidget {
|
||||||
const MediaBangumiSkeleton({super.key});
|
const MediaBangumiSkeleton({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<MediaBangumiSkeleton> createState() => _MediaBangumiSkeletonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MediaBangumiSkeletonState extends State<MediaBangumiSkeleton> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Color bgColor = Theme.of(context).colorScheme.onInverseSurface;
|
Color bgColor = Theme.of(context).colorScheme.onInverseSurface;
|
||||||
@ -35,25 +30,25 @@ class _MediaBangumiSkeletonState extends State<MediaBangumiSkeleton> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
color: bgColor,
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 20,
|
height: 20,
|
||||||
margin: const EdgeInsets.only(bottom: 15),
|
margin: const EdgeInsets.only(bottom: 15),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
color: bgColor,
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 13,
|
height: 13,
|
||||||
margin: const EdgeInsets.only(bottom: 5),
|
margin: const EdgeInsets.only(bottom: 5),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
color: bgColor,
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 13,
|
height: 13,
|
||||||
margin: const EdgeInsets.only(bottom: 5),
|
margin: const EdgeInsets.only(bottom: 5),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
color: bgColor,
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 13,
|
height: 13,
|
||||||
),
|
),
|
||||||
@ -64,7 +59,7 @@ class _MediaBangumiSkeletonState extends State<MediaBangumiSkeleton> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius:
|
borderRadius:
|
||||||
const BorderRadius.all(Radius.circular(20)),
|
const BorderRadius.all(Radius.circular(20)),
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
color: bgColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
42
lib/common/skeleton/user_list.dart
Normal file
42
lib/common/skeleton/user_list.dart
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../constants.dart';
|
||||||
|
|
||||||
|
class UserListSkeleton extends StatelessWidget {
|
||||||
|
const UserListSkeleton({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Color bgColor = Theme.of(context).colorScheme.onInverseSurface;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: StyleString.safeSpace, vertical: 7),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
ClipOval(
|
||||||
|
child: Container(width: 42, height: 42, color: bgColor),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(color: bgColor, width: 60, height: 13),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Container(color: bgColor, width: 40, height: 13),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Container(
|
||||||
|
color: bgColor,
|
||||||
|
width: 100,
|
||||||
|
height: 13,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,9 +4,10 @@ import 'package:flutter_svg/flutter_svg.dart';
|
|||||||
class HttpError extends StatelessWidget {
|
class HttpError extends StatelessWidget {
|
||||||
const HttpError({
|
const HttpError({
|
||||||
required this.errMsg,
|
required this.errMsg,
|
||||||
required this.fn,
|
this.fn,
|
||||||
this.btnText,
|
this.btnText,
|
||||||
this.isShowBtn = true,
|
this.isShowBtn = true,
|
||||||
|
this.isInSliver = true,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -14,46 +15,41 @@ class HttpError extends StatelessWidget {
|
|||||||
final Function()? fn;
|
final Function()? fn;
|
||||||
final String? btnText;
|
final String? btnText;
|
||||||
final bool isShowBtn;
|
final bool isShowBtn;
|
||||||
|
final bool isInSliver;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SliverToBoxAdapter(
|
Color primary = Theme.of(context).colorScheme.primary;
|
||||||
child: SizedBox(
|
final errorContent = SizedBox(
|
||||||
height: 400,
|
height: 400,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: [
|
SvgPicture.asset("assets/images/error.svg", height: 200),
|
||||||
SvgPicture.asset(
|
const SizedBox(height: 30),
|
||||||
"assets/images/error.svg",
|
Text(
|
||||||
height: 200,
|
errMsg ?? '请求异常',
|
||||||
),
|
textAlign: TextAlign.center,
|
||||||
const SizedBox(height: 30),
|
style: Theme.of(context).textTheme.titleSmall,
|
||||||
Text(
|
),
|
||||||
errMsg ?? '请求异常',
|
const SizedBox(height: 20),
|
||||||
textAlign: TextAlign.center,
|
if (isShowBtn)
|
||||||
style: Theme.of(context).textTheme.titleSmall,
|
FilledButton.tonal(
|
||||||
),
|
onPressed: () => fn?.call(),
|
||||||
const SizedBox(height: 20),
|
style: ButtonStyle(
|
||||||
if (isShowBtn)
|
backgroundColor: MaterialStateProperty.resolveWith((states) {
|
||||||
FilledButton.tonal(
|
return primary.withAlpha(20);
|
||||||
onPressed: () {
|
}),
|
||||||
fn!();
|
|
||||||
},
|
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states) {
|
|
||||||
return Theme.of(context).colorScheme.primary.withAlpha(20);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
btnText ?? '点击重试',
|
|
||||||
style:
|
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
child: Text(btnText ?? '点击重试', style: TextStyle(color: primary)),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (isInSliver) {
|
||||||
|
return SliverToBoxAdapter(child: errorContent);
|
||||||
|
} else {
|
||||||
|
return Align(alignment: Alignment.topCenter, child: errorContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
// 图片质量 默认1%
|
// 图片质量 默认1%
|
||||||
this.quality,
|
this.quality,
|
||||||
this.origAspectRatio,
|
this.origAspectRatio,
|
||||||
|
this.radius,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String? src;
|
final String? src;
|
||||||
@ -30,6 +31,18 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
final Duration? fadeInDuration;
|
final Duration? fadeInDuration;
|
||||||
final int? quality;
|
final int? quality;
|
||||||
final double? origAspectRatio;
|
final double? origAspectRatio;
|
||||||
|
final double? radius;
|
||||||
|
|
||||||
|
BorderRadius getBorderRadius(String? type, double? radius) {
|
||||||
|
return BorderRadius.circular(
|
||||||
|
radius ??
|
||||||
|
(type == 'avatar'
|
||||||
|
? 50
|
||||||
|
: type == 'emote'
|
||||||
|
? 0
|
||||||
|
: StyleString.imgRadius.x),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -72,13 +85,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
return src != '' && src != null
|
return src != '' && src != null
|
||||||
? ClipRRect(
|
? ClipRRect(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
borderRadius: BorderRadius.circular(
|
borderRadius: getBorderRadius(type, radius),
|
||||||
type == 'avatar'
|
|
||||||
? 50
|
|
||||||
: type == 'emote'
|
|
||||||
? 0
|
|
||||||
: StyleString.imgRadius.x,
|
|
||||||
),
|
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
imageUrl: imageUrl,
|
imageUrl: imageUrl,
|
||||||
width: width,
|
width: width,
|
||||||
@ -107,11 +114,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface.withOpacity(0.4),
|
color: Theme.of(context).colorScheme.onInverseSurface.withOpacity(0.4),
|
||||||
borderRadius: BorderRadius.circular(type == 'avatar'
|
borderRadius: getBorderRadius(type, radius),
|
||||||
? 50
|
|
||||||
: type == 'emote'
|
|
||||||
? 0
|
|
||||||
: StyleString.imgRadius.x),
|
|
||||||
),
|
),
|
||||||
child: type == 'bg'
|
child: type == 'bg'
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
|
|||||||
@ -104,7 +104,7 @@ class Api {
|
|||||||
|
|
||||||
// 评论列表
|
// 评论列表
|
||||||
// https://api.bilibili.com/x/v2/reply/main?csrf=6e22efc1a47225ea25f901f922b5cfdd&mode=3&oid=254175381&pagination_str=%7B%22offset%22:%22%22%7D&plat=1&seek_rpid=0&type=11
|
// https://api.bilibili.com/x/v2/reply/main?csrf=6e22efc1a47225ea25f901f922b5cfdd&mode=3&oid=254175381&pagination_str=%7B%22offset%22:%22%22%7D&plat=1&seek_rpid=0&type=11
|
||||||
static const String replyList = '/x/v2/reply';
|
static const String replyList = '/x/v2/reply/main';
|
||||||
|
|
||||||
// 楼中楼
|
// 楼中楼
|
||||||
static const String replyReplyList = '/x/v2/reply/reply';
|
static const String replyReplyList = '/x/v2/reply/reply';
|
||||||
@ -175,7 +175,7 @@ class Api {
|
|||||||
static const String delHistory = '/x/v2/history/delete';
|
static const String delHistory = '/x/v2/history/delete';
|
||||||
|
|
||||||
// 搜索历史记录
|
// 搜索历史记录
|
||||||
static const String searchHistory = '/x/web-goblin/history/search';
|
static const String searchHistory = '/x/web-interface/history/search';
|
||||||
|
|
||||||
// 热搜
|
// 热搜
|
||||||
static const String hotSearchList =
|
static const String hotSearchList =
|
||||||
@ -301,10 +301,6 @@ class Api {
|
|||||||
static const String bangumiList =
|
static const String bangumiList =
|
||||||
'/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1©right=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&season_type=1&pagesize=20&type=1';
|
'/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1©right=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&season_type=1&pagesize=20&type=1';
|
||||||
|
|
||||||
// 我的订阅
|
|
||||||
static const String bangumiFollow =
|
|
||||||
'/x/space/bangumi/follow/list?type=1&follow_status=0&pn=1&ps=15&ts=1691544359969';
|
|
||||||
|
|
||||||
// 黑名单
|
// 黑名单
|
||||||
static const String blackLst = '/x/relation/blacks';
|
static const String blackLst = '/x/relation/blacks';
|
||||||
|
|
||||||
@ -499,7 +495,7 @@ class Api {
|
|||||||
static const activateBuvidApi = '/x/internal/gaia-gateway/ExClimbWuzhi';
|
static const activateBuvidApi = '/x/internal/gaia-gateway/ExClimbWuzhi';
|
||||||
|
|
||||||
/// 获取字幕配置
|
/// 获取字幕配置
|
||||||
static const getSubtitleConfig = '/x/player/v2';
|
static const getSubtitleConfig = '/x/player/wbi/v2';
|
||||||
|
|
||||||
/// 我的订阅
|
/// 我的订阅
|
||||||
static const userSubFolder = '/x/v3/fav/folder/collected/list';
|
static const userSubFolder = '/x/v3/fav/folder/collected/list';
|
||||||
@ -593,6 +589,24 @@ 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';
|
||||||
|
|
||||||
|
/// 图片上传
|
||||||
|
static const String uploadImage = '/x/dynamic/feed/draw/upload_bfs';
|
||||||
|
|
||||||
|
/// 更新追番状态
|
||||||
|
static const String updateBangumiStatus = '/pgc/web/follow/status/update';
|
||||||
|
|
||||||
|
/// 番剧点赞投币收藏状态
|
||||||
|
static const String bangumiActionStatus = '/pgc/season/episode/community';
|
||||||
|
|
||||||
|
/// @我的
|
||||||
|
static const String messageAtAPi = '/x/msgfeed/at?';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import '../models/bangumi/list.dart';
|
import '../models/bangumi/list.dart';
|
||||||
import 'index.dart';
|
import 'index.dart';
|
||||||
|
import 'package:html/parser.dart' as html_parser;
|
||||||
|
import 'package:html/dom.dart' as html_dom;
|
||||||
|
|
||||||
class BangumiHttp {
|
class BangumiHttp {
|
||||||
static Future bangumiList({int? page}) async {
|
static Future bangumiList({int? page}) async {
|
||||||
@ -18,8 +21,19 @@ class BangumiHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future bangumiFollow({int? mid}) async {
|
static Future getRecentBangumi({
|
||||||
var res = await Request().get(Api.bangumiFollow, data: {'vmid': mid});
|
int? mid,
|
||||||
|
int type = 1,
|
||||||
|
int pn = 1,
|
||||||
|
int ps = 20,
|
||||||
|
}) async {
|
||||||
|
var res = await Request().get(Api.getRecentBangumiApi, data: {
|
||||||
|
'vmid': mid,
|
||||||
|
'type': type,
|
||||||
|
'follow_status': 0,
|
||||||
|
'pn': pn,
|
||||||
|
'ps': ps,
|
||||||
|
});
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {
|
return {
|
||||||
'status': true,
|
'status': true,
|
||||||
@ -33,4 +47,62 @@ class BangumiHttp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取追番状态
|
||||||
|
static Future bangumiStatus({required int seasonId}) async {
|
||||||
|
var res = await Request()
|
||||||
|
.get('https://www.bilibili.com/bangumi/play/ss$seasonId');
|
||||||
|
html_dom.Document document = html_parser.parse(res.data);
|
||||||
|
// 查找 id 为 __NEXT_DATA__ 的 script 元素
|
||||||
|
html_dom.Element? scriptElement =
|
||||||
|
document.querySelector('script#\\__NEXT_DATA__');
|
||||||
|
if (scriptElement != null) {
|
||||||
|
// 提取 script 元素的内容
|
||||||
|
String scriptContent = scriptElement.text;
|
||||||
|
final dynamic scriptContentJson = jsonDecode(scriptContent);
|
||||||
|
Map followState = scriptContentJson['props']['pageProps']['followState'];
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': {
|
||||||
|
'isFollowed': followState['isFollowed'],
|
||||||
|
'followStatus': followState['followStatus']
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
print('Script element with id "__NEXT_DATA__" not found.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新追番状态
|
||||||
|
static Future updateBangumiStatus({
|
||||||
|
required int seasonId,
|
||||||
|
required int status,
|
||||||
|
}) async {
|
||||||
|
var res = await Request().post(Api.updateBangumiStatus, data: {
|
||||||
|
'season_id': seasonId,
|
||||||
|
'status': status,
|
||||||
|
});
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true, 'data': res.data['data']};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'data': [],
|
||||||
|
'msg': res.data['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取番剧点赞投币收藏状态
|
||||||
|
static Future bangumiActionStatus({required int epId}) async {
|
||||||
|
var res = await Request().get(
|
||||||
|
Api.bangumiActionStatus,
|
||||||
|
data: {'ep_id': epId},
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true, 'data': res.data['data']};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,6 @@ class HtmlHttp {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Document rootTree = parse(response.data);
|
Document rootTree = parse(response.data);
|
||||||
// log(response.data.body.toString());
|
|
||||||
Element body = rootTree.body!;
|
Element body = rootTree.body!;
|
||||||
Element appDom = body.querySelector('#app')!;
|
Element appDom = body.querySelector('#app')!;
|
||||||
Element authorHeader = appDom.querySelector('.fixed-author-header')!;
|
Element authorHeader = appDom.querySelector('.fixed-author-header')!;
|
||||||
@ -52,7 +51,6 @@ class HtmlHttp {
|
|||||||
.className
|
.className
|
||||||
.split(' ')[1]
|
.split(' ')[1]
|
||||||
.split('-')[2];
|
.split('-')[2];
|
||||||
// List imgList = opusDetail.querySelectorAll('bili-album__preview__picture__img');
|
|
||||||
return {
|
return {
|
||||||
'status': true,
|
'status': true,
|
||||||
'avatar': avatar,
|
'avatar': avatar,
|
||||||
@ -76,20 +74,10 @@ class HtmlHttp {
|
|||||||
Element body = rootTree.body!;
|
Element body = rootTree.body!;
|
||||||
Element appDom = body.querySelector('#app')!;
|
Element appDom = body.querySelector('#app')!;
|
||||||
Element authorHeader = appDom.querySelector('.up-left')!;
|
Element authorHeader = appDom.querySelector('.up-left')!;
|
||||||
// 头像
|
|
||||||
// String avatar =
|
|
||||||
// authorHeader.querySelector('.bili-avatar-img')!.attributes['data-src']!;
|
|
||||||
// print(avatar);
|
|
||||||
// avatar = 'https:${avatar.split('@')[0]}';
|
|
||||||
String uname = authorHeader.querySelector('.up-name')!.text.trim();
|
String uname = authorHeader.querySelector('.up-name')!.text.trim();
|
||||||
// 动态详情
|
// 动态详情
|
||||||
Element opusDetail = appDom.querySelector('.article-content')!;
|
Element opusDetail = appDom.querySelector('.article-content')!;
|
||||||
// 发布时间
|
// 发布时间
|
||||||
// String updateTime =
|
|
||||||
// opusDetail.querySelector('.opus-module-author__pub__text')!.text;
|
|
||||||
// print(updateTime);
|
|
||||||
|
|
||||||
//
|
|
||||||
String opusContent =
|
String opusContent =
|
||||||
opusDetail.querySelector('#read-article-holder')!.innerHtml;
|
opusDetail.querySelector('#read-article-holder')!.innerHtml;
|
||||||
RegExp digitRegExp = RegExp(r'\d+');
|
RegExp digitRegExp = RegExp(r'\d+');
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import 'package:cookie_jar/cookie_jar.dart';
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio/io.dart';
|
import 'package:dio/io.dart';
|
||||||
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
||||||
// import 'package:dio_http2_adapter/dio_http2_adapter.dart';
|
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import '../utils/storage.dart';
|
import '../utils/storage.dart';
|
||||||
@ -171,15 +170,6 @@ class Request {
|
|||||||
|
|
||||||
dio = Dio(options);
|
dio = Dio(options);
|
||||||
|
|
||||||
/// fix 第三方登录 302重定向 跟iOS代理问题冲突
|
|
||||||
// ..httpClientAdapter = Http2Adapter(
|
|
||||||
// ConnectionManager(
|
|
||||||
// idleTimeout: const Duration(milliseconds: 10000),
|
|
||||||
// onClientCreate: (_, ClientSetting config) =>
|
|
||||||
// config.onBadCertificate = (_) => true,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
|
|
||||||
/// 设置代理
|
/// 设置代理
|
||||||
if (enableSystemProxy) {
|
if (enableSystemProxy) {
|
||||||
dio.httpClientAdapter = IOHttpClientAdapter(
|
dio.httpClientAdapter = IOHttpClientAdapter(
|
||||||
@ -247,11 +237,26 @@ class Request {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get请求
|
||||||
|
*/
|
||||||
|
getWithoutCookie(url, {data}) {
|
||||||
|
return get(
|
||||||
|
url,
|
||||||
|
data: data,
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'cookie': 'buvid3= ; b_nut= ; sid= ',
|
||||||
|
'user-agent': headerUa(type: 'pc'),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* post请求
|
* post请求
|
||||||
*/
|
*/
|
||||||
post(url, {data, queryParameters, options, cancelToken, extra}) async {
|
post(url, {data, queryParameters, options, cancelToken, extra}) async {
|
||||||
// print('post-data: $data');
|
|
||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
response = await dio.post(
|
response = await dio.post(
|
||||||
@ -262,7 +267,6 @@ class Request {
|
|||||||
options ?? Options(contentType: Headers.formUrlEncodedContentType),
|
options ?? Options(contentType: Headers.formUrlEncodedContentType),
|
||||||
cancelToken: cancelToken,
|
cancelToken: cancelToken,
|
||||||
);
|
);
|
||||||
// print('post success: ${response.data}');
|
|
||||||
return response;
|
return response;
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
Response errResponse = Response(
|
Response errResponse = Response(
|
||||||
@ -318,7 +322,7 @@ class Request {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
headerUa =
|
headerUa =
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15';
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36';
|
||||||
}
|
}
|
||||||
return headerUa;
|
return headerUa;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,7 @@
|
|||||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.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:pilipala/utils/login.dart';
|
||||||
import '../utils/storage.dart';
|
|
||||||
|
|
||||||
class ApiInterceptor extends Interceptor {
|
class ApiInterceptor extends Interceptor {
|
||||||
@override
|
@override
|
||||||
@ -19,20 +18,9 @@ class ApiInterceptor extends Interceptor {
|
|||||||
@override
|
@override
|
||||||
void onResponse(Response response, ResponseInterceptorHandler handler) {
|
void onResponse(Response response, ResponseInterceptorHandler handler) {
|
||||||
try {
|
try {
|
||||||
if (response.statusCode == 302) {
|
// 在响应之后处理数据
|
||||||
final List<String> locations = response.headers['location']!;
|
if (response.data is Map && response.data['code'] == -101) {
|
||||||
if (locations.isNotEmpty) {
|
LoginUtils.loginOut();
|
||||||
if (locations.first.startsWith('https://www.mcbbs.net')) {
|
|
||||||
final Uri uri = Uri.parse(locations.first);
|
|
||||||
final String? accessKey = uri.queryParameters['access_key'];
|
|
||||||
final String? mid = uri.queryParameters['mid'];
|
|
||||||
try {
|
|
||||||
Box localCache = GStrorage.localCache;
|
|
||||||
localCache.put(LocalCacheKey.accessKey,
|
|
||||||
<String, String?>{'mid': mid, 'value': accessKey});
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
print('ApiInterceptor: $err');
|
print('ApiInterceptor: $err');
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pilipala/models/msg/at.dart';
|
||||||
import 'package:pilipala/models/msg/like.dart';
|
import 'package:pilipala/models/msg/like.dart';
|
||||||
import 'package:pilipala/models/msg/reply.dart';
|
import 'package:pilipala/models/msg/reply.dart';
|
||||||
import 'package:pilipala/models/msg/system.dart';
|
import 'package:pilipala/models/msg/system.dart';
|
||||||
@ -63,7 +65,7 @@ class MsgHttp {
|
|||||||
.toList(),
|
.toList(),
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
print('err🔟: $err');
|
debugPrint('err: $err');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
@ -278,10 +280,10 @@ class MsgHttp {
|
|||||||
'data': MessageLikeModel.fromJson(res.data['data']),
|
'data': MessageLikeModel.fromJson(res.data['data']),
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return {'status': false, 'date': [], 'msg': err.toString()};
|
return {'status': false, 'data': [], 'msg': err.toString()};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {'status': false, 'date': [], 'msg': res.data['message']};
|
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,4 +351,24 @@ class MsgHttp {
|
|||||||
return {'status': false, 'date': [], 'msg': res.data['message']};
|
return {'status': false, 'date': [], 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @我的
|
||||||
|
static Future messageAt() async {
|
||||||
|
var res = await Request().get(Api.messageAtAPi, data: {
|
||||||
|
'build': 0,
|
||||||
|
'mobi_app': 'web',
|
||||||
|
});
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
try {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': MessageAtModel.fromJson(res.data['data']),
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
return {'status': false, 'data': [], 'msg': err.toString()};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,8 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
import '../models/video/reply/data.dart';
|
import '../models/video/reply/data.dart';
|
||||||
import '../models/video/reply/emote.dart';
|
import '../models/video/reply/emote.dart';
|
||||||
import 'api.dart';
|
import 'api.dart';
|
||||||
@ -6,17 +11,16 @@ import 'init.dart';
|
|||||||
class ReplyHttp {
|
class ReplyHttp {
|
||||||
static Future replyList({
|
static Future replyList({
|
||||||
required int oid,
|
required int oid,
|
||||||
required int pageNum,
|
required String nextOffset,
|
||||||
required int type,
|
required int type,
|
||||||
int? ps,
|
int? ps,
|
||||||
int sort = 1,
|
int sort = 1,
|
||||||
}) async {
|
}) async {
|
||||||
var res = await Request().get(Api.replyList, data: {
|
var res = await Request().get(Api.replyList, data: {
|
||||||
'oid': oid,
|
'oid': oid,
|
||||||
'pn': pageNum,
|
|
||||||
'type': type,
|
'type': type,
|
||||||
'sort': sort,
|
'pagination_str': jsonEncode({'offset': nextOffset}),
|
||||||
'ps': ps ?? 20
|
'mode': sort + 2,
|
||||||
});
|
});
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {
|
return {
|
||||||
@ -52,19 +56,13 @@ class ReplyHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {
|
return {
|
||||||
'status': true,
|
'status': true,
|
||||||
'data': ReplyData.fromJson(res.data['data']),
|
'data': ReplyReplyData.fromJson(res.data['data']),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
Map errMap = {
|
|
||||||
-400: '请求错误',
|
|
||||||
-404: '无此项',
|
|
||||||
12002: '评论区已关闭',
|
|
||||||
12009: '评论主体的type不合法',
|
|
||||||
};
|
|
||||||
return {
|
return {
|
||||||
'status': false,
|
'status': false,
|
||||||
'date': [],
|
'date': [],
|
||||||
'msg': errMap[res.data['code']] ?? '请求异常',
|
'msg': res.data['message'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,4 +134,44 @@ class ReplyHttp {
|
|||||||
return {'status': false, 'msg': res.data['message']};
|
return {'status': false, 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 图片上传
|
||||||
|
static Future uploadImage(
|
||||||
|
{required XFile xFile, String type = 'new_dyn'}) async {
|
||||||
|
var formData = FormData.fromMap({
|
||||||
|
'file_up': await xFileToMultipartFile(xFile),
|
||||||
|
'biz': type,
|
||||||
|
'csrf': await Request.getCsrf(),
|
||||||
|
'category': 'daily',
|
||||||
|
});
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.uploadImage,
|
||||||
|
data: formData,
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
var data = res.data['data'];
|
||||||
|
data['img_src'] = data['image_url'];
|
||||||
|
data['img_width'] = data['image_width'];
|
||||||
|
data['img_height'] = data['image_height'];
|
||||||
|
data.remove('image_url');
|
||||||
|
data.remove('image_width');
|
||||||
|
data.remove('image_height');
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': data,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'date': [],
|
||||||
|
'msg': res.data['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<MultipartFile> xFileToMultipartFile(XFile xFile) async {
|
||||||
|
var file = File(xFile.path);
|
||||||
|
var bytes = await file.readAsBytes();
|
||||||
|
return MultipartFile.fromBytes(bytes, filename: xFile.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
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 '../common/constants.dart';
|
|
||||||
import '../models/model_hot_video_item.dart';
|
import '../models/model_hot_video_item.dart';
|
||||||
import '../models/user/fav_detail.dart';
|
import '../models/user/fav_detail.dart';
|
||||||
import '../models/user/fav_folder.dart';
|
import '../models/user/fav_folder.dart';
|
||||||
@ -218,25 +216,6 @@ class UserHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户凭证 失效
|
|
||||||
static Future thirdLogin() async {
|
|
||||||
var res = await Request().get(
|
|
||||||
'https://passport.bilibili.com/login/app/third',
|
|
||||||
data: {
|
|
||||||
'appkey': Constants.appKey,
|
|
||||||
'api': Constants.thirdApi,
|
|
||||||
'sign': Constants.thirdSign,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
if (res.data['code'] == 0 && res.data['data']['has_login'] == 1) {
|
|
||||||
Request().get(res.data['data']['confirm_uri']);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
SmartDialog.showNotify(msg: '获取用户凭证: $err', notifyType: NotifyType.error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 清空稍后再看
|
// 清空稍后再看
|
||||||
static Future toViewClear() async {
|
static Future toViewClear() async {
|
||||||
var res = await Request().post(
|
var res = await Request().post(
|
||||||
@ -283,30 +262,6 @@ class UserHttp {
|
|||||||
return {'status': false, 'msg': res.data['message']};
|
return {'status': false, 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // 相互关系查询
|
|
||||||
// static Future relationSearch(int mid) async {
|
|
||||||
// Map params = await WbiSign().makSign({
|
|
||||||
// 'mid': mid,
|
|
||||||
// 'token': '',
|
|
||||||
// 'platform': 'web',
|
|
||||||
// 'web_location': 1550101,
|
|
||||||
// });
|
|
||||||
// var res = await Request().get(
|
|
||||||
// Api.relationSearch,
|
|
||||||
// data: {
|
|
||||||
// 'mid': mid,
|
|
||||||
// 'w_rid': params['w_rid'],
|
|
||||||
// 'wts': params['wts'],
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// if (res.data['code'] == 0) {
|
|
||||||
// // relation 主动状态
|
|
||||||
// // 被动状态
|
|
||||||
// return {'status': true, 'data': res.data['data']};
|
|
||||||
// } else {
|
|
||||||
// return {'status': false, 'msg': res.data['message']};
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 搜索历史记录
|
// 搜索历史记录
|
||||||
static Future searchHistory(
|
static Future searchHistory(
|
||||||
@ -436,31 +391,6 @@ class UserHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 稍后再看播放全部
|
|
||||||
// static Future toViewPlayAll({required int oid, required String bvid}) async {
|
|
||||||
// var res = await Request().get(
|
|
||||||
// Api.watchLaterHtml,
|
|
||||||
// data: {
|
|
||||||
// 'oid': oid,
|
|
||||||
// 'bvid': bvid,
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// String scriptContent =
|
|
||||||
// extractScriptContents(parse(res.data).body!.outerHtml)[0];
|
|
||||||
// int startIndex = scriptContent.indexOf('{');
|
|
||||||
// int endIndex = scriptContent.lastIndexOf('};');
|
|
||||||
// String jsonContent = scriptContent.substring(startIndex, endIndex + 1);
|
|
||||||
// // 解析JSON字符串为Map
|
|
||||||
// Map<String, dynamic> jsonData = json.decode(jsonContent);
|
|
||||||
// // 输出解析后的数据
|
|
||||||
// return {
|
|
||||||
// 'status': true,
|
|
||||||
// 'data': jsonData['resourceList']
|
|
||||||
// .map((e) => MediaVideoItemModel.fromJson(e))
|
|
||||||
// .toList()
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
static List<String> extractScriptContents(String htmlContent) {
|
static List<String> extractScriptContents(String htmlContent) {
|
||||||
RegExp scriptRegExp = RegExp(r'<script>([\s\S]*?)<\/script>');
|
RegExp scriptRegExp = RegExp(r'<script>([\s\S]*?)<\/script>');
|
||||||
Iterable<Match> matches = scriptRegExp.allMatches(htmlContent);
|
Iterable<Match> matches = scriptRegExp.allMatches(htmlContent);
|
||||||
@ -537,4 +467,83 @@ 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'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析up投稿
|
||||||
|
static Future parseUpArchiveVideo({
|
||||||
|
required int mid,
|
||||||
|
required int oid,
|
||||||
|
required String bvid,
|
||||||
|
String sortField = 'pubtime',
|
||||||
|
}) async {
|
||||||
|
var res = await Request().get(
|
||||||
|
'https://www.bilibili.com/list/$mid',
|
||||||
|
data: {
|
||||||
|
'oid': oid,
|
||||||
|
'bvid': bvid,
|
||||||
|
'sort_field': sortField,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
String scriptContent =
|
||||||
|
extractScriptContents(parse(res.data).body!.outerHtml)[0];
|
||||||
|
int startIndex = scriptContent.indexOf('{');
|
||||||
|
int endIndex = scriptContent.lastIndexOf('};');
|
||||||
|
String jsonContent = scriptContent.substring(startIndex, endIndex + 1);
|
||||||
|
// 解析JSON字符串为Map
|
||||||
|
Map<String, dynamic> jsonData = json.decode(jsonContent);
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': jsonData['resourceList']
|
||||||
|
.map<MediaVideoItemModel>((e) => MediaVideoItemModel.fromJson(e))
|
||||||
|
.toList()
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import '../common/constants.dart';
|
import '../common/constants.dart';
|
||||||
import '../models/common/reply_type.dart';
|
import '../models/common/reply_type.dart';
|
||||||
@ -95,6 +97,8 @@ class VideoHttp {
|
|||||||
for (var i in res.data['data']['items']) {
|
for (var i in res.data['data']['items']) {
|
||||||
// 屏蔽推广和拉黑用户
|
// 屏蔽推广和拉黑用户
|
||||||
if (i['card_goto'] != 'ad_av' &&
|
if (i['card_goto'] != 'ad_av' &&
|
||||||
|
i['card_goto'] != 'ad_web_s' &&
|
||||||
|
i['card_goto'] != 'ad_web' &&
|
||||||
(!enableRcmdDynamic ? i['card_goto'] != 'picture' : true) &&
|
(!enableRcmdDynamic ? i['card_goto'] != 'picture' : true) &&
|
||||||
(i['args'] != null &&
|
(i['args'] != null &&
|
||||||
!blackMidsList.contains(i['args']['up_mid']))) {
|
!blackMidsList.contains(i['args']['up_mid']))) {
|
||||||
@ -346,23 +350,37 @@ class VideoHttp {
|
|||||||
required String message,
|
required String message,
|
||||||
int? root,
|
int? root,
|
||||||
int? parent,
|
int? parent,
|
||||||
|
List<Map<dynamic, dynamic>>? pictures,
|
||||||
}) async {
|
}) async {
|
||||||
if (message == '') {
|
if (message == '') {
|
||||||
return {'status': false, 'data': [], 'msg': '请输入评论内容'};
|
return {'status': false, 'data': [], 'msg': '请输入评论内容'};
|
||||||
}
|
}
|
||||||
|
var params = <String, dynamic>{
|
||||||
|
'plat': 1,
|
||||||
|
'oid': oid,
|
||||||
|
'type': type.index,
|
||||||
|
'root': root == null || root == 0 ? '' : root,
|
||||||
|
'parent': parent == null || parent == 0 ? '' : parent,
|
||||||
|
'message': message,
|
||||||
|
'at_name_to_mid': {},
|
||||||
|
if (pictures != null) 'pictures': jsonEncode(pictures),
|
||||||
|
'gaia_source': 'main_web',
|
||||||
|
'csrf': await Request.getCsrf(),
|
||||||
|
};
|
||||||
|
Map sign = await WbiSign().makSign(params);
|
||||||
|
params.remove('wts');
|
||||||
|
params.remove('w_rid');
|
||||||
|
FormData formData = FormData.fromMap({...params});
|
||||||
var res = await Request().post(
|
var res = await Request().post(
|
||||||
Api.replyAdd,
|
Api.replyAdd,
|
||||||
data: {
|
queryParameters: {
|
||||||
'type': type.index,
|
'w_rid': sign['w_rid'],
|
||||||
'oid': oid,
|
'wts': sign['wts'],
|
||||||
'root': root == null || root == 0 ? '' : root,
|
|
||||||
'parent': parent == null || parent == 0 ? '' : parent,
|
|
||||||
'message': message,
|
|
||||||
'csrf': await Request.getCsrf(),
|
|
||||||
},
|
},
|
||||||
|
data: formData,
|
||||||
);
|
);
|
||||||
log(res.toString());
|
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
|
log(res.toString());
|
||||||
return {'status': true, 'data': res.data['data']};
|
return {'status': true, 'data': res.data['data']};
|
||||||
} else {
|
} else {
|
||||||
return {'status': false, 'data': [], 'msg': res.data['message']};
|
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||||
@ -491,10 +509,11 @@ class VideoHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future getSubtitle({int? cid, String? bvid}) async {
|
static Future getSubtitle({int? cid, String? bvid, String? aid}) async {
|
||||||
var res = await Request().get(Api.getSubtitleConfig, data: {
|
var res = await Request().get(Api.getSubtitleConfig, data: {
|
||||||
'cid': cid,
|
'cid': cid,
|
||||||
'bvid': bvid,
|
if (bvid != null) 'bvid': bvid,
|
||||||
|
if (aid != null) 'aid': aid,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
|
|||||||
@ -144,6 +144,7 @@ class EpisodeItem {
|
|||||||
this.link,
|
this.link,
|
||||||
this.longTitle,
|
this.longTitle,
|
||||||
this.pubTime,
|
this.pubTime,
|
||||||
|
this.pubdate,
|
||||||
this.pv,
|
this.pv,
|
||||||
this.releaseDate,
|
this.releaseDate,
|
||||||
this.rights,
|
this.rights,
|
||||||
@ -155,6 +156,7 @@ class EpisodeItem {
|
|||||||
this.subtitle,
|
this.subtitle,
|
||||||
this.title,
|
this.title,
|
||||||
this.vid,
|
this.vid,
|
||||||
|
this.stat,
|
||||||
});
|
});
|
||||||
|
|
||||||
int? aid;
|
int? aid;
|
||||||
@ -173,6 +175,7 @@ class EpisodeItem {
|
|||||||
String? link;
|
String? link;
|
||||||
String? longTitle;
|
String? longTitle;
|
||||||
int? pubTime;
|
int? pubTime;
|
||||||
|
int? pubdate;
|
||||||
int? pv;
|
int? pv;
|
||||||
String? releaseDate;
|
String? releaseDate;
|
||||||
Map? rights;
|
Map? rights;
|
||||||
@ -184,6 +187,7 @@ class EpisodeItem {
|
|||||||
String? subtitle;
|
String? subtitle;
|
||||||
String? title;
|
String? title;
|
||||||
String? vid;
|
String? vid;
|
||||||
|
String? stat;
|
||||||
|
|
||||||
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
||||||
aid = json['aid'];
|
aid = json['aid'];
|
||||||
@ -202,6 +206,7 @@ class EpisodeItem {
|
|||||||
link = json['link'];
|
link = json['link'];
|
||||||
longTitle = json['long_title'];
|
longTitle = json['long_title'];
|
||||||
pubTime = json['pub_time'];
|
pubTime = json['pub_time'];
|
||||||
|
pubdate = json['pub_time'];
|
||||||
pv = json['pv'];
|
pv = json['pv'];
|
||||||
releaseDate = json['release_date'];
|
releaseDate = json['release_date'];
|
||||||
rights = json['rights'];
|
rights = json['rights'];
|
||||||
@ -211,7 +216,7 @@ class EpisodeItem {
|
|||||||
skip = json['skip'];
|
skip = json['skip'];
|
||||||
status = json['status'];
|
status = json['status'];
|
||||||
subtitle = json['subtitle'];
|
subtitle = json['subtitle'];
|
||||||
title = json['title'];
|
title = json['long_title'];
|
||||||
vid = json['vid'];
|
vid = json['vid'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class BangumiListItemModel {
|
|||||||
this.title,
|
this.title,
|
||||||
this.titleIcon,
|
this.titleIcon,
|
||||||
this.progress,
|
this.progress,
|
||||||
|
this.progressIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
String? badge;
|
String? badge;
|
||||||
@ -66,8 +67,8 @@ class BangumiListItemModel {
|
|||||||
String? subTitle;
|
String? subTitle;
|
||||||
String? title;
|
String? title;
|
||||||
String? titleIcon;
|
String? titleIcon;
|
||||||
|
|
||||||
String? progress;
|
String? progress;
|
||||||
|
int? progressIndex;
|
||||||
|
|
||||||
BangumiListItemModel.fromJson(Map<String, dynamic> json) {
|
BangumiListItemModel.fromJson(Map<String, dynamic> json) {
|
||||||
badge = json['badge'] == '' ? null : json['badge'];
|
badge = json['badge'] == '' ? null : json['badge'];
|
||||||
@ -87,7 +88,9 @@ class BangumiListItemModel {
|
|||||||
subTitle = json['sub_title'];
|
subTitle = json['sub_title'];
|
||||||
title = json['title'];
|
title = json['title'];
|
||||||
titleIcon = json['title_icon'];
|
titleIcon = json['title_icon'];
|
||||||
|
|
||||||
progress = json['progress'];
|
progress = json['progress'];
|
||||||
|
progressIndex = int.parse(
|
||||||
|
RegExp(r'第(\d+)话').firstMatch(json['progress'] ?? '第1话')?.group(1) ??
|
||||||
|
'0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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(),
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class LiveFollowingItemModel {
|
|||||||
String? roomNews;
|
String? roomNews;
|
||||||
String? watchIcon;
|
String? watchIcon;
|
||||||
String? textSmall;
|
String? textSmall;
|
||||||
String? roomCover;
|
String? cover;
|
||||||
String? pic;
|
String? pic;
|
||||||
int? parentAreaId;
|
int? parentAreaId;
|
||||||
int? areaId;
|
int? areaId;
|
||||||
@ -90,7 +90,7 @@ class LiveFollowingItemModel {
|
|||||||
this.roomNews,
|
this.roomNews,
|
||||||
this.watchIcon,
|
this.watchIcon,
|
||||||
this.textSmall,
|
this.textSmall,
|
||||||
this.roomCover,
|
this.cover,
|
||||||
this.pic,
|
this.pic,
|
||||||
this.parentAreaId,
|
this.parentAreaId,
|
||||||
this.areaId,
|
this.areaId,
|
||||||
@ -108,7 +108,8 @@ class LiveFollowingItemModel {
|
|||||||
isAttention = json['is_attention'];
|
isAttention = json['is_attention'];
|
||||||
clipNum = json['clipnum'];
|
clipNum = json['clipnum'];
|
||||||
fansNum = json['fans_num'];
|
fansNum = json['fans_num'];
|
||||||
areaName = json['area_name'];
|
areaName =
|
||||||
|
json['area_name'] == '' ? json['area_name_v2'] : json['area_name'];
|
||||||
areaValue = json['area_value'];
|
areaValue = json['area_value'];
|
||||||
tags = json['tags'];
|
tags = json['tags'];
|
||||||
recentRecordIdV2 = json['recent_record_id_v2'];
|
recentRecordIdV2 = json['recent_record_id_v2'];
|
||||||
@ -118,7 +119,7 @@ class LiveFollowingItemModel {
|
|||||||
roomNews = json['room_news'];
|
roomNews = json['room_news'];
|
||||||
watchIcon = json['watch_icon'];
|
watchIcon = json['watch_icon'];
|
||||||
textSmall = json['text_small'];
|
textSmall = json['text_small'];
|
||||||
roomCover = json['room_cover'];
|
cover = json['room_cover'];
|
||||||
pic = json['room_cover'];
|
pic = json['room_cover'];
|
||||||
parentAreaId = json['parent_area_id'];
|
parentAreaId = json['parent_area_id'];
|
||||||
areaId = json['area_id'];
|
areaId = json['area_id'];
|
||||||
|
|||||||
@ -8,6 +8,7 @@ class MemberInfoModel {
|
|||||||
this.level,
|
this.level,
|
||||||
this.isFollowed,
|
this.isFollowed,
|
||||||
this.topPhoto,
|
this.topPhoto,
|
||||||
|
this.silence,
|
||||||
this.official,
|
this.official,
|
||||||
this.vip,
|
this.vip,
|
||||||
this.liveRoom,
|
this.liveRoom,
|
||||||
@ -21,6 +22,7 @@ class MemberInfoModel {
|
|||||||
int? level;
|
int? level;
|
||||||
bool? isFollowed;
|
bool? isFollowed;
|
||||||
String? topPhoto;
|
String? topPhoto;
|
||||||
|
int? silence;
|
||||||
Map? official;
|
Map? official;
|
||||||
Vip? vip;
|
Vip? vip;
|
||||||
LiveRoom? liveRoom;
|
LiveRoom? liveRoom;
|
||||||
@ -34,6 +36,7 @@ class MemberInfoModel {
|
|||||||
level = json['level'];
|
level = json['level'];
|
||||||
isFollowed = json['is_followed'];
|
isFollowed = json['is_followed'];
|
||||||
topPhoto = json['top_photo'];
|
topPhoto = json['top_photo'];
|
||||||
|
silence = json['silence'] ?? 0;
|
||||||
official = json['official'];
|
official = json['official'];
|
||||||
vip = Vip.fromJson(json['vip']);
|
vip = Vip.fromJson(json['vip']);
|
||||||
liveRoom =
|
liveRoom =
|
||||||
|
|||||||
140
lib/models/msg/at.dart
Normal file
140
lib/models/msg/at.dart
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
class MessageAtModel {
|
||||||
|
Cursor? cursor;
|
||||||
|
List<MessageAtItems>? items;
|
||||||
|
|
||||||
|
MessageAtModel({this.cursor, this.items});
|
||||||
|
|
||||||
|
MessageAtModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
cursor = json['cursor'] != null ? Cursor.fromJson(json['cursor']) : null;
|
||||||
|
if (json['items'] != null) {
|
||||||
|
items = <MessageAtItems>[];
|
||||||
|
json['items'].forEach((v) {
|
||||||
|
items!.add(MessageAtItems.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Cursor {
|
||||||
|
Cursor({
|
||||||
|
this.id,
|
||||||
|
this.isEnd,
|
||||||
|
this.time,
|
||||||
|
});
|
||||||
|
|
||||||
|
int? id;
|
||||||
|
bool? isEnd;
|
||||||
|
int? time;
|
||||||
|
|
||||||
|
Cursor.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
isEnd = json['isEnd'];
|
||||||
|
time = json['time'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessageAtItems {
|
||||||
|
int? id;
|
||||||
|
int? atTime;
|
||||||
|
User? user;
|
||||||
|
MessageAtItem? item;
|
||||||
|
|
||||||
|
MessageAtItems({this.id, this.atTime, this.user, this.item});
|
||||||
|
|
||||||
|
MessageAtItems.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
atTime = json['at_time'];
|
||||||
|
user = json['user'] != null ? User.fromJson(json['user']) : null;
|
||||||
|
item = json['item'] != null ? MessageAtItem.fromJson(json['item']) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessageAtItem {
|
||||||
|
String? type;
|
||||||
|
String? business;
|
||||||
|
int? businessId;
|
||||||
|
String? title;
|
||||||
|
String? image;
|
||||||
|
String? uri;
|
||||||
|
int? subjectId;
|
||||||
|
int? rootId;
|
||||||
|
int? targetId;
|
||||||
|
int? sourceId;
|
||||||
|
String? sourceContent;
|
||||||
|
String? nativeUri;
|
||||||
|
List<User>? atDetails;
|
||||||
|
List<dynamic>? topicDetails;
|
||||||
|
bool? hideReplyButton;
|
||||||
|
|
||||||
|
MessageAtItem({
|
||||||
|
this.type,
|
||||||
|
this.business,
|
||||||
|
this.businessId,
|
||||||
|
this.title,
|
||||||
|
this.image,
|
||||||
|
this.uri,
|
||||||
|
this.subjectId,
|
||||||
|
this.rootId,
|
||||||
|
this.targetId,
|
||||||
|
this.sourceId,
|
||||||
|
this.sourceContent,
|
||||||
|
this.nativeUri,
|
||||||
|
this.atDetails,
|
||||||
|
this.topicDetails,
|
||||||
|
this.hideReplyButton,
|
||||||
|
});
|
||||||
|
|
||||||
|
MessageAtItem.fromJson(Map<String, dynamic> json) {
|
||||||
|
type = json['type'];
|
||||||
|
business = json['business'];
|
||||||
|
businessId = json['business_id'];
|
||||||
|
title = json['title'];
|
||||||
|
image = json['image'];
|
||||||
|
uri = json['uri'];
|
||||||
|
subjectId = json['subject_id'];
|
||||||
|
rootId = json['root_id'];
|
||||||
|
targetId = json['target_id'];
|
||||||
|
sourceId = json['source_id'];
|
||||||
|
sourceContent = json['source_content'];
|
||||||
|
nativeUri = json['native_uri'];
|
||||||
|
if (json['at_details'] != null) {
|
||||||
|
atDetails = <User>[];
|
||||||
|
json['at_details'].forEach((v) {
|
||||||
|
atDetails!.add(User.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['topic_details'] != null) {
|
||||||
|
topicDetails = <dynamic>[];
|
||||||
|
json['topic_details'].forEach((v) {
|
||||||
|
topicDetails!.add(v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hideReplyButton = json['hide_reply_button'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class User {
|
||||||
|
int? mid;
|
||||||
|
int? fans;
|
||||||
|
String? nickname;
|
||||||
|
String? avatar;
|
||||||
|
String? midLink;
|
||||||
|
bool? follow;
|
||||||
|
|
||||||
|
User(
|
||||||
|
{this.mid,
|
||||||
|
this.fans,
|
||||||
|
this.nickname,
|
||||||
|
this.avatar,
|
||||||
|
this.midLink,
|
||||||
|
this.follow});
|
||||||
|
|
||||||
|
User.fromJson(Map<String, dynamic> json) {
|
||||||
|
mid = json['mid'];
|
||||||
|
fans = json['fans'];
|
||||||
|
nickname = json['nickname'];
|
||||||
|
avatar = json['avatar'];
|
||||||
|
midLink = json['mid_link'];
|
||||||
|
follow = json['follow'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -39,7 +39,7 @@ class Total {
|
|||||||
List<MessageLikeItem>? items;
|
List<MessageLikeItem>? items;
|
||||||
|
|
||||||
factory Total.fromJson(Map<String, dynamic> json) => Total(
|
factory Total.fromJson(Map<String, dynamic> json) => Total(
|
||||||
cursor: Cursor.fromJson(json['cursor']),
|
cursor: json['cursor'] != null ? Cursor.fromJson(json['cursor']) : null,
|
||||||
items: json["items"] == null
|
items: json["items"] == null
|
||||||
? []
|
? []
|
||||||
: json["items"].map<MessageLikeItem>((e) {
|
: json["items"].map<MessageLikeItem>((e) {
|
||||||
|
|||||||
@ -13,8 +13,9 @@ class SessionDataModel {
|
|||||||
|
|
||||||
SessionDataModel.fromJson(Map<String, dynamic> json) {
|
SessionDataModel.fromJson(Map<String, dynamic> json) {
|
||||||
sessionList = json['session_list']
|
sessionList = json['session_list']
|
||||||
?.map<SessionList>((e) => SessionList.fromJson(e))
|
?.map<SessionList>((e) => SessionList.fromJson(e))
|
||||||
.toList();
|
.toList() ??
|
||||||
|
[];
|
||||||
hasMore = json['has_more'];
|
hasMore = json['has_more'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
class ReplyContent {
|
class ReplyContent {
|
||||||
ReplyContent({
|
ReplyContent({
|
||||||
this.message,
|
this.message,
|
||||||
|
this.message2,
|
||||||
this.atNameToMid, // @的用户的mid null
|
this.atNameToMid, // @的用户的mid null
|
||||||
this.members, // 被@的用户List 如果有的话 []
|
this.members, // 被@的用户List 如果有的话 []
|
||||||
this.emote, // 表情包 如果有的话 null
|
this.emote, // 表情包 如果有的话 null
|
||||||
@ -13,6 +14,7 @@ class ReplyContent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
String? message;
|
String? message;
|
||||||
|
String? message2;
|
||||||
Map? atNameToMid;
|
Map? atNameToMid;
|
||||||
List<MemberItemModel>? members;
|
List<MemberItemModel>? members;
|
||||||
Map? emote;
|
Map? emote;
|
||||||
@ -24,10 +26,17 @@ class ReplyContent {
|
|||||||
Map? topicsMeta;
|
Map? topicsMeta;
|
||||||
|
|
||||||
ReplyContent.fromJson(Map<String, dynamic> json) {
|
ReplyContent.fromJson(Map<String, dynamic> json) {
|
||||||
message = json['message']
|
message = message2 = json['message']
|
||||||
.replaceAll('>', '>')
|
.replaceAll('>', '>')
|
||||||
.replaceAll('"', '"')
|
.replaceAll('"', '"')
|
||||||
.replaceAll(''', "'");
|
.replaceAll(''', "'")
|
||||||
|
.replaceAll('&', '&')
|
||||||
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>')
|
||||||
|
.replaceAll('"', '"')
|
||||||
|
.replaceAll(''', "'")
|
||||||
|
.replaceAll(' ', ' ');
|
||||||
|
|
||||||
atNameToMid = json['at_name_to_mid'] ?? {};
|
atNameToMid = json['at_name_to_mid'] ?? {};
|
||||||
members = json['members'] != null
|
members = json['members'] != null
|
||||||
? json['members']
|
? json['members']
|
||||||
@ -39,8 +48,8 @@ class ReplyContent {
|
|||||||
pictures = json['pictures'] ?? [];
|
pictures = json['pictures'] ?? [];
|
||||||
vote = json['vote'] ?? {};
|
vote = json['vote'] ?? {};
|
||||||
richText = json['rich_text'] ?? {};
|
richText = json['rich_text'] ?? {};
|
||||||
// 不包含@ 笔记 图片的时候,文字可折叠
|
// 不包含@ 笔记的时候,文字可折叠
|
||||||
isText = atNameToMid!.isEmpty && vote!.isEmpty && pictures!.isEmpty;
|
isText = atNameToMid!.isEmpty && vote!.isEmpty;
|
||||||
topicsMeta = json['topics_meta'] ?? {};
|
topicsMeta = json['topics_meta'] ?? {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,21 +6,21 @@ import 'upper.dart';
|
|||||||
|
|
||||||
class ReplyData {
|
class ReplyData {
|
||||||
ReplyData({
|
ReplyData({
|
||||||
this.page,
|
this.cursor,
|
||||||
this.config,
|
this.config,
|
||||||
this.replies,
|
this.replies,
|
||||||
this.topReplies,
|
this.topReplies,
|
||||||
this.upper,
|
this.upper,
|
||||||
});
|
});
|
||||||
|
|
||||||
ReplyPage? page;
|
ReplyCursor? cursor;
|
||||||
ReplyConfig? config;
|
ReplyConfig? config;
|
||||||
late List<ReplyItemModel>? replies;
|
late List<ReplyItemModel>? replies;
|
||||||
late List<ReplyItemModel>? topReplies;
|
late List<ReplyItemModel>? topReplies;
|
||||||
ReplyUpper? upper;
|
ReplyUpper? upper;
|
||||||
|
|
||||||
ReplyData.fromJson(Map<String, dynamic> json) {
|
ReplyData.fromJson(Map<String, dynamic> json) {
|
||||||
page = ReplyPage.fromJson(json['page']);
|
cursor = ReplyCursor.fromJson(json['cursor']);
|
||||||
config = ReplyConfig.fromJson(json['config']);
|
config = ReplyConfig.fromJson(json['config']);
|
||||||
replies = json['replies'] != null
|
replies = json['replies'] != null
|
||||||
? json['replies']
|
? json['replies']
|
||||||
@ -38,3 +38,100 @@ class ReplyData {
|
|||||||
upper = ReplyUpper.fromJson(json['upper']);
|
upper = ReplyUpper.fromJson(json['upper']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ReplyCursor {
|
||||||
|
ReplyCursor({
|
||||||
|
this.isBegin,
|
||||||
|
this.prev,
|
||||||
|
this.next,
|
||||||
|
this.isEnd,
|
||||||
|
this.mode,
|
||||||
|
this.modeText,
|
||||||
|
this.allCount,
|
||||||
|
this.supportMode,
|
||||||
|
this.name,
|
||||||
|
this.paginationReply,
|
||||||
|
this.sessionId,
|
||||||
|
});
|
||||||
|
|
||||||
|
bool? isBegin;
|
||||||
|
int? prev;
|
||||||
|
int? next;
|
||||||
|
bool? isEnd;
|
||||||
|
int? mode;
|
||||||
|
String? modeText;
|
||||||
|
int? allCount;
|
||||||
|
List<int>? supportMode;
|
||||||
|
String? name;
|
||||||
|
PaginationReply? paginationReply;
|
||||||
|
String? sessionId;
|
||||||
|
|
||||||
|
ReplyCursor.fromJson(Map<String, dynamic> json) {
|
||||||
|
isBegin = json['is_begin'];
|
||||||
|
prev = json['prev'];
|
||||||
|
next = json['next'];
|
||||||
|
isEnd = json['is_end'];
|
||||||
|
mode = json['mode'];
|
||||||
|
modeText = json['mode_text'];
|
||||||
|
allCount = json['all_count'] ?? 0;
|
||||||
|
supportMode = json['support_mode'].cast<int>();
|
||||||
|
name = json['name'];
|
||||||
|
paginationReply = json['pagination_reply'] != null
|
||||||
|
? PaginationReply.fromJson(json['pagination_reply'])
|
||||||
|
: null;
|
||||||
|
sessionId = json['session_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PaginationReply {
|
||||||
|
PaginationReply({
|
||||||
|
this.nextOffset,
|
||||||
|
this.prevOffset,
|
||||||
|
});
|
||||||
|
String? nextOffset;
|
||||||
|
String? prevOffset;
|
||||||
|
PaginationReply.fromJson(Map<String, dynamic> json) {
|
||||||
|
nextOffset = json['next_offset'];
|
||||||
|
prevOffset = json['prev_offset'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReplyReplyData {
|
||||||
|
ReplyReplyData({
|
||||||
|
this.page,
|
||||||
|
this.config,
|
||||||
|
this.replies,
|
||||||
|
this.root,
|
||||||
|
this.topReplies,
|
||||||
|
this.upper,
|
||||||
|
});
|
||||||
|
|
||||||
|
ReplyPage? page;
|
||||||
|
ReplyConfig? config;
|
||||||
|
late List<ReplyItemModel>? replies;
|
||||||
|
ReplyItemModel? root;
|
||||||
|
late List<ReplyItemModel>? topReplies;
|
||||||
|
ReplyUpper? upper;
|
||||||
|
|
||||||
|
ReplyReplyData.fromJson(Map<String, dynamic> json) {
|
||||||
|
page = ReplyPage.fromJson(json['page']);
|
||||||
|
config = ReplyConfig.fromJson(json['config']);
|
||||||
|
replies = json['replies'] != null
|
||||||
|
? json['replies']
|
||||||
|
.map<ReplyItemModel>(
|
||||||
|
(item) => ReplyItemModel.fromJson(item, json['upper']['mid']))
|
||||||
|
.toList()
|
||||||
|
: [];
|
||||||
|
root = json['root'] != null
|
||||||
|
? ReplyItemModel.fromJson(json['root'], false)
|
||||||
|
: null;
|
||||||
|
topReplies = json['top_replies'] != null
|
||||||
|
? json['top_replies']
|
||||||
|
.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
|
||||||
|
item, json['upper']['mid'],
|
||||||
|
isTopStatus: true))
|
||||||
|
.toList()
|
||||||
|
: [];
|
||||||
|
upper = ReplyUpper.fromJson(json['upper']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ class ReplyItemModel {
|
|||||||
this.parent,
|
this.parent,
|
||||||
this.dialog,
|
this.dialog,
|
||||||
this.count,
|
this.count,
|
||||||
|
this.rcount,
|
||||||
this.floor,
|
this.floor,
|
||||||
this.state,
|
this.state,
|
||||||
this.fansgrade,
|
this.fansgrade,
|
||||||
@ -41,6 +42,7 @@ class ReplyItemModel {
|
|||||||
int? parent;
|
int? parent;
|
||||||
int? dialog;
|
int? dialog;
|
||||||
int? count;
|
int? count;
|
||||||
|
int? rcount;
|
||||||
int? floor;
|
int? floor;
|
||||||
int? state;
|
int? state;
|
||||||
int? fansgrade;
|
int? fansgrade;
|
||||||
@ -72,6 +74,7 @@ class ReplyItemModel {
|
|||||||
parent = json['parent'];
|
parent = json['parent'];
|
||||||
dialog = json['dialog'];
|
dialog = json['dialog'];
|
||||||
count = json['count'];
|
count = json['count'];
|
||||||
|
rcount = json['rcount'] ?? 0;
|
||||||
floor = json['floor'];
|
floor = json['floor'];
|
||||||
state = json['state'];
|
state = json['state'];
|
||||||
fansgrade = json['fansgrade'];
|
fansgrade = json['fansgrade'];
|
||||||
|
|||||||
@ -377,6 +377,7 @@ class Part {
|
|||||||
int? page;
|
int? page;
|
||||||
String? from;
|
String? from;
|
||||||
String? pagePart;
|
String? pagePart;
|
||||||
|
String? title;
|
||||||
int? duration;
|
int? duration;
|
||||||
String? vid;
|
String? vid;
|
||||||
String? weblink;
|
String? weblink;
|
||||||
@ -389,6 +390,7 @@ class Part {
|
|||||||
this.page,
|
this.page,
|
||||||
this.from,
|
this.from,
|
||||||
this.pagePart,
|
this.pagePart,
|
||||||
|
this.title,
|
||||||
this.duration,
|
this.duration,
|
||||||
this.vid,
|
this.vid,
|
||||||
this.weblink,
|
this.weblink,
|
||||||
@ -406,6 +408,7 @@ class Part {
|
|||||||
page = json["page"];
|
page = json["page"];
|
||||||
from = json["from"];
|
from = json["from"];
|
||||||
pagePart = json["part"];
|
pagePart = json["part"];
|
||||||
|
title = json["part"];
|
||||||
duration = json["duration"];
|
duration = json["duration"];
|
||||||
vid = json["vid"];
|
vid = json["vid"];
|
||||||
weblink = json["weblink"];
|
weblink = json["weblink"];
|
||||||
@ -649,6 +652,9 @@ class EpisodeItem {
|
|||||||
Part? page;
|
Part? page;
|
||||||
String? bvid;
|
String? bvid;
|
||||||
String? cover;
|
String? cover;
|
||||||
|
int? pubdate;
|
||||||
|
int? duration;
|
||||||
|
Stat? stat;
|
||||||
|
|
||||||
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
||||||
seasonId = json['season_id'];
|
seasonId = json['season_id'];
|
||||||
@ -661,6 +667,9 @@ class EpisodeItem {
|
|||||||
page = Part.fromJson(json['page']);
|
page = Part.fromJson(json['page']);
|
||||||
bvid = json['bvid'];
|
bvid = json['bvid'];
|
||||||
cover = json['arc']['pic'];
|
cover = json['arc']['pic'];
|
||||||
|
pubdate = json['arc']['pubdate'];
|
||||||
|
duration = json['arc']['duration'];
|
||||||
|
stat = Stat.fromJson(json['arc']['stat']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:pilipala/http/index.dart';
|
import 'package:pilipala/http/index.dart';
|
||||||
import 'package:pilipala/models/github/latest.dart';
|
import 'package:pilipala/models/github/latest.dart';
|
||||||
|
import 'package:pilipala/plugin/pl_gallery/index.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import '../../utils/cache_manage.dart';
|
import '../../utils/cache_manage.dart';
|
||||||
@ -124,7 +125,7 @@ class _AboutPageState extends State<AboutPage> {
|
|||||||
onTap: () => _aboutController.webSiteUrl(),
|
onTap: () => _aboutController.webSiteUrl(),
|
||||||
title: const Text('访问官网'),
|
title: const Text('访问官网'),
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
'https://pilipalanet.mysxl.cn',
|
'https://pilipala.life',
|
||||||
style: subTitleStyle,
|
style: subTitleStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -168,7 +169,7 @@ class _AboutPageState extends State<AboutPage> {
|
|||||||
onTap: () => _aboutController.tgChanel(),
|
onTap: () => _aboutController.tgChanel(),
|
||||||
title: const Text('TG频道'),
|
title: const Text('TG频道'),
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
'https://t.me/+lm_oOVmF0RJiODk1',
|
'https://t.me/+1DFtqS6usUM5MDNl',
|
||||||
style: subTitleStyle,
|
style: subTitleStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -321,29 +322,35 @@ class AboutController extends GetxController {
|
|||||||
// tg频道
|
// tg频道
|
||||||
tgChanel() {
|
tgChanel() {
|
||||||
Clipboard.setData(
|
Clipboard.setData(
|
||||||
const ClipboardData(text: 'https://t.me/+lm_oOVmF0RJiODk1'),
|
const ClipboardData(text: 'https://t.me/+1DFtqS6usUM5MDNl'),
|
||||||
);
|
);
|
||||||
SmartDialog.showToast(
|
SmartDialog.showToast(
|
||||||
'已复制,即将在浏览器打开',
|
'已复制,即将在浏览器打开',
|
||||||
displayTime: const Duration(milliseconds: 500),
|
displayTime: const Duration(milliseconds: 500),
|
||||||
).then(
|
).then(
|
||||||
(value) => launchUrl(
|
(value) => launchUrl(
|
||||||
Uri.parse('https://t.me/+lm_oOVmF0RJiODk1'),
|
Uri.parse('https://t.me/+1DFtqS6usUM5MDNl'),
|
||||||
mode: LaunchMode.externalApplication,
|
mode: LaunchMode.externalApplication,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
aPay() {
|
aPay() {
|
||||||
try {
|
const List<String> sources = [
|
||||||
launchUrl(
|
'assets/images/pay/wechat.png',
|
||||||
Uri.parse(
|
'assets/images/pay/alipay.jpg'
|
||||||
'alipayqr://platformapi/startapp?saId=10000007&qrcode=https://qr.alipay.com/fkx14623ddwl1ping3ddd73'),
|
];
|
||||||
mode: LaunchMode.externalApplication,
|
Navigator.of(Get.context!).push(
|
||||||
);
|
HeroDialogRoute<void>(
|
||||||
} catch (e) {
|
builder: (BuildContext context) => InteractiveviewerGallery(
|
||||||
print(e);
|
sources: sources,
|
||||||
}
|
initIndex: 0,
|
||||||
|
itemBuilder: (context, index, isFocus, enablePageView) =>
|
||||||
|
Image.asset(sources[index]),
|
||||||
|
actionType: const [ImgActionType.save],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 官网
|
// 官网
|
||||||
|
|||||||
@ -9,6 +9,7 @@ class BangumiController extends GetxController {
|
|||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
RxList<BangumiListItemModel> bangumiList = <BangumiListItemModel>[].obs;
|
RxList<BangumiListItemModel> bangumiList = <BangumiListItemModel>[].obs;
|
||||||
RxList<BangumiListItemModel> bangumiFollowList = <BangumiListItemModel>[].obs;
|
RxList<BangumiListItemModel> bangumiFollowList = <BangumiListItemModel>[].obs;
|
||||||
|
RxInt total = 0.obs;
|
||||||
int _currentPage = 1;
|
int _currentPage = 1;
|
||||||
bool isLoadingMore = true;
|
bool isLoadingMore = true;
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
@ -54,9 +55,10 @@ class BangumiController extends GetxController {
|
|||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result = await BangumiHttp.bangumiFollow(mid: userInfo.mid);
|
var result = await BangumiHttp.getRecentBangumi(mid: userInfo.mid);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
bangumiFollowList.value = result['data'].list;
|
bangumiFollowList.value = result['data'].list;
|
||||||
|
total.value = result['data'].total;
|
||||||
} else {}
|
} else {}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ 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:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/http/bangumi.dart';
|
||||||
import 'package:pilipala/http/constants.dart';
|
import 'package:pilipala/http/constants.dart';
|
||||||
import 'package:pilipala/http/search.dart';
|
import 'package:pilipala/http/search.dart';
|
||||||
import 'package:pilipala/http/video.dart';
|
import 'package:pilipala/http/video.dart';
|
||||||
@ -23,7 +24,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
// 视频bvid
|
// 视频bvid
|
||||||
String bvid = Get.parameters['bvid']!;
|
String bvid = Get.parameters['bvid']!;
|
||||||
var seasonId = Get.parameters['seasonId'] != null
|
var seasonId = Get.parameters['seasonId'] != null
|
||||||
? int.parse(Get.parameters['seasonId']!)
|
? int.tryParse(Get.parameters['seasonId']!)
|
||||||
: null;
|
: null;
|
||||||
var epId = Get.parameters['epId'] != null
|
var epId = Get.parameters['epId'] != null
|
||||||
? int.tryParse(Get.parameters['epId']!)
|
? int.tryParse(Get.parameters['epId']!)
|
||||||
@ -52,28 +53,35 @@ class BangumiIntroController extends GetxController {
|
|||||||
Rx<FavFolderData> favFolderData = FavFolderData().obs;
|
Rx<FavFolderData> favFolderData = FavFolderData().obs;
|
||||||
List addMediaIdsNew = [];
|
List addMediaIdsNew = [];
|
||||||
List delMediaIdsNew = [];
|
List delMediaIdsNew = [];
|
||||||
// 关注状态 默认未关注
|
// 追番状态 1想看 2在看 3已看
|
||||||
RxMap followStatus = {}.obs;
|
RxBool isFollowed = false.obs;
|
||||||
|
RxInt followStatus = 1.obs;
|
||||||
int _tempThemeValue = -1;
|
int _tempThemeValue = -1;
|
||||||
var userInfo;
|
var userInfo;
|
||||||
PersistentBottomSheetController? bottomSheetController;
|
PersistentBottomSheetController? bottomSheetController;
|
||||||
|
List<Map<String, dynamic>> followStatusList = [
|
||||||
|
{'title': '标记为 「想看」', 'status': 1},
|
||||||
|
{'title': '标记为 「在看」', 'status': 2},
|
||||||
|
{'title': '标记为 「已看」', 'status': 3},
|
||||||
|
{'title': '取消追番', 'status': -1},
|
||||||
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
print('bangumi: ${Get.parameters.toString()}');
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
userLogin = userInfo != null;
|
userLogin = userInfo != null;
|
||||||
|
if (userLogin && seasonId != null) {
|
||||||
|
bangumiStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取番剧简介&选集
|
// 获取番剧简介&选集
|
||||||
Future queryBangumiIntro() async {
|
Future queryBangumiIntro() async {
|
||||||
if (userLogin) {
|
if (userLogin) {
|
||||||
// 获取点赞状态
|
// 获取点赞投币收藏状态
|
||||||
queryHasLikeVideo();
|
bangumiActionStatus();
|
||||||
// 获取投币状态
|
|
||||||
queryHasCoinVideo();
|
|
||||||
// 获取收藏状态
|
|
||||||
queryHasFavVideo();
|
|
||||||
}
|
}
|
||||||
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
@ -83,26 +91,15 @@ class BangumiIntroController extends GetxController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取点赞状态
|
// 获取番剧点赞投币收藏状态
|
||||||
Future queryHasLikeVideo() async {
|
Future bangumiActionStatus() async {
|
||||||
var result = await VideoHttp.hasLikeVideo(bvid: bvid);
|
var result = await BangumiHttp.bangumiActionStatus(epId: epId!);
|
||||||
// data num 被点赞标志 0:未点赞 1:已点赞
|
|
||||||
hasLike.value = result["data"] == 1 ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取投币状态
|
|
||||||
Future queryHasCoinVideo() async {
|
|
||||||
var result = await VideoHttp.hasCoinVideo(bvid: bvid);
|
|
||||||
hasCoin.value = result["data"]['multiply'] == 0 ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取收藏状态
|
|
||||||
Future queryHasFavVideo() async {
|
|
||||||
var result = await VideoHttp.hasFavVideo(aid: IdUtils.bv2av(bvid));
|
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
hasFav.value = result["data"]['favoured'];
|
hasLike.value = result['data']['like'] == 1;
|
||||||
|
hasCoin.value = result['data']['coin_number'] != 0;
|
||||||
|
hasFav.value = result['data']['favorite'] == 1;
|
||||||
} else {
|
} else {
|
||||||
hasFav.value = false;
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +107,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
Future actionLikeVideo() async {
|
Future actionLikeVideo() async {
|
||||||
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
SmartDialog.showToast(!hasLike.value ? '点赞成功 👍' : '取消赞');
|
SmartDialog.showToast(!hasLike.value ? '点赞成功' : '取消赞');
|
||||||
hasLike.value = !hasLike.value;
|
hasLike.value = !hasLike.value;
|
||||||
bangumiDetail.value.stat!['likes'] =
|
bangumiDetail.value.stat!['likes'] =
|
||||||
bangumiDetail.value.stat!['likes'] + (!hasLike.value ? 1 : -1);
|
bangumiDetail.value.stat!['likes'] + (!hasLike.value ? 1 : -1);
|
||||||
@ -147,7 +144,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
var res = await VideoHttp.coinVideo(
|
var res = await VideoHttp.coinVideo(
|
||||||
bvid: bvid, multiply: _tempThemeValue);
|
bvid: bvid, multiply: _tempThemeValue);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast('投币成功 👏');
|
SmartDialog.showToast('投币成功');
|
||||||
hasCoin.value = true;
|
hasCoin.value = true;
|
||||||
bangumiDetail.value.stat!['coins'] =
|
bangumiDetail.value.stat!['coins'] =
|
||||||
bangumiDetail.value.stat!['coins'] +
|
bangumiDetail.value.stat!['coins'] +
|
||||||
@ -185,9 +182,11 @@ class BangumiIntroController extends GetxController {
|
|||||||
addMediaIdsNew = [];
|
addMediaIdsNew = [];
|
||||||
delMediaIdsNew = [];
|
delMediaIdsNew = [];
|
||||||
// 重新获取收藏状态
|
// 重新获取收藏状态
|
||||||
queryHasFavVideo();
|
bangumiActionStatus();
|
||||||
SmartDialog.showToast('✅ 操作成功');
|
SmartDialog.showToast('操作成功');
|
||||||
Get.back();
|
Get.back();
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,15 +238,22 @@ class BangumiIntroController extends GetxController {
|
|||||||
|
|
||||||
// 追番
|
// 追番
|
||||||
Future bangumiAdd() async {
|
Future bangumiAdd() async {
|
||||||
var result =
|
var result = await VideoHttp.bangumiAdd(
|
||||||
await VideoHttp.bangumiAdd(seasonId: bangumiDetail.value.seasonId);
|
seasonId: seasonId ?? bangumiDetail.value.seasonId);
|
||||||
|
if (result['status']) {
|
||||||
|
followStatus.value = 2;
|
||||||
|
isFollowed.value = true;
|
||||||
|
}
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消追番
|
// 取消追番
|
||||||
Future bangumiDel() async {
|
Future bangumiDel() async {
|
||||||
var result =
|
var result = await VideoHttp.bangumiDel(
|
||||||
await VideoHttp.bangumiDel(seasonId: bangumiDetail.value.seasonId);
|
seasonId: seasonId ?? bangumiDetail.value.seasonId);
|
||||||
|
if (result['status']) {
|
||||||
|
isFollowed.value = false;
|
||||||
|
}
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,18 +308,48 @@ class BangumiIntroController extends GetxController {
|
|||||||
episodes: episodes,
|
episodes: episodes,
|
||||||
currentCid: videoDetailCtr.cid.value,
|
currentCid: videoDetailCtr.cid.value,
|
||||||
dataType: dataType,
|
dataType: dataType,
|
||||||
context: Get.context!,
|
|
||||||
sheetHeight: Get.size.height,
|
sheetHeight: Get.size.height,
|
||||||
isFullScreen: true,
|
isFullScreen: true,
|
||||||
changeFucCall: (item, index) {
|
changeFucCall: (item, index) {
|
||||||
changeSeasonOrbangu(item.bvid, item.cid, item.aid, item.cover);
|
changeSeasonOrbangu(item.bvid, item.cid, item.aid, item.cover);
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
},
|
},
|
||||||
).buildShowContent(Get.context!),
|
).buildShowContent(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
hiddenEpisodeBottomSheet() {
|
hiddenEpisodeBottomSheet() {
|
||||||
bottomSheetController?.close();
|
bottomSheetController?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取追番状态
|
||||||
|
Future bangumiStatus() async {
|
||||||
|
var result = await BangumiHttp.bangumiStatus(seasonId: seasonId!);
|
||||||
|
if (result['status']) {
|
||||||
|
followStatus.value = result['data']['followStatus'];
|
||||||
|
isFollowed.value = result['data']['isFollowed'];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新追番状态
|
||||||
|
Future updateBangumiStatus(int status) async {
|
||||||
|
Get.back();
|
||||||
|
if (status == -1) {
|
||||||
|
bangumiDel();
|
||||||
|
} else {
|
||||||
|
var result = await BangumiHttp.bangumiStatus(seasonId: seasonId!);
|
||||||
|
if (result['status']) {
|
||||||
|
followStatus.value = status;
|
||||||
|
final title = followStatusList.firstWhere(
|
||||||
|
(e) => e['status'] == status,
|
||||||
|
orElse: () => {'title': '未知状态'},
|
||||||
|
)['title'];
|
||||||
|
SmartDialog.showToast('追番状态$title');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(result['msg']);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import 'package:pilipala/pages/bangumi/widgets/bangumi_panel.dart';
|
|||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/pages/video/detail/introduction/widgets/action_item.dart';
|
import 'package:pilipala/pages/video/detail/introduction/widgets/action_item.dart';
|
||||||
import 'package:pilipala/pages/video/detail/introduction/widgets/fav_panel.dart';
|
import 'package:pilipala/pages/video/detail/introduction/widgets/fav_panel.dart';
|
||||||
|
import 'package:pilipala/plugin/pl_gallery/index.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import '../../../common/widgets/http_error.dart';
|
import '../../../common/widgets/http_error.dart';
|
||||||
@ -146,17 +147,34 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 收藏
|
// 收藏
|
||||||
showFavBottomSheet() {
|
showFavBottomSheet() async {
|
||||||
if (bangumiIntroController.userInfo.mid == null) {
|
if (bangumiIntroController.userInfo.mid == null) {
|
||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showModalBottomSheet(
|
final mediaQueryData = MediaQuery.of(context);
|
||||||
context: context,
|
final contentHeight = mediaQueryData.size.height - kToolbarHeight;
|
||||||
useRootNavigator: true,
|
final double initialChildSize =
|
||||||
|
(contentHeight - Get.width * 9 / 16) / contentHeight;
|
||||||
|
await showModalBottomSheet(
|
||||||
|
context: Get.context!,
|
||||||
|
useSafeArea: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return FavPanel(ctr: bangumiIntroController);
|
return DraggableScrollableSheet(
|
||||||
|
initialChildSize: initialChildSize,
|
||||||
|
minChildSize: 0,
|
||||||
|
maxChildSize: 1,
|
||||||
|
snap: true,
|
||||||
|
expand: false,
|
||||||
|
snapSizes: [initialChildSize],
|
||||||
|
builder: (BuildContext context, ScrollController scrollController) {
|
||||||
|
return FavPanel(
|
||||||
|
ctr: bangumiIntroController,
|
||||||
|
scrollController: scrollController,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -188,10 +206,24 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
children: [
|
children: [
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
NetworkImgLayer(
|
InkWell(
|
||||||
width: 115,
|
onTap: () {
|
||||||
height: 115 / 0.75,
|
Navigator.of(context).push(
|
||||||
src: widget.bangumiDetail!.cover!,
|
HeroDialogRoute<void>(
|
||||||
|
builder: (BuildContext context) =>
|
||||||
|
InteractiveviewerGallery(
|
||||||
|
sources: [widget.bangumiDetail!.cover!],
|
||||||
|
initIndex: 0,
|
||||||
|
onPageChanged: (int pageIndex) {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: NetworkImgLayer(
|
||||||
|
width: 115,
|
||||||
|
height: 115 / 0.75,
|
||||||
|
src: widget.bangumiDetail!.cover!,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
PBadge(
|
PBadge(
|
||||||
text:
|
text:
|
||||||
@ -207,104 +239,65 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => showIntroDetail(),
|
onTap: () => showIntroDetail(),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 115 / 0.75,
|
height: 115 / 0.75,
|
||||||
child: Column(
|
child: Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.fromLTRB(6, 4, 6, 6),
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Row(
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Row(
|
||||||
child: Text(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
widget.bangumiDetail!.title!,
|
children: [
|
||||||
style: const TextStyle(
|
Expanded(
|
||||||
fontSize: 16,
|
child: Text(
|
||||||
fontWeight: FontWeight.w500,
|
widget.bangumiDetail!.title!,
|
||||||
),
|
style: const TextStyle(
|
||||||
maxLines: 1,
|
fontSize: 18,
|
||||||
overflow: TextOverflow.ellipsis,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
maxLines: 2,
|
||||||
const SizedBox(width: 20),
|
overflow: TextOverflow.ellipsis,
|
||||||
SizedBox(
|
|
||||||
width: 34,
|
|
||||||
height: 34,
|
|
||||||
child: IconButton(
|
|
||||||
style: ButtonStyle(
|
|
||||||
padding: MaterialStateProperty.all(
|
|
||||||
EdgeInsets.zero),
|
|
||||||
backgroundColor:
|
|
||||||
MaterialStateProperty.resolveWith(
|
|
||||||
(Set<MaterialState> states) {
|
|
||||||
return t.colorScheme.primaryContainer
|
|
||||||
.withOpacity(0.7);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
onPressed: () =>
|
|
||||||
bangumiIntroController.bangumiAdd(),
|
|
||||||
icon: Icon(
|
|
||||||
Icons.favorite_border_rounded,
|
|
||||||
color: t.colorScheme.primary,
|
|
||||||
size: 22,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 20),
|
||||||
],
|
Obx(
|
||||||
),
|
() => BangumiStatusWidget(
|
||||||
Row(
|
ctr: bangumiIntroController,
|
||||||
children: [
|
isFollowed:
|
||||||
StatView(
|
bangumiIntroController.isFollowed.value,
|
||||||
view: widget.bangumiDetail!.stat!['views'],
|
),
|
||||||
size: 'medium',
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
StatDanMu(
|
|
||||||
danmu: widget.bangumiDetail!.stat!['danmakus'],
|
|
||||||
size: 'medium',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
(widget.bangumiDetail!.areas!.isNotEmpty
|
|
||||||
? widget.bangumiDetail!.areas!.first['name']
|
|
||||||
: ''),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: t.colorScheme.outline,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
const SizedBox(width: 6),
|
|
||||||
Text(
|
|
||||||
widget.bangumiDetail!.publish!['pub_time_show'],
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: t.colorScheme.outline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
widget.bangumiDetail!.newEp!['desc'],
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: t.colorScheme.outline,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 4),
|
||||||
const Spacer(),
|
Row(
|
||||||
Text(
|
children: [
|
||||||
'简介:${widget.bangumiDetail!.evaluate!}',
|
StatView(
|
||||||
maxLines: 3,
|
view: widget.bangumiDetail!.stat!['views'],
|
||||||
overflow: TextOverflow.ellipsis,
|
size: 'medium',
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: 13,
|
const SizedBox(width: 6),
|
||||||
color: t.colorScheme.outline,
|
StatDanMu(
|
||||||
|
danmu: widget.bangumiDetail!.stat!['danmakus'],
|
||||||
|
size: 'medium',
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
],
|
Text(
|
||||||
|
'简介:${widget.bangumiDetail!.evaluate!}',
|
||||||
|
maxLines: 3,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: t.colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -394,3 +387,97 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 追番状态
|
||||||
|
class BangumiStatusWidget extends StatelessWidget {
|
||||||
|
final BangumiIntroController ctr;
|
||||||
|
final bool isFollowed;
|
||||||
|
|
||||||
|
const BangumiStatusWidget({
|
||||||
|
Key? key,
|
||||||
|
required this.ctr,
|
||||||
|
required this.isFollowed,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
void updateFollowStatus() {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
useRootNavigator: true,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (context) {
|
||||||
|
return morePanel(context, ctr);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Obx(
|
||||||
|
() => SizedBox(
|
||||||
|
width: 34,
|
||||||
|
height: 34,
|
||||||
|
child: IconButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
|
backgroundColor:
|
||||||
|
MaterialStateProperty.resolveWith((Set<MaterialState> states) {
|
||||||
|
return ctr.isFollowed.value
|
||||||
|
? colorScheme.primaryContainer.withOpacity(0.7)
|
||||||
|
: colorScheme.outlineVariant.withOpacity(0.7);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
onPressed:
|
||||||
|
isFollowed ? () => updateFollowStatus() : () => ctr.bangumiAdd(),
|
||||||
|
icon: Icon(
|
||||||
|
ctr.isFollowed.value
|
||||||
|
? Icons.favorite
|
||||||
|
: Icons.favorite_border_rounded,
|
||||||
|
color: ctr.isFollowed.value
|
||||||
|
? colorScheme.primary
|
||||||
|
: colorScheme.outline,
|
||||||
|
size: 22,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget morePanel(BuildContext context, BangumiIntroController ctr) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () => Get.back(),
|
||||||
|
child: Container(
|
||||||
|
height: 35,
|
||||||
|
padding: const EdgeInsets.only(bottom: 2),
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
width: 32,
|
||||||
|
height: 3,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(3))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
...ctr.followStatusList
|
||||||
|
.map(
|
||||||
|
(e) => ListTile(
|
||||||
|
onTap: () => ctr.updateBangumiStatus(e['status']),
|
||||||
|
selected: ctr.followStatus == e['status'],
|
||||||
|
title: Text(e['title']),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -76,9 +76,14 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Obx(
|
||||||
'最近追番',
|
() => 0 != _bangumidController.total.value
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
? Text(
|
||||||
|
'我的追番(${_bangumidController.total.value})',
|
||||||
|
style:
|
||||||
|
Theme.of(context).textTheme.titleMedium,
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -183,8 +188,10 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () {
|
fn: () {
|
||||||
_futureBuilderFuture =
|
setState(() {
|
||||||
_bangumidController.queryBangumiListFeed();
|
_futureBuilderFuture =
|
||||||
|
_bangumidController.queryBangumiListFeed();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:pilipala/models/bangumi/info.dart';
|
import 'package:pilipala/models/bangumi/info.dart';
|
||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
|
||||||
import '../../../common/pages_bottom_sheet.dart';
|
import '../../../common/pages_bottom_sheet.dart';
|
||||||
import '../../../models/common/video_episode_type.dart';
|
import '../../../models/common/video_episode_type.dart';
|
||||||
import '../introduction/controller.dart';
|
import '../introduction/controller.dart';
|
||||||
@ -44,7 +43,6 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
late int cid;
|
late int cid;
|
||||||
String heroTag = Get.arguments['heroTag'];
|
String heroTag = Get.arguments['heroTag'];
|
||||||
late final VideoDetailController videoDetailCtr;
|
late final VideoDetailController videoDetailCtr;
|
||||||
final ItemScrollController itemScrollController = ItemScrollController();
|
|
||||||
late PersistentBottomSheetController? _bottomSheetController;
|
late PersistentBottomSheetController? _bottomSheetController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -151,7 +149,6 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
changeFucCall: changeFucCall,
|
changeFucCall: changeFucCall,
|
||||||
sheetHeight: widget.sheetHeight,
|
sheetHeight: widget.sheetHeight,
|
||||||
dataType: VideoEpidoesType.bangumiEpisode,
|
dataType: VideoEpidoesType.bangumiEpisode,
|
||||||
context: context,
|
|
||||||
).show(context);
|
).show(context);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -176,59 +173,60 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
return Container(
|
return Container(
|
||||||
width: 150,
|
width: 150,
|
||||||
margin: const EdgeInsets.only(right: 10),
|
margin: const EdgeInsets.only(right: 10),
|
||||||
child: Material(
|
clipBehavior: Clip.antiAlias,
|
||||||
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(8),
|
||||||
clipBehavior: Clip.hardEdge,
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => changeFucCall(page, i),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Padding(
|
onTap: () => changeFucCall(page, i),
|
||||||
padding: const EdgeInsets.symmetric(
|
child: Padding(
|
||||||
vertical: 8,
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 10,
|
vertical: 8,
|
||||||
),
|
horizontal: 10,
|
||||||
child: Column(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: <Widget>[
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Row(
|
children: <Widget>[
|
||||||
children: [
|
Row(
|
||||||
if (isSelected) ...<Widget>[
|
children: [
|
||||||
Image.asset('assets/images/live.png',
|
if (isSelected) ...<Widget>[
|
||||||
color: primary, height: 12),
|
Image.asset('assets/images/live.png',
|
||||||
const SizedBox(width: 6)
|
color: primary, height: 12),
|
||||||
],
|
const SizedBox(width: 6)
|
||||||
|
],
|
||||||
|
Text(
|
||||||
|
'第${i + 1}话',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: isSelected ? primary : onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 2),
|
||||||
|
if (page.badge != null) ...[
|
||||||
|
const Spacer(),
|
||||||
Text(
|
Text(
|
||||||
'第${i + 1}话',
|
page.badge!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 12,
|
||||||
color: isSelected ? primary : onSurface,
|
color: primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 2),
|
]
|
||||||
if (page.badge != null) ...[
|
],
|
||||||
const Spacer(),
|
),
|
||||||
Text(
|
const SizedBox(height: 3),
|
||||||
page.badge!,
|
Text(
|
||||||
style: TextStyle(
|
page.longTitle!,
|
||||||
fontSize: 12,
|
maxLines: 1,
|
||||||
color: primary,
|
style: TextStyle(
|
||||||
),
|
fontSize: 13,
|
||||||
),
|
color: isSelected ? primary : onSurface,
|
||||||
]
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 3),
|
overflow: TextOverflow.ellipsis,
|
||||||
Text(
|
)
|
||||||
page.longTitle!,
|
],
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: isSelected ? primary : onSurface,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -25,6 +25,7 @@ class BangumiCardV extends StatelessWidget {
|
|||||||
RoutePush.bangumiPush(
|
RoutePush.bangumiPush(
|
||||||
bangumiItem.seasonId,
|
bangumiItem.seasonId,
|
||||||
null,
|
null,
|
||||||
|
progressIndex: bangumiItem.progressIndex,
|
||||||
heroTag: heroTag,
|
heroTag: heroTag,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -77,17 +77,19 @@ class _BlackListPageState extends State<BlackListPage> {
|
|||||||
List<BlackListItem> list = _blackListController.blackList;
|
List<BlackListItem> list = _blackListController.blackList;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => list.isEmpty
|
() => list.isEmpty
|
||||||
? CustomScrollView(
|
? HttpError(
|
||||||
slivers: [
|
errMsg: '你没有拉黑任何人哦~_~',
|
||||||
HttpError(errMsg: '你没有拉黑任何人哦~_~', fn: () => {})
|
fn: () => {},
|
||||||
],
|
isInSliver: false,
|
||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
itemCount: list.length,
|
itemCount: list.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () {},
|
onTap: () => Get.toNamed(
|
||||||
|
'/member?mid=${list[index].mid}',
|
||||||
|
arguments: {'face': list[index].face}),
|
||||||
leading: NetworkImgLayer(
|
leading: NetworkImgLayer(
|
||||||
width: 45,
|
width: 45,
|
||||||
height: 45,
|
height: 45,
|
||||||
@ -119,13 +121,10 @@ class _BlackListPageState extends State<BlackListPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: data['msg'],
|
||||||
HttpError(
|
fn: () => _blackListController.queryBlacklist(),
|
||||||
errMsg: data['msg'],
|
isInSliver: false,
|
||||||
fn: () => _blackListController.queryBlacklist(),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class DynamicDetailController extends GetxController {
|
|||||||
int? type;
|
int? type;
|
||||||
dynamic item;
|
dynamic item;
|
||||||
int? floor;
|
int? floor;
|
||||||
int currentPage = 0;
|
String nextOffset = "";
|
||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
RxString noMore = ''.obs;
|
RxString noMore = ''.obs;
|
||||||
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
||||||
@ -26,6 +26,7 @@ class DynamicDetailController extends GetxController {
|
|||||||
RxString sortTypeLabel = ReplySortType.time.labels.obs;
|
RxString sortTypeLabel = ReplySortType.time.labels.obs;
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
RxInt replyReqCode = 200.obs;
|
RxInt replyReqCode = 200.obs;
|
||||||
|
bool isEnd = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -48,26 +49,30 @@ class DynamicDetailController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future queryReplyList({reqType = 'init'}) async {
|
Future queryReplyList({reqType = 'init'}) async {
|
||||||
|
if (isLoadingMore || noMore.value == '没有更多了' || isEnd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isLoadingMore = true;
|
||||||
if (reqType == 'init') {
|
if (reqType == 'init') {
|
||||||
currentPage = 0;
|
nextOffset = '';
|
||||||
|
noMore.value = '';
|
||||||
}
|
}
|
||||||
var res = await ReplyHttp.replyList(
|
var res = await ReplyHttp.replyList(
|
||||||
oid: oid!,
|
oid: oid!,
|
||||||
pageNum: currentPage + 1,
|
nextOffset: nextOffset,
|
||||||
type: type!,
|
type: type!,
|
||||||
sort: _sortType.index,
|
sort: _sortType.index,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
List<ReplyItemModel> replies = res['data'].replies;
|
List<ReplyItemModel> replies = res['data'].replies;
|
||||||
acount.value = res['data'].page.acount;
|
isEnd = res['data'].cursor.isEnd ?? false;
|
||||||
|
acount.value = res['data'].cursor.allCount;
|
||||||
|
nextOffset = res['data'].cursor.paginationReply.nextOffset ?? "";
|
||||||
if (replies.isNotEmpty) {
|
if (replies.isNotEmpty) {
|
||||||
currentPage++;
|
noMore.value = isEnd ? '没有更多了' : '加载中...';
|
||||||
noMore.value = '加载中...';
|
|
||||||
if (replies.length < 20) {
|
|
||||||
noMore.value = '没有更多了';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
|
noMore.value =
|
||||||
|
replyList.isEmpty && nextOffset == "" ? '还没有评论' : '没有更多了';
|
||||||
}
|
}
|
||||||
if (reqType == 'init') {
|
if (reqType == 'init') {
|
||||||
// 添加置顶回复
|
// 添加置顶回复
|
||||||
@ -113,4 +118,9 @@ class DynamicDetailController extends GetxController {
|
|||||||
var res = await HtmlHttp.reqHtml(id, 'opus');
|
var res = await HtmlHttp.reqHtml(id, 'opus');
|
||||||
oid = res['commentId'];
|
oid = res['commentId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 上拉加载
|
||||||
|
Future onLoad() async {
|
||||||
|
queryReplyList(reqType: 'onLoad');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
with TickerProviderStateMixin {
|
with TickerProviderStateMixin {
|
||||||
late DynamicDetailController _dynamicDetailController;
|
late DynamicDetailController _dynamicDetailController;
|
||||||
late AnimationController fabAnimationCtr;
|
late AnimationController fabAnimationCtr;
|
||||||
Future? _futureBuilderFuture;
|
late Future _futureBuilderFuture;
|
||||||
late StreamController<bool> titleStreamC =
|
late StreamController<bool> titleStreamC =
|
||||||
StreamController<bool>.broadcast(); // appBar title
|
StreamController<bool>.broadcast(); // appBar title
|
||||||
late ScrollController scrollController;
|
late ScrollController scrollController;
|
||||||
@ -140,7 +140,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
scrollController.position.maxScrollExtent - 300) {
|
scrollController.position.maxScrollExtent - 300) {
|
||||||
EasyThrottle.throttle('replylist', const Duration(seconds: 2), () {
|
EasyThrottle.throttle('replylist', const Duration(seconds: 2), () {
|
||||||
_dynamicDetailController.queryReplyList(reqType: 'onLoad');
|
_dynamicDetailController.onLoad();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,8 +278,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
Map data = snapshot.data as Map;
|
Map? data = snapshot.data;
|
||||||
if (snapshot.data['status']) {
|
if (data != null && snapshot.data['status']) {
|
||||||
RxList<ReplyItemModel> replyList =
|
RxList<ReplyItemModel> replyList =
|
||||||
_dynamicDetailController.replyList;
|
_dynamicDetailController.replyList;
|
||||||
// 请求成功
|
// 请求成功
|
||||||
@ -345,8 +345,11 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
} else {
|
} else {
|
||||||
// 请求错误
|
// 请求错误
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data?['msg'] ?? '请求异常',
|
||||||
fn: () => setState(() {}),
|
fn: () => setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_dynamicDetailController.queryReplyList();
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
310
lib/pages/dynamics/forward/index.dart
Normal file
310
lib/pages/dynamics/forward/index.dart
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
|
import 'package:pilipala/http/dynamics.dart';
|
||||||
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
|
|
||||||
|
import '../widgets/rich_node_panel.dart';
|
||||||
|
|
||||||
|
class DynamicForwardPage extends StatefulWidget {
|
||||||
|
const DynamicForwardPage({
|
||||||
|
super.key,
|
||||||
|
this.item,
|
||||||
|
this.mid,
|
||||||
|
this.cb,
|
||||||
|
});
|
||||||
|
|
||||||
|
final DynamicItemModel? item;
|
||||||
|
final int? mid;
|
||||||
|
final Function()? cb;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DynamicForwardPage> createState() => _DynamicForwardPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DynamicForwardPageState extends State<DynamicForwardPage> {
|
||||||
|
final TextEditingController _inputController = TextEditingController();
|
||||||
|
final FocusNode _focusNode = FocusNode();
|
||||||
|
RxBool isExpand = false.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_focusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dynamicForward(String type) async {
|
||||||
|
String dynamicId = widget.item!.idStr!;
|
||||||
|
var res = await DynamicsHttp.dynamicCreate(
|
||||||
|
dynIdStr: dynamicId,
|
||||||
|
mid: widget.mid!,
|
||||||
|
rawText: type == 'quickForward' ? '' : _inputController.text,
|
||||||
|
scene: 4,
|
||||||
|
);
|
||||||
|
if (res['status']) {
|
||||||
|
SmartDialog.showToast('转发成功');
|
||||||
|
widget.cb?.call();
|
||||||
|
_onClose();
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['message']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onClose() async {
|
||||||
|
_focusNode.unfocus();
|
||||||
|
await Future.delayed(const Duration(milliseconds: 120));
|
||||||
|
Get.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Obx(
|
||||||
|
() {
|
||||||
|
final EdgeInsetsGeometry padding = EdgeInsets.fromLTRB(
|
||||||
|
isExpand.value ? 10 : 16,
|
||||||
|
10,
|
||||||
|
isExpand.value ? 12 : 12,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
return AnimatedSize(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
onEnd: () => isExpand.value ? _focusNode.requestFocus() : null,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: isExpand.value ? MainAxisSize.max : MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: padding,
|
||||||
|
child: isExpand.value ? _topBarExpand() : _topBar(),
|
||||||
|
),
|
||||||
|
isExpand.value ? _contentExpand() : _content(),
|
||||||
|
dynamicPreview(),
|
||||||
|
if (!isExpand.value) ..._bottomBar(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转发动态预览
|
||||||
|
Widget dynamicPreview() {
|
||||||
|
ItemModulesModel? modules = widget.item!.modules;
|
||||||
|
final String type = widget.item!.type!;
|
||||||
|
String? cover = modules?.moduleAuthor?.face;
|
||||||
|
switch (type) {
|
||||||
|
/// 图文动态
|
||||||
|
case 'DYNAMIC_TYPE_DRAW':
|
||||||
|
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
|
||||||
|
|
||||||
|
/// 投稿
|
||||||
|
case 'DYNAMIC_TYPE_AV':
|
||||||
|
cover = modules?.moduleDynamic?.major?.archive?.cover;
|
||||||
|
|
||||||
|
/// 转发的动态
|
||||||
|
case 'DYNAMIC_TYPE_FORWARD':
|
||||||
|
String forwardType = widget.item!.orig!.type!;
|
||||||
|
switch (forwardType) {
|
||||||
|
/// 图文动态
|
||||||
|
case 'DYNAMIC_TYPE_DRAW':
|
||||||
|
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
|
||||||
|
|
||||||
|
/// 投稿
|
||||||
|
case 'DYNAMIC_TYPE_AV':
|
||||||
|
cover = modules?.moduleDynamic?.major?.archive?.cover;
|
||||||
|
|
||||||
|
/// 番剧
|
||||||
|
case 'DYNAMIC_TYPE_PGC_UNION':
|
||||||
|
cover = modules?.moduleDynamic?.major?.pgc?.cover;
|
||||||
|
// 专栏文章
|
||||||
|
case 'DYNAMIC_TYPE_ARTICLE':
|
||||||
|
// 番剧
|
||||||
|
case 'DYNAMIC_TYPE_PGC':
|
||||||
|
// 纯文字动态
|
||||||
|
case 'DYNAMIC_TYPE_WORD':
|
||||||
|
// 直播
|
||||||
|
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||||
|
// 合集查看
|
||||||
|
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
default:
|
||||||
|
cover = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 专栏文章
|
||||||
|
case 'DYNAMIC_TYPE_ARTICLE':
|
||||||
|
// 番剧
|
||||||
|
case 'DYNAMIC_TYPE_PGC':
|
||||||
|
// 纯文字动态
|
||||||
|
case 'DYNAMIC_TYPE_WORD':
|
||||||
|
// 直播
|
||||||
|
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||||
|
// 合集查看
|
||||||
|
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||||
|
// 番剧查看
|
||||||
|
case 'DYNAMIC_TYPE_PGC_UNION':
|
||||||
|
cover = '';
|
||||||
|
default:
|
||||||
|
cover = '';
|
||||||
|
}
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 98,
|
||||||
|
margin: const EdgeInsets.fromLTRB(12, 0, 12, 14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
width: 4,
|
||||||
|
color: Theme.of(context).colorScheme.primary.withOpacity(0.8)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'@${widget.item!.modules!.moduleAuthor!.name}',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
NetworkImgLayer(
|
||||||
|
src: cover ?? '',
|
||||||
|
width: 45,
|
||||||
|
height: 45,
|
||||||
|
radius: 6,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text.rich(
|
||||||
|
richNode(widget.item, context),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Text(data)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未展开时的顶部
|
||||||
|
Widget _topBar() {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'转发动态',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => dynamicForward('quickForward'),
|
||||||
|
child: const Text('快速转发'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展开时的顶部
|
||||||
|
Widget _topBarExpand() {
|
||||||
|
return Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: _onClose,
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () => dynamicForward('forward'),
|
||||||
|
child: const Text('转发'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
'转发动态',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleMedium!
|
||||||
|
.copyWith(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未展开时的底部
|
||||||
|
List<Widget> _bottomBar() {
|
||||||
|
return [
|
||||||
|
const Divider(thickness: 0.1, height: 1),
|
||||||
|
ListTile(
|
||||||
|
onTap: () => Get.back(),
|
||||||
|
minLeadingWidth: 0,
|
||||||
|
dense: true,
|
||||||
|
title: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).padding.bottom,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未展开时的内容区
|
||||||
|
Widget _content() {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
isExpand.value = true;
|
||||||
|
},
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 10, 10, 16),
|
||||||
|
child: Text(
|
||||||
|
'说点什么吧',
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展开时的内容区
|
||||||
|
Widget _contentExpand() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 10, 16, 0),
|
||||||
|
child: TextField(
|
||||||
|
maxLines: null,
|
||||||
|
minLines: 3,
|
||||||
|
focusNode: _focusNode,
|
||||||
|
controller: _inputController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
border: InputBorder.none,
|
||||||
|
hintText: '说点什么吧',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,7 +9,6 @@ import 'package:pilipala/common/skeleton/dynamic_card.dart';
|
|||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/no_data.dart';
|
import 'package:pilipala/common/widgets/no_data.dart';
|
||||||
import 'package:pilipala/models/dynamics/result.dart';
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
import 'package:pilipala/plugin/pl_popup/index.dart';
|
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import 'package:pilipala/utils/main_stream.dart';
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
import 'package:pilipala/utils/route_push.dart';
|
import 'package:pilipala/utils/route_push.dart';
|
||||||
@ -18,7 +17,6 @@ import 'package:pilipala/utils/storage.dart';
|
|||||||
import '../mine/controller.dart';
|
import '../mine/controller.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/dynamic_panel.dart';
|
import 'widgets/dynamic_panel.dart';
|
||||||
import 'up_dynamic/route_panel.dart';
|
|
||||||
import 'widgets/up_panel.dart';
|
import 'widgets/up_panel.dart';
|
||||||
|
|
||||||
class DynamicsPage extends StatefulWidget {
|
class DynamicsPage extends StatefulWidget {
|
||||||
@ -90,32 +88,34 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (_dynamicsController.mid.value != -1 &&
|
final mid = _dynamicsController.mid.value;
|
||||||
_dynamicsController.upInfo.value.uname != null) {
|
final uname = _dynamicsController.upInfo.value.uname;
|
||||||
return SizedBox(
|
|
||||||
height: 36,
|
if (mid == -1 || uname == null) {
|
||||||
child: AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
transitionBuilder:
|
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'${_dynamicsController.upInfo.value.uname!}的动态',
|
|
||||||
key: ValueKey<String>(
|
|
||||||
_dynamicsController.upInfo.value.uname!),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.labelLarge!
|
|
||||||
.fontSize,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
height: 36,
|
||||||
|
child: AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
transitionBuilder:
|
||||||
|
(Widget child, Animation<double> animation) {
|
||||||
|
return ScaleTransition(
|
||||||
|
scale: animation, child: child);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'$uname的动态',
|
||||||
|
key: ValueKey<String>(uname),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelLarge!
|
||||||
|
.fontSize,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
Obx(
|
Obx(
|
||||||
() => _dynamicsController.userLogin.value
|
() => _dynamicsController.userLogin.value
|
||||||
@ -206,16 +206,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
return Obx(
|
return Obx(
|
||||||
() => UpPanel(
|
() => UpPanel(
|
||||||
upData: _dynamicsController.upData.value,
|
upData: _dynamicsController.upData.value,
|
||||||
onClickUpCb: (data) {
|
dynamicsController: _dynamicsController,
|
||||||
// _dynamicsController.onTapUp(data);
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
PlPopupRoute(
|
|
||||||
child: OverlayPanel(
|
|
||||||
ctr: _dynamicsController, upInfo: data),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -3,20 +3,19 @@ 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:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
|
||||||
import 'package:pilipala/http/dynamics.dart';
|
import 'package:pilipala/http/dynamics.dart';
|
||||||
import 'package:pilipala/models/dynamics/result.dart';
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
import 'package:pilipala/pages/dynamics/index.dart';
|
import 'package:pilipala/pages/dynamics/index.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import 'package:status_bar_control/status_bar_control.dart';
|
import 'package:status_bar_control/status_bar_control.dart';
|
||||||
import 'rich_node_panel.dart';
|
import '../forward/index.dart';
|
||||||
|
|
||||||
class ActionPanel extends StatefulWidget {
|
class ActionPanel extends StatefulWidget {
|
||||||
const ActionPanel({
|
const ActionPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
});
|
});
|
||||||
// ignore: prefer_typing_uninitialized_variables
|
|
||||||
final DynamicItemModel item;
|
final DynamicItemModel item;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -32,9 +31,6 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
RxDouble height = 0.0.obs;
|
RxDouble height = 0.0.obs;
|
||||||
RxBool isExpand = false.obs;
|
RxBool isExpand = false.obs;
|
||||||
late double statusHeight;
|
late double statusHeight;
|
||||||
TextEditingController _inputController = TextEditingController();
|
|
||||||
FocusNode myFocusNode = FocusNode();
|
|
||||||
String _inputText = '';
|
|
||||||
|
|
||||||
void Function()? handleState(Future Function() action) {
|
void Function()? handleState(Future Function() action) {
|
||||||
return isProcessing
|
return isProcessing
|
||||||
@ -60,7 +56,7 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
// 动态点赞
|
// 动态点赞
|
||||||
Future onLikeDynamic() async {
|
Future onLikeDynamic() async {
|
||||||
feedBack();
|
feedBack();
|
||||||
var item = widget.item!;
|
var item = widget.item;
|
||||||
String dynamicId = item.idStr!;
|
String dynamicId = item.idStr!;
|
||||||
// 1 已点赞 2 不喜欢 0 未操作
|
// 1 已点赞 2 不喜欢 0 未操作
|
||||||
Like like = item.modules!.moduleStat!.like!;
|
Like like = item.modules!.moduleStat!.like!;
|
||||||
@ -87,300 +83,38 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 转发动态预览
|
|
||||||
Widget dynamicPreview() {
|
|
||||||
ItemModulesModel? modules = widget.item.modules;
|
|
||||||
final String type = widget.item.type!;
|
|
||||||
String? cover = modules?.moduleAuthor?.face;
|
|
||||||
switch (type) {
|
|
||||||
/// 图文动态
|
|
||||||
case 'DYNAMIC_TYPE_DRAW':
|
|
||||||
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
|
|
||||||
|
|
||||||
/// 投稿
|
|
||||||
case 'DYNAMIC_TYPE_AV':
|
|
||||||
cover = modules?.moduleDynamic?.major?.archive?.cover;
|
|
||||||
|
|
||||||
/// 转发的动态
|
|
||||||
case 'DYNAMIC_TYPE_FORWARD':
|
|
||||||
String forwardType = widget.item.orig!.type!;
|
|
||||||
switch (forwardType) {
|
|
||||||
/// 图文动态
|
|
||||||
case 'DYNAMIC_TYPE_DRAW':
|
|
||||||
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
|
|
||||||
|
|
||||||
/// 投稿
|
|
||||||
case 'DYNAMIC_TYPE_AV':
|
|
||||||
cover = modules?.moduleDynamic?.major?.archive?.cover;
|
|
||||||
|
|
||||||
/// 专栏文章
|
|
||||||
case 'DYNAMIC_TYPE_ARTICLE':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 番剧
|
|
||||||
case 'DYNAMIC_TYPE_PGC':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 纯文字动态
|
|
||||||
case 'DYNAMIC_TYPE_WORD':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 直播
|
|
||||||
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 合集查看
|
|
||||||
case 'DYNAMIC_TYPE_UGC_SEASON':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 番剧
|
|
||||||
case 'DYNAMIC_TYPE_PGC_UNION':
|
|
||||||
cover = modules?.moduleDynamic?.major?.pgc?.cover;
|
|
||||||
|
|
||||||
default:
|
|
||||||
cover = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 专栏文章
|
|
||||||
case 'DYNAMIC_TYPE_ARTICLE':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 番剧
|
|
||||||
case 'DYNAMIC_TYPE_PGC':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 纯文字动态
|
|
||||||
case 'DYNAMIC_TYPE_WORD':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 直播
|
|
||||||
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 合集查看
|
|
||||||
case 'DYNAMIC_TYPE_UGC_SEASON':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
/// 番剧查看
|
|
||||||
case 'DYNAMIC_TYPE_PGC_UNION':
|
|
||||||
cover = '';
|
|
||||||
|
|
||||||
default:
|
|
||||||
cover = '';
|
|
||||||
}
|
|
||||||
return Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: 95,
|
|
||||||
margin: const EdgeInsets.fromLTRB(12, 0, 12, 14),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color:
|
|
||||||
Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4),
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
border: Border(
|
|
||||||
left: BorderSide(
|
|
||||||
width: 4,
|
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.8)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'@${widget.item.modules!.moduleAuthor!.name}',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
NetworkImgLayer(
|
|
||||||
src: cover ?? '',
|
|
||||||
width: 34,
|
|
||||||
height: 34,
|
|
||||||
type: 'emote',
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: Text.rich(
|
|
||||||
style: const TextStyle(height: 0),
|
|
||||||
richNode(widget.item, context),
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Text(data)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 动态转发
|
// 动态转发
|
||||||
void forwardHandler() async {
|
void forwardHandler() async {
|
||||||
|
final userInfo = _dynamicsController.userInfo;
|
||||||
|
if (userInfo == null) {
|
||||||
|
SmartDialog.showToast('请先登录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int mid = userInfo.mid;
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
enableDrag: false,
|
enableDrag: true,
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
|
useSafeArea: true,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Obx(
|
return DynamicForwardPage(
|
||||||
() => AnimatedContainer(
|
item: widget.item,
|
||||||
duration: Durations.medium1,
|
mid: mid,
|
||||||
onEnd: () async {
|
cb: () => setState(() {
|
||||||
if (isExpand.value) {
|
stat.forward!.count =
|
||||||
await Future.delayed(const Duration(milliseconds: 80));
|
(int.parse(stat.forward!.count ?? '0') + 1).toString();
|
||||||
myFocusNode.requestFocus();
|
}),
|
||||||
}
|
|
||||||
},
|
|
||||||
height: height.value + MediaQuery.of(context).padding.bottom,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
AnimatedContainer(
|
|
||||||
duration: Durations.medium1,
|
|
||||||
height: isExpand.value ? statusHeight : 0,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.fromLTRB(
|
|
||||||
isExpand.value ? 10 : 16,
|
|
||||||
10,
|
|
||||||
isExpand.value ? 14 : 12,
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
if (isExpand.value) ...[
|
|
||||||
IconButton(
|
|
||||||
onPressed: () => togglePanelState(false),
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'转发动态',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleMedium!
|
|
||||||
.copyWith(fontWeight: FontWeight.bold),
|
|
||||||
)
|
|
||||||
] else ...[
|
|
||||||
const Text(
|
|
||||||
'转发动态',
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
isExpand.value
|
|
||||||
? FilledButton(
|
|
||||||
onPressed: () => dynamicForward('forward'),
|
|
||||||
child: const Text('转发'),
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('立即转发'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!isExpand.value) ...[
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () => togglePanelState(true),
|
|
||||||
behavior: HitTestBehavior.translucent,
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
padding: const EdgeInsets.fromLTRB(16, 0, 10, 14),
|
|
||||||
child: Text(
|
|
||||||
'说点什么吧',
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.outline),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
] else ...[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(16, 10, 16, 0),
|
|
||||||
child: TextField(
|
|
||||||
maxLines: 5,
|
|
||||||
focusNode: myFocusNode,
|
|
||||||
controller: _inputController,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_inputText = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
border: InputBorder.none,
|
|
||||||
hintText: '说点什么吧',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
dynamicPreview(),
|
|
||||||
if (!isExpand.value) ...[
|
|
||||||
const Divider(thickness: 0.1, height: 1),
|
|
||||||
ListTile(
|
|
||||||
onTap: () => Get.back(),
|
|
||||||
minLeadingWidth: 0,
|
|
||||||
dense: true,
|
|
||||||
title: Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.outline),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePanelState(status) {
|
|
||||||
if (!status) {
|
|
||||||
Get.back();
|
|
||||||
height.value = defaultHeight;
|
|
||||||
_inputText = '';
|
|
||||||
_inputController.clear();
|
|
||||||
} else {
|
|
||||||
height.value = Get.size.height;
|
|
||||||
}
|
|
||||||
isExpand.value = !(isExpand.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
dynamicForward(String type) async {
|
|
||||||
String dynamicId = widget.item.idStr!;
|
|
||||||
var res = await DynamicsHttp.dynamicCreate(
|
|
||||||
dynIdStr: dynamicId,
|
|
||||||
mid: _dynamicsController.userInfo.mid,
|
|
||||||
rawText: _inputText,
|
|
||||||
scene: 4,
|
|
||||||
);
|
|
||||||
if (res['status']) {
|
|
||||||
SmartDialog.showToast(type == 'forward' ? '转发成功' : '发布成功');
|
|
||||||
togglePanelState(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
myFocusNode.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var color = Theme.of(context).colorScheme.outline;
|
var color = Theme.of(context).colorScheme.outline;
|
||||||
var primary = Theme.of(context).colorScheme.primary;
|
var primary = Theme.of(context).colorScheme.primary;
|
||||||
height.value = defaultHeight;
|
height.value = defaultHeight;
|
||||||
print('height.value: ${height.value}');
|
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -66,76 +66,85 @@ Widget liveRcmdPanel(item, context, {floor = 1}) {
|
|||||||
},
|
},
|
||||||
child: LayoutBuilder(builder: (context, box) {
|
child: LayoutBuilder(builder: (context, box) {
|
||||||
double width = box.maxWidth;
|
double width = box.maxWidth;
|
||||||
return Stack(
|
return Container(
|
||||||
children: [
|
margin: floor == 1
|
||||||
Hero(
|
? const EdgeInsets.only(
|
||||||
tag: liveRcmd.roomId.toString(),
|
left: StyleString.safeSpace, right: StyleString.safeSpace)
|
||||||
child: NetworkImgLayer(
|
: EdgeInsets.zero,
|
||||||
type: floor == 1 ? 'emote' : null,
|
clipBehavior: Clip.hardEdge,
|
||||||
width: width,
|
decoration: const BoxDecoration(
|
||||||
height: width / StyleString.aspectRatio,
|
borderRadius: BorderRadius.all(StyleString.imgRadius)),
|
||||||
src: item.modules.moduleDynamic.major.liveRcmd.cover,
|
child: Stack(
|
||||||
),
|
children: [
|
||||||
),
|
Hero(
|
||||||
PBadge(
|
tag: liveRcmd.roomId.toString(),
|
||||||
text: watchedShow['text_large'],
|
child: NetworkImgLayer(
|
||||||
top: 6,
|
type: floor == 1 ? 'emote' : null,
|
||||||
right: 56,
|
width: width,
|
||||||
bottom: null,
|
height: width / StyleString.aspectRatio,
|
||||||
left: null,
|
src: item.modules.moduleDynamic.major.liveRcmd.cover,
|
||||||
type: 'gray',
|
|
||||||
),
|
|
||||||
PBadge(
|
|
||||||
text: liveStatus == 1 ? '直播中' : '直播结束',
|
|
||||||
top: 6,
|
|
||||||
right: 6,
|
|
||||||
bottom: null,
|
|
||||||
left: null,
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: Container(
|
|
||||||
height: 80,
|
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 10, 10),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: const LinearGradient(
|
|
||||||
begin: Alignment.topCenter,
|
|
||||||
end: Alignment.bottomCenter,
|
|
||||||
colors: <Color>[
|
|
||||||
Colors.transparent,
|
|
||||||
Colors.black45,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
borderRadius: floor == 1
|
|
||||||
? null
|
|
||||||
: const BorderRadius.all(Radius.circular(6))),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
DefaultTextStyle.merge(
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.labelMedium!
|
|
||||||
.fontSize,
|
|
||||||
color: Colors.white),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Text(item.modules.moduleDynamic.major.liveRcmd
|
|
||||||
.areaName ??
|
|
||||||
''),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
PBadge(
|
||||||
],
|
text: watchedShow['text_large'],
|
||||||
|
top: 8.0,
|
||||||
|
right: 62.0,
|
||||||
|
bottom: null,
|
||||||
|
left: null,
|
||||||
|
type: 'gray',
|
||||||
|
),
|
||||||
|
PBadge(
|
||||||
|
text: liveStatus == 1 ? '直播中' : '直播结束',
|
||||||
|
top: 8.0,
|
||||||
|
right: 10.0,
|
||||||
|
bottom: null,
|
||||||
|
left: null,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: Container(
|
||||||
|
height: 80,
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 0, 10, 10),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: <Color>[
|
||||||
|
Colors.transparent,
|
||||||
|
Colors.black45,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
borderRadius: floor == 1
|
||||||
|
? null
|
||||||
|
: const BorderRadius.all(Radius.circular(6))),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
DefaultTextStyle.merge(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.fontSize,
|
||||||
|
color: Colors.white),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(item.modules.moduleDynamic.major.liveRcmd
|
||||||
|
.areaName ??
|
||||||
|
''),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -4,17 +4,22 @@ 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/dynamics/up.dart';
|
import 'package:pilipala/models/dynamics/up.dart';
|
||||||
import 'package:pilipala/models/live/item.dart';
|
import 'package:pilipala/models/live/item.dart';
|
||||||
|
import 'package:pilipala/plugin/pl_popup/index.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
|
import '../controller.dart';
|
||||||
|
import '../up_dynamic/route_panel.dart';
|
||||||
|
|
||||||
class UpPanel extends StatefulWidget {
|
class UpPanel extends StatefulWidget {
|
||||||
final FollowUpModel upData;
|
final FollowUpModel upData;
|
||||||
final Function? onClickUpCb;
|
final DynamicsController dynamicsController;
|
||||||
|
|
||||||
const UpPanel({
|
const UpPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.upData,
|
required this.upData,
|
||||||
this.onClickUpCb,
|
required this.dynamicsController,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -23,7 +28,7 @@ class UpPanel extends StatefulWidget {
|
|||||||
|
|
||||||
class _UpPanelState extends State<UpPanel> {
|
class _UpPanelState extends State<UpPanel> {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
int currentMid = -1;
|
RxInt currentMid = (-1).obs;
|
||||||
late double contentWidth = 56;
|
late double contentWidth = 56;
|
||||||
List<UpItem> upList = [];
|
List<UpItem> upList = [];
|
||||||
List<LiveUserItem> liveList = [];
|
List<LiveUserItem> liveList = [];
|
||||||
@ -37,26 +42,44 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onClickUp(data, i) {
|
void onClickUp(data, i) {
|
||||||
currentMid = data.mid;
|
currentMid.value = data.mid;
|
||||||
widget.onClickUpCb?.call(data);
|
Navigator.push(
|
||||||
// int liveLen = liveList.length;
|
context,
|
||||||
// int upLen = upList.length;
|
PlPopupRoute(
|
||||||
// double itemWidth = contentWidth + itemPadding.horizontal;
|
child: OverlayPanel(
|
||||||
// double screenWidth = MediaQuery.sizeOf(context).width;
|
ctr: widget.dynamicsController,
|
||||||
// double moveDistance = 0.0;
|
upInfo: data,
|
||||||
// if (itemWidth * (upList.length + liveList.length) <= screenWidth) {
|
),
|
||||||
// } else if ((upLen - i - 0.5) * itemWidth > screenWidth / 2) {
|
),
|
||||||
// moveDistance = (i + liveLen + 0.5) * itemWidth + 46 - screenWidth / 2;
|
).then((value) => {currentMid.value = -1});
|
||||||
// } else {
|
}
|
||||||
// moveDistance = (upLen + liveLen) * itemWidth + 46 - screenWidth;
|
|
||||||
// }
|
void onClickUpAni(data, i) {
|
||||||
// data.hasUpdate = false;
|
final screenWidth = MediaQuery.sizeOf(context).width;
|
||||||
// scrollController.animateTo(
|
final itemWidth = contentWidth + itemPadding.horizontal;
|
||||||
// moveDistance,
|
final liveLen = liveList.length;
|
||||||
// duration: const Duration(milliseconds: 200),
|
final upLen = upList.length;
|
||||||
// curve: Curves.linear,
|
|
||||||
// );
|
currentMid.value = data.mid;
|
||||||
// setState(() {});
|
widget.dynamicsController.onTapUp(data);
|
||||||
|
|
||||||
|
double moveDistance = 0.0;
|
||||||
|
final totalItemsWidth = itemWidth * (upLen + liveLen);
|
||||||
|
|
||||||
|
if (totalItemsWidth > screenWidth) {
|
||||||
|
if ((upLen - i - 0.5) * itemWidth > screenWidth / 2) {
|
||||||
|
moveDistance = (i + liveLen + 0.5) * itemWidth + 46 - screenWidth / 2;
|
||||||
|
} else {
|
||||||
|
moveDistance = totalItemsWidth + 46 - screenWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.hasUpdate = false;
|
||||||
|
scrollController.animateTo(
|
||||||
|
moveDistance,
|
||||||
|
duration: const Duration(milliseconds: 500),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -144,14 +167,17 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget upItemBuild(data, i) {
|
Widget upItemBuild(data, i) {
|
||||||
bool isCurrent = currentMid == data.mid || currentMid == -1;
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
feedBack();
|
feedBack();
|
||||||
if (data.type == 'up') {
|
if (data.type == 'up') {
|
||||||
EasyThrottle.throttle('follow', const Duration(milliseconds: 300),
|
EasyThrottle.throttle('follow', const Duration(milliseconds: 300),
|
||||||
() {
|
() {
|
||||||
onClickUp(data, i);
|
if (GlobalDataCache().enableDynamicSwitch) {
|
||||||
|
onClickUp(data, i);
|
||||||
|
} else {
|
||||||
|
onClickUpAni(data, i);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if (data.type == 'live') {
|
} else if (data.type == 'live') {
|
||||||
LiveItemModel liveItem = LiveItemModel.fromJson({
|
LiveItemModel liveItem = LiveItemModel.fromJson({
|
||||||
@ -177,60 +203,66 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: itemPadding,
|
padding: itemPadding,
|
||||||
child: AnimatedOpacity(
|
child: Obx(
|
||||||
opacity: isCurrent ? 1 : 0.3,
|
() => AnimatedOpacity(
|
||||||
duration: const Duration(milliseconds: 200),
|
opacity: currentMid.value == data.mid || currentMid.value == -1
|
||||||
curve: Curves.easeInOut,
|
? 1
|
||||||
child: Column(
|
: 0.3,
|
||||||
mainAxisSize: MainAxisSize.min,
|
duration: const Duration(milliseconds: 200),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
curve: Curves.easeInOut,
|
||||||
children: [
|
child: Column(
|
||||||
Badge(
|
mainAxisSize: MainAxisSize.min,
|
||||||
smallSize: 8,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
label: data.type == 'live' ? const Text('Live') : null,
|
children: [
|
||||||
textColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
Badge(
|
||||||
alignment: data.type == 'live'
|
smallSize: 8,
|
||||||
? AlignmentDirectional.topCenter
|
label: data.type == 'live' ? const Text('Live') : null,
|
||||||
: AlignmentDirectional.topEnd,
|
textColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||||
padding: const EdgeInsets.only(left: 6, right: 6),
|
alignment: data.type == 'live'
|
||||||
isLabelVisible: data.type == 'live' ||
|
? AlignmentDirectional.topCenter
|
||||||
(data.type == 'up' && (data.hasUpdate ?? false)),
|
: AlignmentDirectional.topEnd,
|
||||||
backgroundColor: data.type == 'live'
|
padding: const EdgeInsets.only(left: 6, right: 6),
|
||||||
? Theme.of(context).colorScheme.secondaryContainer
|
isLabelVisible: data.type == 'live' ||
|
||||||
: Theme.of(context).colorScheme.primary,
|
(data.type == 'up' && (data.hasUpdate ?? false)),
|
||||||
child: data.face != ''
|
backgroundColor: data.type == 'live'
|
||||||
? NetworkImgLayer(
|
? Theme.of(context).colorScheme.secondaryContainer
|
||||||
width: 50,
|
: Theme.of(context).colorScheme.primary,
|
||||||
height: 50,
|
child: data.face != ''
|
||||||
src: data.face,
|
? NetworkImgLayer(
|
||||||
type: 'avatar',
|
width: 50,
|
||||||
)
|
height: 50,
|
||||||
: const CircleAvatar(
|
src: data.face,
|
||||||
radius: 25,
|
type: 'avatar',
|
||||||
backgroundImage: AssetImage(
|
)
|
||||||
'assets/images/noface.jpeg',
|
: const CircleAvatar(
|
||||||
|
radius: 25,
|
||||||
|
backgroundImage: AssetImage(
|
||||||
|
'assets/images/noface.jpeg',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.only(top: 4),
|
||||||
padding: const EdgeInsets.only(top: 4),
|
child: SizedBox(
|
||||||
child: SizedBox(
|
width: contentWidth,
|
||||||
width: contentWidth,
|
child: Text(
|
||||||
child: Text(
|
data.uname,
|
||||||
data.uname,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
softWrap: false,
|
||||||
softWrap: false,
|
textAlign: TextAlign.center,
|
||||||
textAlign: TextAlign.center,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
color: currentMid.value == data.mid
|
||||||
color: currentMid == data.mid
|
? Theme.of(context).colorScheme.primary
|
||||||
? Theme.of(context).colorScheme.primary
|
: Theme.of(context).colorScheme.outline,
|
||||||
: Theme.of(context).colorScheme.outline,
|
fontSize: Theme.of(context)
|
||||||
fontSize:
|
.textTheme
|
||||||
Theme.of(context).textTheme.labelMedium!.fontSize),
|
.labelMedium!
|
||||||
|
.fontSize),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -78,72 +78,83 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) {
|
|||||||
],
|
],
|
||||||
LayoutBuilder(builder: (context, box) {
|
LayoutBuilder(builder: (context, box) {
|
||||||
double width = box.maxWidth;
|
double width = box.maxWidth;
|
||||||
return Stack(
|
return Container(
|
||||||
children: [
|
margin: floor == 1
|
||||||
NetworkImgLayer(
|
? const EdgeInsets.only(
|
||||||
type: floor == 1 ? 'emote' : null,
|
left: StyleString.safeSpace, right: StyleString.safeSpace)
|
||||||
width: width,
|
: EdgeInsets.zero,
|
||||||
height: width / StyleString.aspectRatio,
|
clipBehavior: Clip.hardEdge,
|
||||||
src: content.cover,
|
decoration: const BoxDecoration(
|
||||||
),
|
borderRadius: BorderRadius.all(StyleString.imgRadius)),
|
||||||
if (content.badge != null && content.badge['text'] != null)
|
child: Stack(
|
||||||
PBadge(
|
children: [
|
||||||
text: content.badge['text'],
|
NetworkImgLayer(
|
||||||
top: 8.0,
|
type: floor == 1 ? 'emote' : null,
|
||||||
right: 10.0,
|
width: width,
|
||||||
bottom: null,
|
height: width / StyleString.aspectRatio,
|
||||||
left: null,
|
src: content.cover,
|
||||||
),
|
),
|
||||||
Positioned(
|
if (content.badge != null && content.badge['text'] != null)
|
||||||
left: 0,
|
PBadge(
|
||||||
right: 0,
|
text: content.badge['text'],
|
||||||
bottom: 0,
|
top: 8.0,
|
||||||
child: Container(
|
right: 10.0,
|
||||||
height: 80,
|
bottom: null,
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 10, 10),
|
left: null,
|
||||||
clipBehavior: Clip.hardEdge,
|
),
|
||||||
decoration: BoxDecoration(
|
Positioned(
|
||||||
gradient: const LinearGradient(
|
left: 0,
|
||||||
begin: Alignment.topCenter,
|
right: 0,
|
||||||
end: Alignment.bottomCenter,
|
bottom: 0,
|
||||||
colors: <Color>[
|
child: Container(
|
||||||
Colors.transparent,
|
height: 80,
|
||||||
Colors.black54,
|
padding: const EdgeInsets.fromLTRB(12, 0, 10, 10),
|
||||||
],
|
clipBehavior: Clip.hardEdge,
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
borderRadius: floor == 1
|
gradient: const LinearGradient(
|
||||||
? null
|
begin: Alignment.topCenter,
|
||||||
: const BorderRadius.all(Radius.circular(6))),
|
end: Alignment.bottomCenter,
|
||||||
child: Row(
|
colors: <Color>[
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
Colors.transparent,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
Colors.black54,
|
||||||
children: [
|
|
||||||
DefaultTextStyle.merge(
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize:
|
|
||||||
Theme.of(context).textTheme.labelMedium!.fontSize,
|
|
||||||
color: Colors.white),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Text(content.durationText ?? ''),
|
|
||||||
if (content.durationText != null)
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Text(content.stat.play + '次围观'),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Text(content.stat.danmaku + '条弹幕')
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
borderRadius: floor == 1
|
||||||
Image.asset(
|
? null
|
||||||
'assets/images/play.png',
|
: const BorderRadius.all(Radius.circular(6))),
|
||||||
width: 60,
|
child: Row(
|
||||||
height: 60,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
],
|
children: [
|
||||||
|
DefaultTextStyle.merge(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.fontSize,
|
||||||
|
color: Colors.white),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(content.durationText ?? ''),
|
||||||
|
if (content.durationText != null)
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(content.stat.play + '次围观'),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(content.stat.danmaku + '条弹幕')
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/play.png',
|
||||||
|
width: 60,
|
||||||
|
height: 60,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
|||||||
@ -103,17 +103,14 @@ class _FansPageState extends State<FansPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
errMsg: data['msg'],
|
||||||
slivers: [
|
fn: () {
|
||||||
HttpError(
|
setState(() {
|
||||||
errMsg: data['msg'],
|
_futureBuilderFuture = _fansController.queryFans('init');
|
||||||
fn: () {
|
});
|
||||||
_futureBuilderFuture =
|
},
|
||||||
_fansController.queryFans('init');
|
isInSliver: false,
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -112,23 +112,19 @@ class _FavPageState extends State<FavPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
errMsg: data?['msg'] ?? '请求异常',
|
||||||
slivers: [
|
btnText: data?['code'] == -101 ? '去登录' : null,
|
||||||
HttpError(
|
fn: () {
|
||||||
errMsg: data?['msg'] ?? '请求异常',
|
if (data?['code'] == -101) {
|
||||||
btnText: data?['code'] == -101 ? '去登录' : null,
|
RoutePush.loginRedirectPush();
|
||||||
fn: () {
|
} else {
|
||||||
if (data?['code'] == -101) {
|
setState(() {
|
||||||
RoutePush.loginRedirectPush();
|
_futureBuilderFuture = _favController.queryFavFolder();
|
||||||
} else {
|
});
|
||||||
setState(() {
|
}
|
||||||
_futureBuilderFuture = _favController.queryFavFolder();
|
},
|
||||||
});
|
isInSliver: false,
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'package:flutter/material.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/utils/logic_utils.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
class FavItem extends StatelessWidget {
|
class FavItem extends StatelessWidget {
|
||||||
@ -96,7 +97,7 @@ class VideoContent extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Text(
|
Text(
|
||||||
[23, 1].contains(favFolderItem.attr) ? '私密' : '公开',
|
LogicUtils.isPublic(favFolderItem.attr) ? '公开' : '私密',
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
|
|||||||
@ -21,6 +21,7 @@ class FavDetailController extends GetxController {
|
|||||||
RxString loadingText = '加载中...'.obs;
|
RxString loadingText = '加载中...'.obs;
|
||||||
RxInt mediaCount = 0.obs;
|
RxInt mediaCount = 0.obs;
|
||||||
late String isOwner;
|
late String isOwner;
|
||||||
|
late bool hasMore = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -35,7 +36,7 @@ class FavDetailController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> queryUserFavFolderDetail({type = 'init'}) async {
|
Future<dynamic> queryUserFavFolderDetail({type = 'init'}) async {
|
||||||
if (type == 'onLoad' && favList.length >= mediaCount.value) {
|
if (type == 'onLoad' && !hasMore) {
|
||||||
loadingText.value = '没有更多了';
|
loadingText.value = '没有更多了';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -47,17 +48,18 @@ class FavDetailController extends GetxController {
|
|||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
favInfo.value = res['data'].info;
|
favInfo.value = res['data'].info;
|
||||||
|
hasMore = res['data'].hasMore;
|
||||||
if (currentPage == 1 && type == 'init') {
|
if (currentPage == 1 && type == 'init') {
|
||||||
favList.value = res['data'].medias;
|
favList.value = res['data'].medias;
|
||||||
mediaCount.value = res['data'].info['media_count'];
|
mediaCount.value = res['data'].info['media_count'];
|
||||||
} else if (type == 'onLoad') {
|
} else if (type == 'onLoad') {
|
||||||
favList.addAll(res['data'].medias);
|
favList.addAll(res['data'].medias);
|
||||||
}
|
}
|
||||||
if (favList.length >= mediaCount.value) {
|
if (!hasMore) {
|
||||||
loadingText.value = '没有更多了';
|
loadingText.value = '没有更多了';
|
||||||
}
|
}
|
||||||
|
currentPage += 1;
|
||||||
}
|
}
|
||||||
currentPage += 1;
|
|
||||||
isLoadingMore = false;
|
isLoadingMore = false;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -126,7 +128,7 @@ class FavDetailController extends GetxController {
|
|||||||
'title': item!.title,
|
'title': item!.title,
|
||||||
'intro': item!.intro,
|
'intro': item!.intro,
|
||||||
'cover': item!.cover,
|
'cover': item!.cover,
|
||||||
'privacy': [23, 1].contains(item!.attr) ? 1 : 0,
|
'privacy': [22, 0].contains(item!.attr) ? 0 : 1,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
title.value = res['title'];
|
title.value = res['title'];
|
||||||
|
|||||||
@ -193,7 +193,9 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
padding: const EdgeInsets.only(top: 15, bottom: 8, left: 14),
|
padding: const EdgeInsets.only(top: 15, bottom: 8, left: 14),
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
'共${_favDetailController.mediaCount}条视频',
|
_favDetailController.mediaCount > 0
|
||||||
|
? '共${_favDetailController.mediaCount}条视频'
|
||||||
|
: '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize:
|
fontSize:
|
||||||
Theme.of(context).textTheme.labelMedium!.fontSize,
|
Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
@ -215,7 +217,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
List favList = _favDetailController.favList;
|
List favList = _favDetailController.favList;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => favList.isEmpty
|
() => favList.isEmpty
|
||||||
? const SliverToBoxAdapter(child: SizedBox())
|
? const NoData()
|
||||||
: SliverList(
|
: SliverList(
|
||||||
delegate:
|
delegate:
|
||||||
SliverChildBuilderDelegate((context, index) {
|
SliverChildBuilderDelegate((context, index) {
|
||||||
@ -247,18 +249,20 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Container(
|
child: Container(
|
||||||
height: MediaQuery.of(context).padding.bottom + 60,
|
height: MediaQuery.of(context).padding.bottom + 90,
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.of(context).padding.bottom),
|
bottom: MediaQuery.of(context).padding.bottom),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Obx(
|
child: Obx(() {
|
||||||
() => Text(
|
final mediaCount = _favDetailController.mediaCount;
|
||||||
_favDetailController.loadingText.value,
|
final loadingText = _favDetailController.loadingText.value;
|
||||||
style: TextStyle(
|
final textColor = Theme.of(context).colorScheme.outline;
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
fontSize: 13),
|
return Text(
|
||||||
),
|
mediaCount > 0 ? loadingText : '',
|
||||||
),
|
style: TextStyle(color: textColor, fontSize: 13),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import 'package:bottom_sheet/bottom_sheet.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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';
|
||||||
@ -48,24 +47,27 @@ class FollowItem extends StatelessWidget {
|
|||||||
height: 34,
|
height: 34,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await showFlexibleBottomSheet(
|
await showModalBottomSheet(
|
||||||
bottomSheetBorderRadius: const BorderRadius.only(
|
context: context,
|
||||||
topLeft: Radius.circular(16),
|
useSafeArea: true,
|
||||||
topRight: Radius.circular(16),
|
isScrollControlled: true,
|
||||||
),
|
builder: (BuildContext context) {
|
||||||
minHeight: 1,
|
return DraggableScrollableSheet(
|
||||||
initHeight: 1,
|
initialChildSize: 0.6,
|
||||||
maxHeight: 1,
|
minChildSize: 0,
|
||||||
context: Get.context!,
|
maxChildSize: 1,
|
||||||
builder: (BuildContext context,
|
snap: true,
|
||||||
ScrollController scrollController, double offset) {
|
expand: false,
|
||||||
return GroupPanel(
|
snapSizes: const [0.6],
|
||||||
mid: item.mid!,
|
builder: (BuildContext context,
|
||||||
scrollController: scrollController,
|
ScrollController scrollController) {
|
||||||
|
return GroupPanel(
|
||||||
|
mid: item.mid!,
|
||||||
|
scrollController: scrollController,
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
anchors: [1],
|
|
||||||
isSafeArea: true,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
|
|||||||
@ -94,13 +94,14 @@ class _FollowListState extends State<FollowList> {
|
|||||||
: const CustomScrollView(slivers: [NoData()]),
|
: const CustomScrollView(slivers: [NoData()]),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: data['msg'],
|
||||||
HttpError(
|
fn: () {
|
||||||
errMsg: data['msg'],
|
setState(() {
|
||||||
fn: () => widget.ctr.queryFollowings('init'),
|
_futureBuilderFuture = widget.ctr.queryFollowings('init');
|
||||||
)
|
});
|
||||||
],
|
},
|
||||||
|
isInSliver: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -112,13 +112,10 @@ class _OwnerFollowListState extends State<OwnerFollowList>
|
|||||||
: const CustomScrollView(slivers: [NoData()]),
|
: const CustomScrollView(slivers: [NoData()]),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: data['msg'],
|
||||||
HttpError(
|
fn: () => widget.ctr.queryFollowings('init'),
|
||||||
errMsg: data['msg'],
|
isInSliver: false,
|
||||||
fn: () => widget.ctr.queryFollowings('init'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -82,10 +82,10 @@ class _FollowSearchPageState extends State<FollowSearchPage> {
|
|||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
var data = snapshot.data;
|
var data = snapshot.data;
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: snapshot.data['msg'],
|
||||||
HttpError(errMsg: snapshot.data['msg'], fn: reRequest)
|
fn: reRequest,
|
||||||
],
|
isInSliver: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
@ -101,15 +101,17 @@ class _FollowSearchPageState extends State<FollowSearchPage> {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
: CustomScrollView(
|
: HttpError(
|
||||||
slivers: [HttpError(errMsg: '未搜索到结果', fn: reRequest)],
|
errMsg: '未搜索到结果',
|
||||||
|
fn: reRequest,
|
||||||
|
isInSliver: false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: snapshot.data['msg'],
|
||||||
HttpError(errMsg: snapshot.data['msg'], fn: reRequest)
|
fn: reRequest,
|
||||||
],
|
isInSliver: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -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
|
||||||
@ -394,14 +395,17 @@ class SearchBar extends StatelessWidget {
|
|||||||
color: colorScheme.onSecondaryContainer,
|
color: colorScheme.onSecondaryContainer,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Obx(
|
Expanded(
|
||||||
() => Text(
|
child: Obx(
|
||||||
ctr!.defaultSearch.value,
|
() => Text(
|
||||||
maxLines: 1,
|
ctr!.defaultSearch.value,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 1,
|
||||||
style: TextStyle(color: colorScheme.outline),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(color: colorScheme.outline),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -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),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class HtmlRenderController extends GetxController {
|
|||||||
RxInt oid = (-1).obs;
|
RxInt oid = (-1).obs;
|
||||||
late Map response;
|
late Map response;
|
||||||
int? floor;
|
int? floor;
|
||||||
int currentPage = 0;
|
String nextOffset = "";
|
||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
RxString noMore = ''.obs;
|
RxString noMore = ''.obs;
|
||||||
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
||||||
@ -52,21 +52,21 @@ class HtmlRenderController extends GetxController {
|
|||||||
Future queryReplyList({reqType = 'init'}) async {
|
Future queryReplyList({reqType = 'init'}) async {
|
||||||
var res = await ReplyHttp.replyList(
|
var res = await ReplyHttp.replyList(
|
||||||
oid: oid.value,
|
oid: oid.value,
|
||||||
pageNum: currentPage + 1,
|
nextOffset: nextOffset,
|
||||||
type: type,
|
type: type,
|
||||||
sort: _sortType.index,
|
sort: _sortType.index,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
List<ReplyItemModel> replies = res['data'].replies;
|
List<ReplyItemModel> replies = res['data'].replies;
|
||||||
acount.value = res['data'].page.acount;
|
acount.value = res['data'].cursor.allCount;
|
||||||
|
nextOffset = res['data'].cursor.paginationReply.nextOffset ?? "";
|
||||||
if (replies.isNotEmpty) {
|
if (replies.isNotEmpty) {
|
||||||
currentPage++;
|
|
||||||
noMore.value = '加载中...';
|
noMore.value = '加载中...';
|
||||||
if (replies.length < 20) {
|
if (res['data'].cursor.isEnd == true) {
|
||||||
noMore.value = '没有更多了';
|
noMore.value = '没有更多了';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
|
noMore.value = nextOffset == "" ? '还没有评论' : '没有更多了';
|
||||||
}
|
}
|
||||||
if (reqType == 'init') {
|
if (reqType == 'init') {
|
||||||
// 添加置顶回复
|
// 添加置顶回复
|
||||||
@ -102,7 +102,7 @@ class HtmlRenderController extends GetxController {
|
|||||||
}
|
}
|
||||||
sortTypeTitle.value = _sortType.titles;
|
sortTypeTitle.value = _sortType.titles;
|
||||||
sortTypeLabel.value = _sortType.labels;
|
sortTypeLabel.value = _sortType.labels;
|
||||||
currentPage = 0;
|
nextOffset = "";
|
||||||
replyList.clear();
|
replyList.clear();
|
||||||
queryReplyList(reqType: 'init');
|
queryReplyList(reqType: 'init');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -380,13 +380,10 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// 请求错误
|
// 请求错误
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: data['msg'],
|
||||||
HttpError(
|
fn: () => setState(() {}),
|
||||||
errMsg: data['msg'],
|
isInSliver: false,
|
||||||
fn: () => setState(() {}),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -22,11 +22,11 @@ class LaterController extends GetxController {
|
|||||||
userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future queryLaterList() async {
|
Future queryLaterList({type = 'init'}) async {
|
||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
return {'status': false, 'msg': '账号未登录', 'code': -101};
|
return {'status': false, 'msg': '账号未登录', 'code': -101};
|
||||||
}
|
}
|
||||||
isLoading.value = true;
|
isLoading.value = type == 'init';
|
||||||
var res = await UserHttp.seeYouLater();
|
var res = await UserHttp.seeYouLater();
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
count = res['data']['count'];
|
count = res['data']['count'];
|
||||||
|
|||||||
@ -66,67 +66,74 @@ class _LaterPageState extends State<LaterPage> {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: CustomScrollView(
|
body: RefreshIndicator(
|
||||||
controller: _laterController.scrollController,
|
onRefresh: () async {
|
||||||
slivers: [
|
await _laterController.queryLaterList(type: 'onRefresh');
|
||||||
FutureBuilder(
|
},
|
||||||
future: _futureBuilderFuture,
|
child: CustomScrollView(
|
||||||
builder: (context, snapshot) {
|
controller: _laterController.scrollController,
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
Map? data = snapshot.data;
|
slivers: [
|
||||||
if (data != null && data['status']) {
|
FutureBuilder(
|
||||||
return Obx(
|
future: _futureBuilderFuture,
|
||||||
() => _laterController.laterList.isNotEmpty &&
|
builder: (context, snapshot) {
|
||||||
!_laterController.isLoading.value
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
? SliverList(
|
Map? data = snapshot.data;
|
||||||
delegate:
|
if (data != null && data['status']) {
|
||||||
SliverChildBuilderDelegate((context, index) {
|
return Obx(
|
||||||
var videoItem = _laterController.laterList[index];
|
() => _laterController.laterList.isNotEmpty &&
|
||||||
return VideoCardH(
|
!_laterController.isLoading.value
|
||||||
videoItem: videoItem,
|
? SliverList(
|
||||||
source: 'later',
|
delegate:
|
||||||
onPressedFn: () => _laterController.toViewDel(
|
SliverChildBuilderDelegate((context, index) {
|
||||||
aid: videoItem.aid));
|
var videoItem =
|
||||||
}, childCount: _laterController.laterList.length),
|
_laterController.laterList[index];
|
||||||
)
|
return VideoCardH(
|
||||||
: _laterController.isLoading.value
|
videoItem: videoItem,
|
||||||
? const SliverToBoxAdapter(
|
source: 'later',
|
||||||
child: Center(child: Text('加载中')),
|
onPressedFn: () => _laterController
|
||||||
)
|
.toViewDel(aid: videoItem.aid));
|
||||||
: const NoData(),
|
}, childCount: _laterController.laterList.length),
|
||||||
);
|
)
|
||||||
|
: _laterController.isLoading.value
|
||||||
|
? const SliverToBoxAdapter(
|
||||||
|
child: Center(child: Text('加载中')),
|
||||||
|
)
|
||||||
|
: const NoData(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return HttpError(
|
||||||
|
errMsg: data?['msg'] ?? '请求异常',
|
||||||
|
btnText: data?['code'] == -101 ? '去登录' : null,
|
||||||
|
fn: () {
|
||||||
|
if (data?['code'] == -101) {
|
||||||
|
RoutePush.loginRedirectPush();
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_laterController.queryLaterList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
// 骨架屏
|
||||||
errMsg: data?['msg'] ?? '请求异常',
|
return SliverList(
|
||||||
btnText: data?['code'] == -101 ? '去登录' : null,
|
delegate: SliverChildBuilderDelegate((context, index) {
|
||||||
fn: () {
|
return const VideoCardHSkeleton();
|
||||||
if (data?['code'] == -101) {
|
}, childCount: 10),
|
||||||
RoutePush.loginRedirectPush();
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
_futureBuilderFuture =
|
|
||||||
_laterController.queryLaterList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
},
|
||||||
// 骨架屏
|
|
||||||
return SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate((context, index) {
|
|
||||||
return const VideoCardHSkeleton();
|
|
||||||
}, childCount: 10),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: SizedBox(
|
|
||||||
height: MediaQuery.of(context).padding.bottom + 10,
|
|
||||||
),
|
),
|
||||||
)
|
SliverToBoxAdapter(
|
||||||
],
|
child: SizedBox(
|
||||||
|
height: MediaQuery.of(context).padding.bottom + 80,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: Obx(
|
floatingActionButton: Obx(
|
||||||
() => _laterController.laterList.isNotEmpty
|
() => _laterController.laterList.isNotEmpty
|
||||||
|
|||||||
@ -14,6 +14,7 @@ class LiveController extends GetxController {
|
|||||||
RxList<LiveItemModel> liveList = <LiveItemModel>[].obs;
|
RxList<LiveItemModel> liveList = <LiveItemModel>[].obs;
|
||||||
RxList<LiveFollowingItemModel> liveFollowingList =
|
RxList<LiveFollowingItemModel> liveFollowingList =
|
||||||
<LiveFollowingItemModel>[].obs;
|
<LiveFollowingItemModel>[].obs;
|
||||||
|
RxInt liveFollowingCount = 0.obs;
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
OverlayEntry? popupDialog;
|
OverlayEntry? popupDialog;
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@ -27,9 +28,6 @@ class LiveController extends GetxController {
|
|||||||
|
|
||||||
// 获取推荐
|
// 获取推荐
|
||||||
Future queryLiveList(type) async {
|
Future queryLiveList(type) async {
|
||||||
// if (type == 'init') {
|
|
||||||
// _currentPage = 1;
|
|
||||||
// }
|
|
||||||
var res = await LiveHttp.liveList(
|
var res = await LiveHttp.liveList(
|
||||||
pn: _currentPage,
|
pn: _currentPage,
|
||||||
);
|
);
|
||||||
@ -68,13 +66,14 @@ class LiveController extends GetxController {
|
|||||||
|
|
||||||
//
|
//
|
||||||
Future fetchLiveFollowing() async {
|
Future fetchLiveFollowing() async {
|
||||||
var res = await LiveHttp.liveFollowing(pn: 1, ps: 20);
|
var res = await LiveHttp.liveFollowing(pn: 1, ps: 10);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
liveFollowingList.value =
|
liveFollowingList.value =
|
||||||
(res['data'].list as List<LiveFollowingItemModel>)
|
(res['data'].list as List<LiveFollowingItemModel>)
|
||||||
.where((LiveFollowingItemModel item) =>
|
.where((LiveFollowingItemModel item) =>
|
||||||
item.liveStatus == 1 && item.recordLiveTime == 0) // 根据条件过滤
|
item.liveStatus == 1 && item.recordLiveTime == 0) // 根据条件过滤
|
||||||
.toList();
|
.toList();
|
||||||
|
liveFollowingCount.value = res['data'].liveCount;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,34 +162,61 @@ class _LivePageState extends State<LivePage>
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Obx(
|
Row(
|
||||||
() => Text.rich(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
TextSpan(
|
children: [
|
||||||
children: [
|
Obx(
|
||||||
const TextSpan(
|
() => Text.rich(
|
||||||
text: ' 我的关注 ',
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 15,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' ${_liveController.liveFollowingList.length}',
|
children: [
|
||||||
style: TextStyle(
|
const TextSpan(
|
||||||
fontSize: 12,
|
text: ' 我的关注 ',
|
||||||
color: Theme.of(context).colorScheme.primary,
|
style: TextStyle(
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: ' ${_liveController.liveFollowingCount}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: '人正在直播',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
TextSpan(
|
),
|
||||||
text: '人正在直播',
|
),
|
||||||
style: TextStyle(
|
InkWell(
|
||||||
fontSize: 12,
|
onTap: () {
|
||||||
|
Get.toNamed('/liveFollowing');
|
||||||
|
},
|
||||||
|
highlightColor: Colors.transparent,
|
||||||
|
splashColor: Colors.transparent,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'查看更多',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.chevron_right,
|
||||||
color: Theme.of(context).colorScheme.outline,
|
color: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: _futureBuilderFuture2,
|
future: _futureBuilderFuture2,
|
||||||
@ -201,8 +228,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
Map? data = snapshot.data;
|
Map? data = snapshot.data;
|
||||||
if (data?['status']) {
|
if (data?['status']) {
|
||||||
RxList list = _liveController.liveFollowingList;
|
RxList list = _liveController.liveFollowingList;
|
||||||
// ignore: invalid_use_of_protected_member
|
return LiveFollowingListView(list: list);
|
||||||
return Obx(() => LiveFollowingListView(list: list.value));
|
|
||||||
} else {
|
} else {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 80,
|
height: 80,
|
||||||
@ -230,69 +256,71 @@ class _LivePageState extends State<LivePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LiveFollowingListView extends StatelessWidget {
|
class LiveFollowingListView extends StatelessWidget {
|
||||||
final List list;
|
final RxList list;
|
||||||
|
|
||||||
const LiveFollowingListView({super.key, required this.list});
|
const LiveFollowingListView({super.key, required this.list});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox(
|
return Obx(
|
||||||
height: 100,
|
() => SizedBox(
|
||||||
child: ListView.builder(
|
height: 100,
|
||||||
scrollDirection: Axis.horizontal,
|
child: ListView.builder(
|
||||||
itemBuilder: (context, index) {
|
scrollDirection: Axis.horizontal,
|
||||||
final LiveFollowingItemModel item = list[index];
|
itemBuilder: (context, index) {
|
||||||
return Padding(
|
final LiveFollowingItemModel item = list[index];
|
||||||
padding: const EdgeInsets.fromLTRB(3, 12, 3, 0),
|
return Padding(
|
||||||
child: Column(
|
padding: const EdgeInsets.fromLTRB(3, 12, 3, 0),
|
||||||
children: [
|
child: Column(
|
||||||
InkWell(
|
children: [
|
||||||
onTap: () {
|
InkWell(
|
||||||
Get.toNamed(
|
onTap: () {
|
||||||
'/liveRoom?roomid=${item.roomId}',
|
Get.toNamed(
|
||||||
arguments: {
|
'/liveRoom?roomid=${item.roomId}',
|
||||||
'liveItem': item,
|
arguments: {
|
||||||
'heroTag': item.roomId.toString()
|
'liveItem': item,
|
||||||
},
|
'heroTag': item.roomId.toString()
|
||||||
);
|
},
|
||||||
},
|
);
|
||||||
child: Container(
|
},
|
||||||
width: 54,
|
child: Container(
|
||||||
height: 54,
|
width: 54,
|
||||||
padding: const EdgeInsets.all(2),
|
height: 54,
|
||||||
decoration: BoxDecoration(
|
padding: const EdgeInsets.all(2),
|
||||||
borderRadius: BorderRadius.circular(27),
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
borderRadius: BorderRadius.circular(27),
|
||||||
color: Theme.of(context).colorScheme.primary,
|
border: Border.all(
|
||||||
width: 1.5,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: NetworkImgLayer(
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
type: 'avatar',
|
||||||
|
src: list[index].face,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: NetworkImgLayer(
|
),
|
||||||
width: 50,
|
const SizedBox(height: 6),
|
||||||
height: 50,
|
SizedBox(
|
||||||
type: 'avatar',
|
width: 62,
|
||||||
src: list[index].face,
|
child: Text(
|
||||||
|
list[index].uname,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
SizedBox(
|
);
|
||||||
width: 62,
|
},
|
||||||
child: Text(
|
itemCount: list.length,
|
||||||
list[index].uname,
|
),
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: list.length,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@ 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: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/badge.dart';
|
||||||
|
import 'package:pilipala/models/live/follow.dart';
|
||||||
import 'package:pilipala/models/live/item.dart';
|
import 'package:pilipala/models/live/item.dart';
|
||||||
import 'package:pilipala/utils/image_save.dart';
|
import 'package:pilipala/utils/image_save.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
@ -9,7 +11,7 @@ import 'package:pilipala/common/widgets/network_img_layer.dart';
|
|||||||
|
|
||||||
// 视频卡片 - 垂直布局
|
// 视频卡片 - 垂直布局
|
||||||
class LiveCardV extends StatelessWidget {
|
class LiveCardV extends StatelessWidget {
|
||||||
final LiveItemModel liveItem;
|
final dynamic liveItem;
|
||||||
final int crossAxisCount;
|
final int crossAxisCount;
|
||||||
|
|
||||||
const LiveCardV({
|
const LiveCardV({
|
||||||
@ -64,6 +66,9 @@ class LiveCardV extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (liveItem is LiveFollowingItemModel &&
|
||||||
|
liveItem.liveStatus == 1)
|
||||||
|
const PBadge(top: 8, right: 8, text: '直播中'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -148,7 +153,7 @@ class LiveContent extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class VideoStat extends StatelessWidget {
|
class VideoStat extends StatelessWidget {
|
||||||
final LiveItemModel? liveItem;
|
final dynamic liveItem;
|
||||||
|
|
||||||
const VideoStat({
|
const VideoStat({
|
||||||
Key? key,
|
Key? key,
|
||||||
@ -178,25 +183,20 @@ class VideoStat extends StatelessWidget {
|
|||||||
liveItem!.areaName!,
|
liveItem!.areaName!,
|
||||||
style: const TextStyle(fontSize: 11, color: Colors.white),
|
style: const TextStyle(fontSize: 11, color: Colors.white),
|
||||||
),
|
),
|
||||||
Text(
|
if (liveItem is LiveItemModel) ...[
|
||||||
liveItem!.watchedShow!['text_small'],
|
Text(
|
||||||
style: const TextStyle(fontSize: 11, color: Colors.white),
|
liveItem!.watchedShow?['text_small'],
|
||||||
),
|
style: const TextStyle(fontSize: 11, color: Colors.white),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (liveItem is LiveFollowingItemModel) ...[
|
||||||
|
Text(
|
||||||
|
'${liveItem.textSmall}',
|
||||||
|
style: const TextStyle(fontSize: 11, color: Colors.white),
|
||||||
|
),
|
||||||
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// child: RichText(
|
|
||||||
// maxLines: 1,
|
|
||||||
// textAlign: TextAlign.justify,
|
|
||||||
// softWrap: false,
|
|
||||||
// text: TextSpan(
|
|
||||||
// style: const TextStyle(fontSize: 11, color: Colors.white),
|
|
||||||
// children: [
|
|
||||||
// TextSpan(text: liveItem!.areaName!),
|
|
||||||
// TextSpan(text: liveItem!.watchedShow!['text_small']),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
lib/pages/live_follow/controller.dart
Normal file
50
lib/pages/live_follow/controller.dart
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/http/live.dart';
|
||||||
|
import 'package:pilipala/models/live/follow.dart';
|
||||||
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
class LiveFollowController extends GetxController {
|
||||||
|
RxInt crossAxisCount = 2.obs;
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
int _currentPage = 1;
|
||||||
|
RxInt liveFollowingCount = 0.obs;
|
||||||
|
RxList<LiveFollowingItemModel> liveFollowingList =
|
||||||
|
<LiveFollowingItemModel>[].obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
crossAxisCount.value =
|
||||||
|
setting.get(SettingBoxKey.customRows, defaultValue: 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future queryLiveFollowList(type) async {
|
||||||
|
var res = await LiveHttp.liveFollowing(
|
||||||
|
pn: _currentPage,
|
||||||
|
ps: 20,
|
||||||
|
);
|
||||||
|
if (res['status']) {
|
||||||
|
if (type == 'init') {
|
||||||
|
liveFollowingList.value = res['data'].list;
|
||||||
|
liveFollowingCount.value = res['data'].liveCount;
|
||||||
|
} else if (type == 'onLoad') {
|
||||||
|
liveFollowingList.addAll(res['data'].list);
|
||||||
|
}
|
||||||
|
_currentPage += 1;
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future onRefresh() async {
|
||||||
|
_currentPage = 1;
|
||||||
|
await queryLiveFollowList('init');
|
||||||
|
}
|
||||||
|
|
||||||
|
void onLoad() async {
|
||||||
|
queryLiveFollowList('onLoad');
|
||||||
|
}
|
||||||
|
}
|
||||||
4
lib/pages/live_follow/index.dart
Normal file
4
lib/pages/live_follow/index.dart
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
library live_follow;
|
||||||
|
|
||||||
|
export 'view.dart';
|
||||||
|
export 'controller.dart';
|
||||||
136
lib/pages/live_follow/view.dart
Normal file
136
lib/pages/live_follow/view.dart
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/common/constants.dart';
|
||||||
|
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
||||||
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
|
import 'package:pilipala/pages/live/widgets/live_item.dart';
|
||||||
|
|
||||||
|
import 'controller.dart';
|
||||||
|
|
||||||
|
class LiveFollowPage extends StatefulWidget {
|
||||||
|
const LiveFollowPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LiveFollowPage> createState() => _LiveFollowPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LiveFollowPageState extends State<LiveFollowPage> {
|
||||||
|
late Future _futureBuilderFuture;
|
||||||
|
final ScrollController scrollController = ScrollController();
|
||||||
|
final LiveFollowController _liveFollowController =
|
||||||
|
Get.put(LiveFollowController());
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_futureBuilderFuture = _liveFollowController.queryLiveFollowList('init');
|
||||||
|
scrollController.addListener(
|
||||||
|
() {
|
||||||
|
if (scrollController.position.pixels >=
|
||||||
|
scrollController.position.maxScrollExtent - 200) {
|
||||||
|
EasyThrottle.throttle(
|
||||||
|
'liveFollowList', const Duration(milliseconds: 200), () {
|
||||||
|
_liveFollowController.onLoad();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
elevation: 0,
|
||||||
|
scrolledUnderElevation: 0,
|
||||||
|
titleSpacing: 0,
|
||||||
|
centerTitle: false,
|
||||||
|
title: Obx(() => Text(
|
||||||
|
'${_liveFollowController.liveFollowingCount}人正在直播中',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
body: Container(
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
margin: const EdgeInsets.only(
|
||||||
|
left: StyleString.safeSpace, right: StyleString.safeSpace),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(StyleString.imgRadius),
|
||||||
|
),
|
||||||
|
child: RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
return await _liveFollowController.onRefresh();
|
||||||
|
},
|
||||||
|
child: CustomScrollView(
|
||||||
|
controller: scrollController,
|
||||||
|
slivers: [
|
||||||
|
SliverPadding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.fromLTRB(0, StyleString.safeSpace, 0, 0),
|
||||||
|
sliver: FutureBuilder(
|
||||||
|
future: _futureBuilderFuture,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
if (snapshot.data == null) {
|
||||||
|
return const SliverToBoxAdapter(child: SizedBox());
|
||||||
|
}
|
||||||
|
Map data = snapshot.data as Map;
|
||||||
|
if (data['status']) {
|
||||||
|
return SliverLayoutBuilder(
|
||||||
|
builder: (context, boxConstraints) {
|
||||||
|
return Obx(
|
||||||
|
() => contentGrid(_liveFollowController,
|
||||||
|
_liveFollowController.liveFollowingList),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return HttpError(
|
||||||
|
errMsg: data['msg'],
|
||||||
|
fn: () {
|
||||||
|
setState(() {
|
||||||
|
_futureBuilderFuture = _liveFollowController
|
||||||
|
.queryLiveFollowList('init');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return contentGrid(_liveFollowController, []);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget contentGrid(ctr, liveList) {
|
||||||
|
int crossAxisCount = ctr.crossAxisCount.value;
|
||||||
|
return SliverGrid(
|
||||||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
mainAxisSpacing: StyleString.safeSpace,
|
||||||
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
|
crossAxisCount: crossAxisCount,
|
||||||
|
mainAxisExtent:
|
||||||
|
Get.size.width / crossAxisCount / StyleString.aspectRatio +
|
||||||
|
MediaQuery.textScalerOf(context).scale(
|
||||||
|
(crossAxisCount == 1 ? 48 : 68),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
(BuildContext context, int index) {
|
||||||
|
return liveList!.isNotEmpty
|
||||||
|
? LiveCardV(
|
||||||
|
liveItem: liveList[index],
|
||||||
|
crossAxisCount: crossAxisCount,
|
||||||
|
)
|
||||||
|
: const VideoCardVSkeleton();
|
||||||
|
},
|
||||||
|
childCount: liveList!.isNotEmpty ? liveList!.length : 10,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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,10 +7,11 @@ 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';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import './controller.dart';
|
import './controller.dart';
|
||||||
|
|
||||||
@ -26,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;
|
||||||
@ -92,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
|
||||||
@ -126,6 +125,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
double sheetHeight = MediaQuery.sizeOf(context).height -
|
double sheetHeight = MediaQuery.sizeOf(context).height -
|
||||||
MediaQuery.of(context).padding.top -
|
MediaQuery.of(context).padding.top -
|
||||||
MediaQuery.sizeOf(context).width * 9 / 16;
|
MediaQuery.sizeOf(context).width * 9 / 16;
|
||||||
|
GlobalDataCache().sheetHeight = sheetHeight;
|
||||||
localCache.put('sheetHeight', sheetHeight);
|
localCache.put('sheetHeight', sheetHeight);
|
||||||
localCache.put('statusBarHeight', statusBarHeight);
|
localCache.put('statusBarHeight', statusBarHeight);
|
||||||
|
|
||||||
@ -205,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),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -32,7 +32,7 @@ class MemberController extends GetxController {
|
|||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
mid = int.parse(Get.parameters['mid']!);
|
mid = int.tryParse(Get.parameters['mid']!) ?? -2;
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
ownerMid = userInfo != null ? userInfo.mid : -1;
|
ownerMid = userInfo != null ? userInfo.mid : -1;
|
||||||
isOwner.value = mid == ownerMid;
|
isOwner.value = mid == ownerMid;
|
||||||
@ -43,6 +43,11 @@ class MemberController extends GetxController {
|
|||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
Future<Map<String, dynamic>> getInfo() async {
|
Future<Map<String, dynamic>> getInfo() async {
|
||||||
|
if (mid == -2) {
|
||||||
|
SmartDialog.showToast('用户ID获取异常');
|
||||||
|
return {'status': false, 'msg': '用户ID获取异常'};
|
||||||
|
}
|
||||||
|
|
||||||
await getMemberStat();
|
await getMemberStat();
|
||||||
await getMemberView();
|
await getMemberView();
|
||||||
var res = await MemberHttp.memberInfo(mid: mid);
|
var res = await MemberHttp.memberInfo(mid: mid);
|
||||||
@ -117,18 +122,13 @@ class MemberController extends GetxController {
|
|||||||
|
|
||||||
// 合并关注/取关和拉黑逻辑
|
// 合并关注/取关和拉黑逻辑
|
||||||
Future modifyRelation(String actionType) async {
|
Future modifyRelation(String actionType) async {
|
||||||
if (userInfo == null) {
|
|
||||||
SmartDialog.showToast('账号未登录');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String contentText;
|
String contentText;
|
||||||
int act;
|
int act;
|
||||||
if (actionType == 'follow') {
|
if (actionType == 'follow') {
|
||||||
contentText = memberInfo.value.isFollowed! ? '确定取消关注UP主?' : '确定关注UP主?';
|
contentText = memberInfo.value.isFollowed! ? '确定取消关注UP主?' : '确定关注UP主?';
|
||||||
act = memberInfo.value.isFollowed! ? 2 : 1;
|
act = memberInfo.value.isFollowed! ? 2 : 1;
|
||||||
} else if (actionType == 'block') {
|
} else if (actionType == 'block') {
|
||||||
contentText = attribute.value != 128 ? '确定拉黑UP主?' : '确定从黑名单移除UP主?';
|
contentText = attribute.value != 128 ? '确定拉黑UP主?' : '确定从黑名单移除UP主?';
|
||||||
act = attribute.value != 128 ? 5 : 6;
|
act = attribute.value != 128 ? 5 : 6;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.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/member/info.dart';
|
import 'package:pilipala/models/member/info.dart';
|
||||||
import 'package:pilipala/pages/member/index.dart';
|
import 'package:pilipala/pages/member/index.dart';
|
||||||
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import 'widgets/commen_widget.dart';
|
import 'widgets/commen_widget.dart';
|
||||||
import 'widgets/conis.dart';
|
import 'widgets/conis.dart';
|
||||||
@ -36,7 +39,7 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
mid = int.parse(Get.parameters['mid']!);
|
mid = int.tryParse(Get.parameters['mid']!) ?? -1;
|
||||||
heroTag = Get.arguments['heroTag'] ?? Utils.makeHeroTag(mid);
|
heroTag = Get.arguments['heroTag'] ?? Utils.makeHeroTag(mid);
|
||||||
_memberController = Get.put(MemberController(), tag: heroTag);
|
_memberController = Get.put(MemberController(), tag: heroTag);
|
||||||
_futureBuilderFuture = _memberController.getInfo();
|
_futureBuilderFuture = _memberController.getInfo();
|
||||||
@ -100,8 +103,14 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => Get.toNamed(
|
onPressed: () {
|
||||||
'/memberSearch?mid=$mid&uname=${_memberController.memberInfo.value.name!}'),
|
if (mid == -1) {
|
||||||
|
SmartDialog.showToast('用户ID获取异常');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Get.toNamed(
|
||||||
|
'/memberSearch?mid=$mid&uname=${_memberController.memberInfo.value.name ?? ''}');
|
||||||
|
},
|
||||||
icon: const Icon(Icons.search_outlined),
|
icon: const Icon(Icons.search_outlined),
|
||||||
),
|
),
|
||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
@ -147,6 +156,25 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
bottom: MediaQuery.of(context).padding.bottom + 20,
|
bottom: MediaQuery.of(context).padding.bottom + 20,
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
|
Obx(() {
|
||||||
|
Rx<MemberInfoModel> memberInfo = _memberController.memberInfo;
|
||||||
|
return memberInfo.value.silence != null &&
|
||||||
|
memberInfo.value.silence! == 1
|
||||||
|
? Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.only(top: 10, bottom: 10),
|
||||||
|
color: Theme.of(context).colorScheme.errorContainer,
|
||||||
|
child: Text(
|
||||||
|
'该账号封禁中',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onErrorContainer,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox();
|
||||||
|
}),
|
||||||
profileWidget(),
|
profileWidget(),
|
||||||
|
|
||||||
/// 动态链接
|
/// 动态链接
|
||||||
@ -311,6 +339,7 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
Rx<MemberInfoModel> memberInfo = _memberController.memberInfo;
|
Rx<MemberInfoModel> memberInfo = _memberController.memberInfo;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => Column(
|
() => Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
ProfilePanel(ctr: _memberController),
|
ProfilePanel(ctr: _memberController),
|
||||||
@ -369,7 +398,7 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
.value.vip!.label!['img_label_uri_hans_static'],
|
.value.vip!.label!['img_label_uri_hans_static'],
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (memberInfo.value.official!['title'] != '') ...[
|
if (memberInfo.value.official!['title'] != '') ...[
|
||||||
@ -386,6 +415,39 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
feedBack();
|
||||||
|
Clipboard.setData(ClipboardData(
|
||||||
|
text: memberInfo.value.mid.toString()));
|
||||||
|
SmartDialog.showToast('uid复制成功');
|
||||||
|
},
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
child: Ink(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceVariant,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10, vertical: 4),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 16,
|
||||||
|
child: Text(
|
||||||
|
'uid: ${memberInfo.value.mid}',
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSurfaceVariant,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
SelectableText(memberInfo.value.sign ?? ''),
|
SelectableText(memberInfo.value.sign ?? ''),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -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),
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class MemberSeasonsPanel extends StatelessWidget {
|
|||||||
'category': '1',
|
'category': '1',
|
||||||
'mid': item.meta!.mid.toString(),
|
'mid': item.meta!.mid.toString(),
|
||||||
'seriesId': item.meta!.seriesId.toString(),
|
'seriesId': item.meta!.seriesId.toString(),
|
||||||
|
'seasonId': item.meta!.seasonId.toString(),
|
||||||
'seasonName': item.meta!.name!,
|
'seasonName': item.meta!.name!,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/http/member.dart';
|
import 'package:pilipala/http/member.dart';
|
||||||
|
import 'package:pilipala/http/search.dart';
|
||||||
import 'package:pilipala/models/member/archive.dart';
|
import 'package:pilipala/models/member/archive.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
class MemberArchiveController extends GetxController {
|
class MemberArchiveController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
late int mid;
|
late int mid;
|
||||||
int pn = 1;
|
int pn = 1;
|
||||||
int count = 0;
|
RxInt count = 0.obs;
|
||||||
RxMap<String, String> currentOrder = <String, String>{}.obs;
|
RxMap<String, String> currentOrder = <String, String>{}.obs;
|
||||||
RxList<Map<String, String>> orderList = [
|
RxList<Map<String, String>> orderList = [
|
||||||
{'type': 'pubdate', 'label': '最新发布'},
|
{'type': 'pubdate', 'label': '最新发布'},
|
||||||
@ -17,12 +20,18 @@ class MemberArchiveController extends GetxController {
|
|||||||
].obs;
|
].obs;
|
||||||
RxList<VListItemModel> archivesList = <VListItemModel>[].obs;
|
RxList<VListItemModel> archivesList = <VListItemModel>[].obs;
|
||||||
RxBool isLoading = false.obs;
|
RxBool isLoading = false.obs;
|
||||||
|
late int ownerMid;
|
||||||
|
RxBool isOwner = false.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
mid = int.parse(Get.parameters['mid']!);
|
mid = int.parse(Get.parameters['mid']!);
|
||||||
currentOrder.value = orderList.first;
|
currentOrder.value = orderList.first;
|
||||||
|
ownerMid = GlobalDataCache().userInfo != null
|
||||||
|
? GlobalDataCache().userInfo!.mid!
|
||||||
|
: -1;
|
||||||
|
isOwner.value = mid == -1 || mid == ownerMid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户投稿
|
// 获取用户投稿
|
||||||
@ -43,11 +52,11 @@ class MemberArchiveController extends GetxController {
|
|||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
if (type == 'init') {
|
if (type == 'init') {
|
||||||
archivesList.value = res['data'].list.vlist;
|
archivesList.value = res['data'].list.vlist;
|
||||||
|
count.value = res['data'].page['count'];
|
||||||
}
|
}
|
||||||
if (type == 'onLoad') {
|
if (type == 'onLoad') {
|
||||||
archivesList.addAll(res['data'].list.vlist);
|
archivesList.addAll(res['data'].list.vlist);
|
||||||
}
|
}
|
||||||
count = res['data'].page['count'];
|
|
||||||
pn += 1;
|
pn += 1;
|
||||||
}
|
}
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
@ -69,4 +78,29 @@ class MemberArchiveController extends GetxController {
|
|||||||
Future onLoad() async {
|
Future onLoad() async {
|
||||||
getMemberArchive('onLoad');
|
getMemberArchive('onLoad');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future toViewPlayAll() async {
|
||||||
|
final VListItemModel firstItem = archivesList.first;
|
||||||
|
final String bvid = firstItem.bvid!;
|
||||||
|
final int cid = await SearchHttp.ab2c(bvid: bvid);
|
||||||
|
final String heroTag = Utils.makeHeroTag(bvid);
|
||||||
|
late Map sortFieldMap = {
|
||||||
|
'pubdate': 'pubtime',
|
||||||
|
'click': 'play',
|
||||||
|
'fav': 'fav',
|
||||||
|
};
|
||||||
|
Get.toNamed(
|
||||||
|
'/video?bvid=${firstItem.bvid}&cid=$cid',
|
||||||
|
arguments: {
|
||||||
|
'videoItem': firstItem,
|
||||||
|
'heroTag': heroTag,
|
||||||
|
'sourceType': 'up_archive',
|
||||||
|
'oid': firstItem.aid,
|
||||||
|
'favTitle': '${firstItem.owner!.name!} - ${currentOrder['label']!}',
|
||||||
|
'favInfo': firstItem,
|
||||||
|
'count': count.value,
|
||||||
|
'sortField': sortFieldMap[currentOrder['type']],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,8 +51,9 @@ class _MemberArchivePageState extends State<MemberArchivePage> {
|
|||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: Obx(
|
title: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
'他的投稿 - ${_memberArchivesController.currentOrder['label']}',
|
'${_memberArchivesController.isOwner.value ? '我' : 'Ta'}的投稿 - ${_memberArchivesController.currentOrder['label']}',
|
||||||
style: Theme.of(context).textTheme.titleMedium),
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
// Obx(
|
// Obx(
|
||||||
@ -134,6 +135,15 @@ class _MemberArchivePageState extends State<MemberArchivePage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
floatingActionButton: Obx(
|
||||||
|
() => _memberArchivesController.count > 0
|
||||||
|
? FloatingActionButton.extended(
|
||||||
|
onPressed: _memberArchivesController.toViewPlayAll,
|
||||||
|
label: const Text('播放全部'),
|
||||||
|
icon: const Icon(Icons.playlist_play),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/http/member.dart';
|
import 'package:pilipala/http/member.dart';
|
||||||
import 'package:pilipala/models/member/article.dart';
|
import 'package:pilipala/models/member/article.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
|
|
||||||
class MemberArticleController extends GetxController {
|
class MemberArticleController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
@ -12,15 +13,21 @@ class MemberArticleController extends GetxController {
|
|||||||
bool hasMore = true;
|
bool hasMore = true;
|
||||||
RxBool isLoading = false.obs;
|
RxBool isLoading = false.obs;
|
||||||
RxList<MemberArticleItemModel> articleList = <MemberArticleItemModel>[].obs;
|
RxList<MemberArticleItemModel> articleList = <MemberArticleItemModel>[].obs;
|
||||||
|
late int ownerMid;
|
||||||
|
RxBool isOwner = false.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
mid = int.parse(Get.parameters['mid']!);
|
mid = int.parse(Get.parameters['mid']!);
|
||||||
|
ownerMid = GlobalDataCache().userInfo != null
|
||||||
|
? GlobalDataCache().userInfo!.mid!
|
||||||
|
: -1;
|
||||||
|
isOwner.value = mid == -1 || mid == ownerMid;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future getMemberArticle(type) async {
|
Future getMemberArticle(type) async {
|
||||||
if (isLoading.value) {
|
if (isLoading.value || !hasMore) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
|||||||
@ -50,7 +50,12 @@ class _MemberArticlePageState extends State<MemberArticlePage> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: const Text('Ta的图文', style: TextStyle(fontSize: 16)),
|
title: Obx(
|
||||||
|
() => Text(
|
||||||
|
'${_memberArticleController.isOwner.value ? '我' : 'Ta'}的图文',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
body: FutureBuilder(
|
body: FutureBuilder(
|
||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
@ -113,12 +118,14 @@ class _MemberArticlePageState extends State<MemberArticlePage> {
|
|||||||
'articleType': 'opus',
|
'articleType': 'opus',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
leading: NetworkImgLayer(
|
leading: item?.cover != null
|
||||||
width: 50,
|
? NetworkImgLayer(
|
||||||
height: 50,
|
width: 50,
|
||||||
type: 'emote',
|
height: 50,
|
||||||
src: item.cover['url'],
|
type: 'emote',
|
||||||
),
|
src: item?.cover?['url'] ?? '',
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
title: Text(
|
title: Text(
|
||||||
item.content,
|
item.content,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
@ -138,16 +145,10 @@ class _MemberArticlePageState extends State<MemberArticlePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildError(String errMsg) {
|
Widget _buildError(String errMsg) {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
errMsg: errMsg,
|
||||||
slivers: [
|
fn: () {},
|
||||||
SliverToBoxAdapter(
|
isInSliver: false,
|
||||||
child: HttpError(
|
|
||||||
errMsg: errMsg,
|
|
||||||
fn: () {},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/http/member.dart';
|
import 'package:pilipala/http/member.dart';
|
||||||
import 'package:pilipala/models/dynamics/result.dart';
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
|
|
||||||
class MemberDynamicsController extends GetxController {
|
class MemberDynamicsController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
@ -10,11 +11,17 @@ class MemberDynamicsController extends GetxController {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
bool hasMore = true;
|
bool hasMore = true;
|
||||||
RxList<DynamicItemModel> dynamicsList = <DynamicItemModel>[].obs;
|
RxList<DynamicItemModel> dynamicsList = <DynamicItemModel>[].obs;
|
||||||
|
late int ownerMid;
|
||||||
|
RxBool isOwner = false.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
mid = int.parse(Get.parameters['mid']!);
|
mid = int.parse(Get.parameters['mid']!);
|
||||||
|
ownerMid = GlobalDataCache().userInfo != null
|
||||||
|
? GlobalDataCache().userInfo!.mid!
|
||||||
|
: -1;
|
||||||
|
isOwner.value = mid == -1 || mid == ownerMid;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future getMemberDynamic(type) async {
|
Future getMemberDynamic(type) async {
|
||||||
|
|||||||
@ -56,7 +56,12 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: Text('他的动态', style: Theme.of(context).textTheme.titleMedium),
|
title: Obx(
|
||||||
|
() => Text(
|
||||||
|
'${_memberDynamicController.isOwner.value ? '我' : 'Ta'}的动态',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
controller: _memberDynamicController.scrollController,
|
controller: _memberDynamicController.scrollController,
|
||||||
|
|||||||
@ -164,13 +164,10 @@ class _MemberSearchPageState extends State<MemberSearchPage>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: <Widget>[
|
errMsg: data['msg'],
|
||||||
HttpError(
|
fn: () => setState(() {}),
|
||||||
errMsg: data['msg'],
|
isInSliver: false,
|
||||||
fn: () => setState(() {}),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -24,7 +24,8 @@ class MemberSeasonsController extends GetxController {
|
|||||||
seasonId = int.parse(Get.parameters['seasonId']!);
|
seasonId = int.parse(Get.parameters['seasonId']!);
|
||||||
}
|
}
|
||||||
if (category == '1') {
|
if (category == '1') {
|
||||||
seriesId = int.parse(Get.parameters['seriesId']!);
|
seriesId = int.tryParse(Get.parameters['seriesId']!);
|
||||||
|
seasonId = int.tryParse(Get.parameters['seasonId']!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +74,27 @@ class MemberSeasonsController extends GetxController {
|
|||||||
getSeasonDetail('onLoad');
|
getSeasonDetail('onLoad');
|
||||||
}
|
}
|
||||||
if (category == '1') {
|
if (category == '1') {
|
||||||
getSeriesDetail('onLoad');
|
if (seasonId != null) {
|
||||||
|
getSeasonDetail('onLoad');
|
||||||
|
}
|
||||||
|
if (seriesId != null) {
|
||||||
|
getSeriesDetail('onLoad');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下拉刷新
|
||||||
|
Future onRefresh() async {
|
||||||
|
if (category == '0') {
|
||||||
|
return getSeasonDetail('onRefresh');
|
||||||
|
}
|
||||||
|
if (category == '1') {
|
||||||
|
if (seasonId != null) {
|
||||||
|
return getSeasonDetail('onRefresh');
|
||||||
|
}
|
||||||
|
if (seriesId != null) {
|
||||||
|
return getSeriesDetail('onRefresh');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,9 +23,7 @@ class _MemberSeasonsPageState extends State<MemberSeasonsPage> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
category = Get.parameters['category']!;
|
category = Get.parameters['category']!;
|
||||||
_futureBuilderFuture = category == '0'
|
_futureBuilderFuture = _memberSeasonsController.onRefresh();
|
||||||
? _memberSeasonsController.getSeasonDetail('onRefresh')
|
|
||||||
: _memberSeasonsController.getSeriesDetail('onRefresh');
|
|
||||||
scrollController = _memberSeasonsController.scrollController;
|
scrollController = _memberSeasonsController.scrollController;
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
() {
|
() {
|
||||||
|
|||||||
@ -1,3 +1,27 @@
|
|||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/http/msg.dart';
|
||||||
|
import 'package:pilipala/models/msg/at.dart';
|
||||||
|
|
||||||
class MessageAtController extends GetxController {}
|
class MessageAtController extends GetxController {
|
||||||
|
Cursor? cursor;
|
||||||
|
RxList<MessageAtItems> atItems = <MessageAtItems>[].obs;
|
||||||
|
|
||||||
|
Future queryMessageAt({String type = 'init'}) async {
|
||||||
|
if (cursor != null && cursor!.isEnd == true) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
var res = await MsgHttp.messageAt();
|
||||||
|
if (res['status']) {
|
||||||
|
cursor = res['data'].cursor;
|
||||||
|
if (type == 'init') {
|
||||||
|
atItems.value = res['data'].items;
|
||||||
|
} else {
|
||||||
|
atItems.addAll(res['data'].items);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,14 @@
|
|||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
|
import 'package:pilipala/common/widgets/no_data.dart';
|
||||||
|
import 'package:pilipala/models/msg/at.dart';
|
||||||
|
import 'package:pilipala/pages/message/utils/index.dart';
|
||||||
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
|
import 'controller.dart';
|
||||||
|
|
||||||
class MessageAtPage extends StatefulWidget {
|
class MessageAtPage extends StatefulWidget {
|
||||||
const MessageAtPage({super.key});
|
const MessageAtPage({super.key});
|
||||||
@ -8,12 +18,179 @@ class MessageAtPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MessageAtPageState extends State<MessageAtPage> {
|
class _MessageAtPageState extends State<MessageAtPage> {
|
||||||
|
final MessageAtController _messageAtCtr = Get.put(MessageAtController());
|
||||||
|
late Future _futureBuilderFuture;
|
||||||
|
final ScrollController scrollController = ScrollController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_futureBuilderFuture = _messageAtCtr.queryMessageAt();
|
||||||
|
scrollController.addListener(
|
||||||
|
() async {
|
||||||
|
if (scrollController.position.pixels >=
|
||||||
|
scrollController.position.maxScrollExtent - 200) {
|
||||||
|
EasyThrottle.throttle('follow', const Duration(seconds: 1), () {
|
||||||
|
_messageAtCtr.queryMessageAt(type: 'onLoad');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('@我的'),
|
title: const Text('@我的'),
|
||||||
),
|
),
|
||||||
|
body: RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
await _messageAtCtr.queryMessageAt(type: 'init');
|
||||||
|
},
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: _futureBuilderFuture,
|
||||||
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
final Map<String, dynamic>? data = snapshot.data;
|
||||||
|
if (data != null && data['status']) {
|
||||||
|
final RxList<MessageAtItems> atItems = _messageAtCtr.atItems;
|
||||||
|
return Obx(
|
||||||
|
() => atItems.isEmpty
|
||||||
|
? const CustomScrollView(slivers: [NoData()])
|
||||||
|
: ListView.separated(
|
||||||
|
controller: scrollController,
|
||||||
|
itemBuilder: (context, index) => AtItem(
|
||||||
|
item: atItems[index],
|
||||||
|
index: index,
|
||||||
|
messageAtCtr: _messageAtCtr,
|
||||||
|
),
|
||||||
|
itemCount: atItems.length,
|
||||||
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
|
return Divider(
|
||||||
|
indent: 66,
|
||||||
|
endIndent: 14,
|
||||||
|
height: 1,
|
||||||
|
color: Colors.grey.withOpacity(0.1),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// 请求错误
|
||||||
|
return HttpError(
|
||||||
|
errMsg: data?['msg'] ?? '请求异常',
|
||||||
|
fn: () {
|
||||||
|
setState(() {
|
||||||
|
_futureBuilderFuture = _messageAtCtr.queryMessageAt();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isInSliver: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AtItem extends StatelessWidget {
|
||||||
|
final MessageAtItems item;
|
||||||
|
final int index;
|
||||||
|
final MessageAtController messageAtCtr;
|
||||||
|
|
||||||
|
const AtItem({
|
||||||
|
super.key,
|
||||||
|
required this.item,
|
||||||
|
required this.index,
|
||||||
|
required this.messageAtCtr,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Color outline = Theme.of(context).colorScheme.outline;
|
||||||
|
final User user = item.user!;
|
||||||
|
final String heroTag = Utils.makeHeroTag(user.mid);
|
||||||
|
final Uri uri = Uri.parse(item.item!.uri!);
|
||||||
|
|
||||||
|
/// bilibili://
|
||||||
|
final Uri nativeUri = Uri.parse(item.item!.nativeUri!);
|
||||||
|
final String type = item.item!.type!;
|
||||||
|
|
||||||
|
return InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
MessageUtils.onClickMessage(context, uri, nativeUri, type);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Get.toNamed('/member?mid=${item.user!.mid}',
|
||||||
|
arguments: {'face': item.user!.avatar, 'heroTag': heroTag});
|
||||||
|
},
|
||||||
|
child: Hero(
|
||||||
|
tag: heroTag,
|
||||||
|
child: NetworkImgLayer(
|
||||||
|
width: 42,
|
||||||
|
height: 42,
|
||||||
|
type: 'avatar',
|
||||||
|
src: item.user!.avatar,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text.rich(TextSpan(children: [
|
||||||
|
TextSpan(text: item.user!.nickname!),
|
||||||
|
const TextSpan(text: ' '),
|
||||||
|
if (item.item!.type! == 'reply')
|
||||||
|
TextSpan(
|
||||||
|
text: '在评论中@了我',
|
||||||
|
style: TextStyle(color: outline),
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(item.item!.sourceContent!),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
Utils.dateFormat(item.atTime!, formatType: 'detail'),
|
||||||
|
style: TextStyle(color: outline),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 25),
|
||||||
|
if (item.item!.type! == 'reply')
|
||||||
|
Container(
|
||||||
|
width: 60,
|
||||||
|
height: 80,
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
child: Text(
|
||||||
|
item.item!.title!,
|
||||||
|
maxLines: 3,
|
||||||
|
style: const TextStyle(fontSize: 12, letterSpacing: 0.3),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,11 @@ class MessageLikeController extends GetxController {
|
|||||||
id: params['id'], likeTime: params['likeTime']);
|
id: params['id'], likeTime: params['likeTime']);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
cursor = res['data'].total.cursor;
|
cursor = res['data'].total.cursor;
|
||||||
likeItems.addAll(res['data'].total.items);
|
if (type == 'init') {
|
||||||
|
likeItems.value = res['data'].total.items;
|
||||||
|
} else {
|
||||||
|
likeItems.addAll(res['data'].total.items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.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/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/http/search.dart';
|
import 'package:pilipala/common/widgets/no_data.dart';
|
||||||
import 'package:pilipala/models/msg/like.dart';
|
import 'package:pilipala/models/msg/like.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
import '../utils/index.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class MessageLikePage extends StatefulWidget {
|
class MessageLikePage extends StatefulWidget {
|
||||||
@ -59,44 +58,40 @@ class _MessageLikePageState extends State<MessageLikePage> {
|
|||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.data == null) {
|
Map? data = snapshot.data;
|
||||||
return const SizedBox();
|
if (data != null && data['status']) {
|
||||||
}
|
|
||||||
if (snapshot.data['status']) {
|
|
||||||
final likeItems = _messageLikeCtr.likeItems;
|
final likeItems = _messageLikeCtr.likeItems;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => ListView.separated(
|
() => likeItems.isEmpty
|
||||||
controller: scrollController,
|
? const CustomScrollView(slivers: [NoData()])
|
||||||
itemBuilder: (context, index) => LikeItem(
|
: ListView.separated(
|
||||||
item: likeItems[index],
|
controller: scrollController,
|
||||||
index: index,
|
itemBuilder: (context, index) => LikeItem(
|
||||||
messageLikeCtr: _messageLikeCtr,
|
item: likeItems[index],
|
||||||
),
|
index: index,
|
||||||
itemCount: likeItems.length,
|
messageLikeCtr: _messageLikeCtr,
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
),
|
||||||
return Divider(
|
itemCount: likeItems.length,
|
||||||
indent: 66,
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
endIndent: 14,
|
return Divider(
|
||||||
height: 1,
|
indent: 66,
|
||||||
color: Colors.grey.withOpacity(0.1),
|
endIndent: 14,
|
||||||
);
|
height: 1,
|
||||||
},
|
color: Colors.grey.withOpacity(0.1),
|
||||||
),
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// 请求错误
|
// 请求错误
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: data?['msg'] ?? '请求异常',
|
||||||
HttpError(
|
fn: () {
|
||||||
errMsg: snapshot.data['msg'],
|
setState(() {
|
||||||
fn: () {
|
_futureBuilderFuture = _messageLikeCtr.queryMessageLike();
|
||||||
setState(() {
|
});
|
||||||
_futureBuilderFuture =
|
},
|
||||||
_messageLikeCtr.queryMessageLike();
|
isInSliver: false,
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -126,39 +121,13 @@ class LikeItem extends StatelessWidget {
|
|||||||
final nickNameList = item.users!.map((e) => e.nickname).take(2).toList();
|
final nickNameList = item.users!.map((e) => e.nickname).take(2).toList();
|
||||||
int usersLen = item.users!.length > 3 ? 3 : item.users!.length;
|
int usersLen = item.users!.length > 3 ? 3 : item.users!.length;
|
||||||
final Uri uri = Uri.parse(item.item!.uri!);
|
final Uri uri = Uri.parse(item.item!.uri!);
|
||||||
final String path = uri.path;
|
|
||||||
final String bvid = path.split('/').last;
|
|
||||||
|
|
||||||
/// bilibili://
|
/// bilibili://
|
||||||
final Uri nativeUri = Uri.parse(item.item!.nativeUri!);
|
final Uri nativeUri = Uri.parse(item.item!.nativeUri!);
|
||||||
final Map<String, String> queryParameters = nativeUri.queryParameters;
|
|
||||||
final String type = item.item!.type!;
|
final String type = item.item!.type!;
|
||||||
// cid
|
|
||||||
final String? argCid = queryParameters['cid'];
|
|
||||||
// 页码
|
|
||||||
final String? page = queryParameters['page'];
|
|
||||||
// 根评论id
|
|
||||||
final String? commentRootId = queryParameters['comment_root_id'];
|
|
||||||
// 二级评论id
|
|
||||||
final String? commentSecondaryId = queryParameters['comment_secondary_id'];
|
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
try {
|
MessageUtils.onClickMessage(context, uri, nativeUri, type);
|
||||||
final int cid = argCid != null
|
|
||||||
? int.parse(argCid)
|
|
||||||
: await SearchHttp.ab2c(bvid: bvid);
|
|
||||||
final String heroTag = Utils.makeHeroTag(bvid);
|
|
||||||
Get.toNamed<dynamic>(
|
|
||||||
'/video?bvid=$bvid&cid=$cid',
|
|
||||||
arguments: <String, String?>{
|
|
||||||
'pic': '',
|
|
||||||
'heroTag': heroTag,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
SmartDialog.showToast('视频可能失效了$e');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -247,6 +216,7 @@ class LikeItem extends StatelessWidget {
|
|||||||
width: 60,
|
width: 60,
|
||||||
height: 60,
|
height: 60,
|
||||||
src: item.item!.image,
|
src: item.item!.image,
|
||||||
|
radius: 6,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -4,10 +4,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/http/search.dart';
|
import 'package:pilipala/common/widgets/no_data.dart';
|
||||||
import 'package:pilipala/models/msg/reply.dart';
|
import 'package:pilipala/models/msg/reply.dart';
|
||||||
|
import 'package:pilipala/pages/message/utils/index.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class MessageReplyPage extends StatefulWidget {
|
class MessageReplyPage extends StatefulWidget {
|
||||||
@ -59,41 +59,38 @@ class _MessageReplyPageState extends State<MessageReplyPage> {
|
|||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.data == null) {
|
Map? data = snapshot.data;
|
||||||
return const SizedBox();
|
if (data != null && data['status']) {
|
||||||
}
|
|
||||||
if (snapshot.data['status']) {
|
|
||||||
final replyItems = _messageReplyCtr.replyItems;
|
final replyItems = _messageReplyCtr.replyItems;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => ListView.separated(
|
() => replyItems.isEmpty
|
||||||
controller: scrollController,
|
? const CustomScrollView(slivers: [NoData()])
|
||||||
itemBuilder: (context, index) =>
|
: ListView.separated(
|
||||||
ReplyItem(item: replyItems[index]),
|
controller: scrollController,
|
||||||
itemCount: replyItems.length,
|
itemBuilder: (context, index) =>
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
ReplyItem(item: replyItems[index]),
|
||||||
return Divider(
|
itemCount: replyItems.length,
|
||||||
indent: 66,
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
endIndent: 14,
|
return Divider(
|
||||||
height: 1,
|
indent: 66,
|
||||||
color: Colors.grey.withOpacity(0.1),
|
endIndent: 14,
|
||||||
);
|
height: 1,
|
||||||
},
|
color: Colors.grey.withOpacity(0.1),
|
||||||
),
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// 请求错误
|
// 请求错误
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: data?['msg'] ?? '请求异常',
|
||||||
HttpError(
|
fn: () {
|
||||||
errMsg: snapshot.data['msg'],
|
setState(() {
|
||||||
fn: () {
|
_futureBuilderFuture =
|
||||||
setState(() {
|
_messageReplyCtr.queryMessageReply();
|
||||||
_futureBuilderFuture =
|
});
|
||||||
_messageReplyCtr.queryMessageReply();
|
},
|
||||||
});
|
isInSliver: false,
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -115,28 +112,14 @@ class ReplyItem extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Color outline = Theme.of(context).colorScheme.outline;
|
Color outline = Theme.of(context).colorScheme.outline;
|
||||||
final String heroTag = Utils.makeHeroTag(item.user!.mid);
|
final String heroTag = Utils.makeHeroTag(item.user!.mid);
|
||||||
final String bvid = item.item!.uri!.split('/').last;
|
final Uri uri = Uri.parse(item.item!.uri!);
|
||||||
// 页码
|
|
||||||
final String page =
|
|
||||||
item.item!.nativeUri!.split('page=').last.split('&').first;
|
|
||||||
// 根评论id
|
|
||||||
final String commentRootId =
|
|
||||||
item.item!.nativeUri!.split('comment_root_id=').last.split('&').first;
|
|
||||||
// 二级评论id
|
|
||||||
final String commentSecondaryId =
|
|
||||||
item.item!.nativeUri!.split('comment_secondary_id=').last;
|
|
||||||
|
|
||||||
|
/// bilibili://
|
||||||
|
final Uri nativeUri = Uri.parse(item.item!.nativeUri!);
|
||||||
|
final String type = item.item!.type!;
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final int cid = await SearchHttp.ab2c(bvid: bvid);
|
MessageUtils.onClickMessage(context, uri, nativeUri, type);
|
||||||
final String heroTag = Utils.makeHeroTag(bvid);
|
|
||||||
Get.toNamed<dynamic>(
|
|
||||||
'/video?bvid=$bvid&cid=$cid',
|
|
||||||
arguments: <String, String?>{
|
|
||||||
'pic': '',
|
|
||||||
'heroTag': heroTag,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(14),
|
padding: const EdgeInsets.all(14),
|
||||||
@ -220,6 +203,7 @@ class ReplyItem extends StatelessWidget {
|
|||||||
width: 60,
|
width: 60,
|
||||||
height: 60,
|
height: 60,
|
||||||
src: item.item!.image,
|
src: item.item!.image,
|
||||||
|
radius: 6,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/models/msg/system.dart';
|
import 'package:pilipala/models/msg/system.dart';
|
||||||
|
import 'package:pilipala/pages/message/utils/index.dart';
|
||||||
|
import 'package:pilipala/utils/app_scheme.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class MessageSystemPage extends StatefulWidget {
|
class MessageSystemPage extends StatefulWidget {
|
||||||
@ -63,18 +66,15 @@ class _MessageSystemPageState extends State<MessageSystemPage> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// 请求错误
|
// 请求错误
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: snapshot.data['msg'],
|
||||||
HttpError(
|
fn: () {
|
||||||
errMsg: snapshot.data['msg'],
|
setState(() {
|
||||||
fn: () {
|
_futureBuilderFuture =
|
||||||
setState(() {
|
_messageSystemCtr.queryMessageSystem();
|
||||||
_futureBuilderFuture =
|
});
|
||||||
_messageSystemCtr.queryMessageSystem();
|
},
|
||||||
});
|
isInSliver: false,
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -114,9 +114,73 @@ class SystemItem extends StatelessWidget {
|
|||||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
Text(item.content is String ? item.content : item.content!['web']),
|
Text.rich(
|
||||||
|
TextSpan(
|
||||||
|
children: [
|
||||||
|
buildContent(
|
||||||
|
context,
|
||||||
|
item.content is String ? item.content : item.content!['web']!,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// if (item.content is String)
|
||||||
|
// Text(item.content)
|
||||||
|
// else ...[
|
||||||
|
// Text(item.content!['web']!),
|
||||||
|
// ]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InlineSpan buildContent(
|
||||||
|
BuildContext context,
|
||||||
|
String content,
|
||||||
|
) {
|
||||||
|
final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||||
|
final List<InlineSpan> spanChilds = <InlineSpan>[];
|
||||||
|
Map<String, dynamic> contentMap = MessageUtils().extractLinks(content);
|
||||||
|
List<String> keys = contentMap.keys.toList();
|
||||||
|
keys.removeWhere((element) => element == 'message');
|
||||||
|
String patternStr = keys.join('|');
|
||||||
|
RegExp regExp = RegExp(patternStr, caseSensitive: false);
|
||||||
|
|
||||||
|
contentMap['message'].splitMapJoin(
|
||||||
|
regExp,
|
||||||
|
onMatch: (Match match) {
|
||||||
|
if (match.group(0) != '' && !match.group(0)!.startsWith('BV')) {
|
||||||
|
spanChilds.add(
|
||||||
|
WidgetSpan(
|
||||||
|
child: Icon(Icons.link, color: colorScheme.primary, size: 16),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
spanChilds.add(
|
||||||
|
TextSpan(
|
||||||
|
text: match.group(0),
|
||||||
|
style: TextStyle(
|
||||||
|
color: colorScheme.primary,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
PiliSchame.routePush(Uri.parse(contentMap[match.group(0)]));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
onNonMatch: (String text) {
|
||||||
|
spanChilds.add(
|
||||||
|
TextSpan(
|
||||||
|
text: text,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return TextSpan(
|
||||||
|
children: spanChilds,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
158
lib/pages/message/utils/index.dart
Normal file
158
lib/pages/message/utils/index.dart
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/http/search.dart';
|
||||||
|
import 'package:pilipala/models/common/reply_type.dart';
|
||||||
|
import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
|
||||||
|
import 'package:pilipala/utils/app_scheme.dart';
|
||||||
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
|
class MessageUtils {
|
||||||
|
// 回复我的、收到的赞点击
|
||||||
|
static void onClickMessage(
|
||||||
|
BuildContext context, Uri uri, Uri nativeUri, String type) async {
|
||||||
|
final String path = uri.path;
|
||||||
|
final String bvid = path.split('/').last;
|
||||||
|
String? sourceType;
|
||||||
|
final String nativePath = nativeUri.path;
|
||||||
|
String oid = nativePath.split('/').last;
|
||||||
|
final Map<String, String> queryParameters = nativeUri.queryParameters;
|
||||||
|
final String? argCid = queryParameters['cid'];
|
||||||
|
// final String? page = queryParameters['page'];
|
||||||
|
String? commentRootId = queryParameters['comment_root_id'];
|
||||||
|
// final String? commentSecondaryId = queryParameters['comment_secondary_id'];
|
||||||
|
if (nativePath.contains('detail')) {
|
||||||
|
// 动态详情
|
||||||
|
sourceType = 'opus';
|
||||||
|
oid = nativePath.split('/')[3];
|
||||||
|
commentRootId = nativePath.split('/')[4];
|
||||||
|
}
|
||||||
|
switch (type) {
|
||||||
|
case 'video':
|
||||||
|
case 'danmu':
|
||||||
|
try {
|
||||||
|
final int cid = argCid != null
|
||||||
|
? int.parse(argCid)
|
||||||
|
: await SearchHttp.ab2c(bvid: bvid);
|
||||||
|
final String heroTag = Utils.makeHeroTag(bvid);
|
||||||
|
Get.toNamed<dynamic>(
|
||||||
|
'/video?bvid=$bvid&cid=$cid',
|
||||||
|
arguments: <String, String?>{
|
||||||
|
'pic': '',
|
||||||
|
'heroTag': heroTag,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
SmartDialog.showToast('视频可能失效了$e');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'reply':
|
||||||
|
debugPrint('commentRootId: $oid, $commentRootId');
|
||||||
|
navigateToComment(
|
||||||
|
context,
|
||||||
|
oid,
|
||||||
|
commentRootId!,
|
||||||
|
sourceType == 'opus' ? ReplyType.dynamics : ReplyType.video,
|
||||||
|
nativeUri,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 跳转查看评论
|
||||||
|
static void navigateToComment(
|
||||||
|
BuildContext context,
|
||||||
|
String oid,
|
||||||
|
String rpid,
|
||||||
|
ReplyType replyType,
|
||||||
|
Uri nativeUri,
|
||||||
|
) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('评论详情'),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
tooltip: '查看原内容',
|
||||||
|
onPressed: () {
|
||||||
|
PiliSchame.routePush(nativeUri);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.open_in_new_outlined),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: VideoReplyReplyPanel(
|
||||||
|
oid: int.tryParse(oid),
|
||||||
|
rpid: int.tryParse(rpid),
|
||||||
|
source: 'routePush',
|
||||||
|
replyType: replyType,
|
||||||
|
firstFloor: null,
|
||||||
|
showRoot: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 匹配链接
|
||||||
|
Map<String, String> extractLinks(String text) {
|
||||||
|
Map<String, String> result = {};
|
||||||
|
String message = '';
|
||||||
|
// 是否匹配到bv
|
||||||
|
RegExp bvRegex = RegExp(r'bv1[\d\w]{9}', caseSensitive: false);
|
||||||
|
final Iterable<RegExpMatch> bvMatches = bvRegex.allMatches(text);
|
||||||
|
for (var match in bvMatches) {
|
||||||
|
result[match.group(0)!] =
|
||||||
|
'https://www.bilibili.com/video/${match.group(0)!}';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义正则表达式
|
||||||
|
RegExp regex = RegExp(
|
||||||
|
r'(?:(?:(?:http:\/\/|https:\/\/)(?:[a-zA-Z0-9_.-]+\.)*(?:bilibili|biligame)\.com(?:\/[/.$*?~=#!%@&\-\w]*)?)|(?:(?:http:\/\/|https:\/\/)(?:[a-zA-Z0-9_.-]+\.)*(?:acg|b23)\.tv(?:\/[/.$*?~=#!%@&\-\w]*)?)|(?:(?:http:\/\/|https:\/\/)dl\.(?:hdslb)\.com(?:\/[/.$*?~=#!%@&\-\w]*)?))');
|
||||||
|
// 链接文字
|
||||||
|
RegExp linkTextRegex = RegExp(r"#\{(.*?)\}");
|
||||||
|
final Iterable<RegExpMatch> matches = regex.allMatches(text);
|
||||||
|
int lastMatchEnd = 0;
|
||||||
|
if (matches.isNotEmpty) {
|
||||||
|
for (var match in matches) {
|
||||||
|
final int start = match.start;
|
||||||
|
final int end = match.end;
|
||||||
|
String str = text.substring(lastMatchEnd, start);
|
||||||
|
final Iterable<RegExpMatch> linkTextMatches =
|
||||||
|
linkTextRegex.allMatches(str);
|
||||||
|
|
||||||
|
if (linkTextMatches.isNotEmpty) {
|
||||||
|
for (var linkTextMatch in linkTextMatches) {
|
||||||
|
if (linkTextMatch.group(1) != null) {
|
||||||
|
String linkText = linkTextMatch.group(1)!;
|
||||||
|
str = str
|
||||||
|
.replaceAll(linkTextMatch.group(0)!, linkText)
|
||||||
|
.replaceAll('{', '')
|
||||||
|
.replaceAll('}', '');
|
||||||
|
result[linkText] = match.group(0)!;
|
||||||
|
}
|
||||||
|
print('str: $str');
|
||||||
|
message += str;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message += '$str查看详情';
|
||||||
|
result['查看详情'] = match.group(0)!;
|
||||||
|
}
|
||||||
|
lastMatchEnd = end;
|
||||||
|
}
|
||||||
|
// 处理剩余的未匹配部分
|
||||||
|
if (lastMatchEnd < text.length) {
|
||||||
|
message += text.substring(lastMatchEnd + 1);
|
||||||
|
}
|
||||||
|
result['message'] = message;
|
||||||
|
} else {
|
||||||
|
result['message'] = text;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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,71 +41,212 @@ 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(
|
||||||
child: Column(
|
parent: BouncingScrollPhysics()),
|
||||||
children: [
|
child: Padding(
|
||||||
const SizedBox(height: 10),
|
padding: const EdgeInsets.only(bottom: 110),
|
||||||
FutureBuilder(
|
child: Column(
|
||||||
future: _futureBuilderFuture,
|
children: [
|
||||||
builder: (context, snapshot) {
|
Obx(() => _buildProfileSection(context, ctr.userInfo.value)),
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
const SizedBox(height: 10),
|
||||||
if (snapshot.data == null) {
|
FutureBuilder(
|
||||||
return const SizedBox();
|
future: _futureBuilderFuture,
|
||||||
}
|
builder: (context, snapshot) {
|
||||||
if (snapshot.data['status']) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
return Obx(
|
if (snapshot.data == null) {
|
||||||
() => userInfoBuild(mineController, context));
|
return const SizedBox();
|
||||||
} else {
|
|
||||||
return userInfoBuild(mineController, context);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return userInfoBuild(mineController, context);
|
|
||||||
}
|
}
|
||||||
},
|
if (snapshot.data['status']) {
|
||||||
|
return Obx(
|
||||||
|
() => _buildStatsSection(
|
||||||
|
context,
|
||||||
|
ctr.userStat.value,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return _buildStatsSection(
|
||||||
|
context,
|
||||||
|
ctr.userStat.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -108,257 +254,257 @@ class _MinePageState extends State<MinePage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,10 +1,13 @@
|
|||||||
|
import 'dart:async';
|
||||||
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:get/get_rx/src/rx_workers/utils/debouncer.dart';
|
import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/search.dart';
|
import 'package:pilipala/http/search.dart';
|
||||||
import 'package:pilipala/models/search/hot.dart';
|
import 'package:pilipala/models/search/hot.dart';
|
||||||
import 'package:pilipala/models/search/suggest.dart';
|
import 'package:pilipala/models/search/suggest.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
class SSearchController extends GetxController {
|
class SSearchController extends GetxController {
|
||||||
@ -12,7 +15,7 @@ class SSearchController extends GetxController {
|
|||||||
RxString searchKeyWord = ''.obs;
|
RxString searchKeyWord = ''.obs;
|
||||||
Rx<TextEditingController> controller = TextEditingController().obs;
|
Rx<TextEditingController> controller = TextEditingController().obs;
|
||||||
RxList<HotSearchItem> hotSearchList = <HotSearchItem>[].obs;
|
RxList<HotSearchItem> hotSearchList = <HotSearchItem>[].obs;
|
||||||
Box histiryWord = GStrorage.historyword;
|
Box localCache = GStrorage.localCache;
|
||||||
List historyCacheList = [];
|
List historyCacheList = [];
|
||||||
RxList historyList = [].obs;
|
RxList historyList = [].obs;
|
||||||
RxList<SearchSuggestItem> searchSuggestList = <SearchSuggestItem>[].obs;
|
RxList<SearchSuggestItem> searchSuggestList = <SearchSuggestItem>[].obs;
|
||||||
@ -22,23 +25,28 @@ class SSearchController extends GetxController {
|
|||||||
RxString defaultSearch = ''.obs;
|
RxString defaultSearch = ''.obs;
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
bool enableHotKey = true;
|
bool enableHotKey = true;
|
||||||
|
bool enableSearchSuggest = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
// 其他页面跳转过来
|
// 其他页面跳转过来
|
||||||
if (Get.parameters.keys.isNotEmpty) {
|
final parameters = Get.parameters;
|
||||||
if (Get.parameters['keyword'] != null) {
|
if (parameters.keys.isNotEmpty) {
|
||||||
onClickKeyword(Get.parameters['keyword']!);
|
final keyword = parameters['keyword'];
|
||||||
|
if (keyword != null) {
|
||||||
|
onClickKeyword(keyword);
|
||||||
}
|
}
|
||||||
if (Get.parameters['hintText'] != null) {
|
|
||||||
hintText = Get.parameters['hintText']!;
|
final hint = parameters['hintText'];
|
||||||
searchKeyWord.value = hintText;
|
if (hint != null) {
|
||||||
|
hintText = hint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
historyCacheList = histiryWord.get('cacheList') ?? [];
|
historyCacheList = GlobalDataCache().historyCacheList;
|
||||||
historyList.value = historyCacheList;
|
historyList.value = historyCacheList;
|
||||||
enableHotKey = setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
|
enableHotKey = setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
|
||||||
|
enableSearchSuggest = GlobalDataCache().enableSearchSuggest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onChange(value) {
|
void onChange(value) {
|
||||||
@ -47,34 +55,29 @@ class SSearchController extends GetxController {
|
|||||||
searchSuggestList.value = [];
|
searchSuggestList.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_debouncer.call(() => querySearchSuggest(value));
|
if (enableSearchSuggest) {
|
||||||
|
_debouncer.call(() => querySearchSuggest(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClear() {
|
void onClear() {
|
||||||
if (searchKeyWord.value.isNotEmpty && controller.value.text != '') {
|
controller.value.clear();
|
||||||
controller.value.clear();
|
searchKeyWord.value = '';
|
||||||
searchKeyWord.value = '';
|
searchSuggestList.value = [];
|
||||||
searchSuggestList.value = [];
|
|
||||||
} else {
|
|
||||||
Get.back();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
void submit() {
|
void submit() {
|
||||||
// ignore: unrelated_type_equality_checks
|
if (searchKeyWord.value == '' && hintText.isNotEmpty && hintText == '搜索') {
|
||||||
if (searchKeyWord == '') {
|
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
if (searchKeyWord.value == '' && hintText != '搜索') {
|
||||||
|
searchKeyWord.value = hintText;
|
||||||
|
controller.value.text = hintText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List arr = historyCacheList.where((e) => e != searchKeyWord.value).toList();
|
hintText = '搜索';
|
||||||
arr.insert(0, searchKeyWord.value);
|
cacheHistory();
|
||||||
historyCacheList = arr;
|
|
||||||
|
|
||||||
historyList.value = historyCacheList;
|
|
||||||
// 手动刷新
|
|
||||||
historyList.refresh();
|
|
||||||
histiryWord.put('cacheList', historyCacheList);
|
|
||||||
searchFocusNode.unfocus();
|
|
||||||
Get.toNamed('/searchResult', parameters: {'keyword': searchKeyWord.value});
|
Get.toNamed('/searchResult', parameters: {'keyword': searchKeyWord.value});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,13 +120,26 @@ class SSearchController extends GetxController {
|
|||||||
int index = historyList.indexOf(word);
|
int index = historyList.indexOf(word);
|
||||||
historyList.removeAt(index);
|
historyList.removeAt(index);
|
||||||
historyList.refresh();
|
historyList.refresh();
|
||||||
histiryWord.put('cacheList', historyList);
|
localCache.put('cacheList', historyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClearHis() {
|
onClearHis() {
|
||||||
historyList.value = [];
|
historyList.value = [];
|
||||||
historyCacheList = [];
|
historyCacheList = [];
|
||||||
historyList.refresh();
|
historyList.refresh();
|
||||||
histiryWord.put('cacheList', []);
|
localCache.put('cacheList', []);
|
||||||
|
GlobalDataCache().historyCacheList = [];
|
||||||
|
SmartDialog.showToast('搜索历史已清空');
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheHistory() {
|
||||||
|
List arr = historyCacheList.where((e) => e != searchKeyWord.value).toList();
|
||||||
|
arr.insert(0, searchKeyWord.value);
|
||||||
|
historyCacheList = arr;
|
||||||
|
historyList.value = historyCacheList;
|
||||||
|
historyList.refresh();
|
||||||
|
localCache.put('cacheList', historyCacheList);
|
||||||
|
GlobalDataCache().historyCacheList = historyCacheList;
|
||||||
|
searchFocusNode.unfocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
@ -54,7 +53,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => _searchController.submit(),
|
onPressed: () => _searchController.submit(),
|
||||||
icon: const Icon(CupertinoIcons.search, size: 22),
|
icon: const Icon(Icons.search),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10)
|
const SizedBox(width: 10)
|
||||||
],
|
],
|
||||||
@ -64,18 +63,35 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
focusNode: _searchController.searchFocusNode,
|
focusNode: _searchController.searchFocusNode,
|
||||||
controller: _searchController.controller.value,
|
controller: _searchController.controller.value,
|
||||||
textInputAction: TextInputAction.search,
|
textInputAction: TextInputAction.search,
|
||||||
onChanged: (value) => _searchController.onChange(value),
|
onChanged: _searchController.onChange,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: _searchController.hintText,
|
hintText: _searchController.hintText,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
suffixIcon: IconButton(
|
suffix: Obx(() {
|
||||||
icon: Icon(
|
RxString searchKeyWord = _searchController.searchKeyWord;
|
||||||
Icons.clear,
|
if (searchKeyWord.value.isEmpty) {
|
||||||
size: 22,
|
return const SizedBox();
|
||||||
color: Theme.of(context).colorScheme.outline,
|
}
|
||||||
),
|
return Row(
|
||||||
onPressed: () => _searchController.onClear(),
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
children: [
|
||||||
|
if (RegExp(r'^\d+$').hasMatch(searchKeyWord.value))
|
||||||
|
IconButton(
|
||||||
|
tooltip: '直达up主页',
|
||||||
|
icon: const Icon(Icons.person_outline, size: 22),
|
||||||
|
onPressed: () {
|
||||||
|
_searchController.cacheHistory();
|
||||||
|
Get.toNamed('/member?mid=${searchKeyWord.value}',
|
||||||
|
arguments: {'face': null});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.clear, size: 22),
|
||||||
|
onPressed: () => _searchController.onClear(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
onSubmitted: (String value) => _searchController.submit(),
|
onSubmitted: (String value) => _searchController.submit(),
|
||||||
),
|
),
|
||||||
@ -84,7 +100,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 6),
|
||||||
// 搜索建议
|
// 搜索建议
|
||||||
_searchSuggest(),
|
_searchSuggest(),
|
||||||
// 热搜
|
// 热搜
|
||||||
@ -135,7 +151,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 6),
|
padding: const EdgeInsets.fromLTRB(6, 0, 6, 4),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -153,7 +169,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
padding: MaterialStateProperty.all(const EdgeInsets.only(
|
padding: MaterialStateProperty.all(const EdgeInsets.only(
|
||||||
left: 10, top: 6, bottom: 6, right: 10)),
|
left: 10, top: 6, bottom: 6, right: 10)),
|
||||||
),
|
),
|
||||||
onPressed: () => ctr.queryHotSearchList(),
|
onPressed: ctr.queryHotSearchList,
|
||||||
icon: const Icon(Icons.refresh_outlined, size: 18),
|
icon: const Icon(Icons.refresh_outlined, size: 18),
|
||||||
label: const Text('刷新'),
|
label: const Text('刷新'),
|
||||||
),
|
),
|
||||||
@ -187,13 +203,10 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return CustomScrollView(
|
return HttpError(
|
||||||
slivers: [
|
errMsg: data['msg'],
|
||||||
HttpError(
|
fn: () => setState(() {}),
|
||||||
errMsg: data['msg'],
|
isInSliver: false,
|
||||||
fn: () => setState(() {}),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -202,6 +215,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
return HotKeyword(
|
return HotKeyword(
|
||||||
width: width,
|
width: width,
|
||||||
hotSearchList: _searchController.hotSearchList,
|
hotSearchList: _searchController.hotSearchList,
|
||||||
|
onClick: () {},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
@ -220,13 +234,13 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
return Obx(
|
return Obx(
|
||||||
() => Container(
|
() => Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.fromLTRB(10, 25, 6, 0),
|
padding: const EdgeInsets.fromLTRB(10, 20, 4, 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (_searchController.historyList.isNotEmpty)
|
if (_searchController.historyList.isNotEmpty)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(6, 0, 0, 2),
|
padding: const EdgeInsets.fromLTRB(6, 0, 6, 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -237,10 +251,19 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
.titleMedium!
|
.titleMedium!
|
||||||
.copyWith(fontWeight: FontWeight.bold),
|
.copyWith(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
TextButton(
|
SizedBox(
|
||||||
onPressed: () => _searchController.onClearHis(),
|
height: 34,
|
||||||
child: const Text('清空'),
|
child: TextButton.icon(
|
||||||
)
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(
|
||||||
|
const EdgeInsets.only(
|
||||||
|
left: 10, top: 6, bottom: 6, right: 10)),
|
||||||
|
),
|
||||||
|
onPressed: _searchController.onClearHis,
|
||||||
|
icon: const Icon(Icons.clear_all_outlined, size: 18),
|
||||||
|
label: const Text('清空'),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
// ignore: file_names
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class HotKeyword extends StatelessWidget {
|
class HotKeyword extends StatelessWidget {
|
||||||
final double? width;
|
final double width;
|
||||||
final List? hotSearchList;
|
final List hotSearchList;
|
||||||
final Function? onClick;
|
final Function onClick;
|
||||||
|
|
||||||
const HotKeyword({
|
const HotKeyword({
|
||||||
this.width,
|
required this.width,
|
||||||
this.hotSearchList,
|
required this.hotSearchList,
|
||||||
this.onClick,
|
required this.onClick,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -18,45 +18,67 @@ class HotKeyword extends StatelessWidget {
|
|||||||
return Wrap(
|
return Wrap(
|
||||||
runSpacing: 0.4,
|
runSpacing: 0.4,
|
||||||
spacing: 5.0,
|
spacing: 5.0,
|
||||||
children: [
|
children: hotSearchList.map((item) {
|
||||||
for (var i in hotSearchList!)
|
return HotKeywordItem(
|
||||||
SizedBox(
|
width: width,
|
||||||
width: width! / 2 - 4,
|
item: item,
|
||||||
child: Material(
|
onClick: onClick,
|
||||||
borderRadius: BorderRadius.circular(3),
|
isRightPadding: hotSearchList.indexOf(item) % 2 == 1,
|
||||||
clipBehavior: Clip.hardEdge,
|
);
|
||||||
child: InkWell(
|
}).toList(),
|
||||||
onTap: () => onClick!(i.keyword),
|
);
|
||||||
child: Padding(
|
}
|
||||||
padding: EdgeInsets.only(
|
}
|
||||||
left: 2,
|
|
||||||
right: hotSearchList!.indexOf(i) % 2 == 1 ? 10 : 0),
|
class HotKeywordItem extends StatelessWidget {
|
||||||
child: Row(
|
final double width;
|
||||||
children: [
|
final dynamic item;
|
||||||
Flexible(
|
final Function onClick;
|
||||||
child: Padding(
|
final bool isRightPadding;
|
||||||
padding: const EdgeInsets.fromLTRB(6, 5, 4, 5),
|
|
||||||
child: Text(
|
const HotKeywordItem({
|
||||||
i.keyword!,
|
required this.width,
|
||||||
overflow: TextOverflow.ellipsis,
|
required this.item,
|
||||||
maxLines: 1,
|
required this.onClick,
|
||||||
style: const TextStyle(fontSize: 14),
|
required this.isRightPadding,
|
||||||
),
|
super.key,
|
||||||
),
|
});
|
||||||
),
|
|
||||||
if (i.icon != null && i.icon != '')
|
@override
|
||||||
SizedBox(
|
Widget build(BuildContext context) {
|
||||||
height: 15,
|
return SizedBox(
|
||||||
child: CachedNetworkImage(
|
width: width / 2 - 4,
|
||||||
imageUrl: i.icon!, height: 15.0),
|
child: Material(
|
||||||
),
|
borderRadius: BorderRadius.circular(4),
|
||||||
],
|
clipBehavior: Clip.hardEdge,
|
||||||
),
|
child: InkWell(
|
||||||
),
|
onTap: () => onClick.call(item.keyword),
|
||||||
),
|
child: Padding(
|
||||||
),
|
padding: EdgeInsets.only(left: 2, right: isRightPadding ? 10 : 0),
|
||||||
),
|
child: Row(
|
||||||
],
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(6, 5, 4, 5),
|
||||||
|
child: Text(
|
||||||
|
item.keyword,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (item.icon != null && item.icon != '')
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
child:
|
||||||
|
CachedNetworkImage(imageUrl: item.icon!, height: 15.0),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
|
||||||
class SearchText extends StatelessWidget {
|
class SearchText extends StatelessWidget {
|
||||||
final String? searchText;
|
final String? searchText;
|
||||||
@ -17,30 +18,31 @@ class SearchText extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||||
return Material(
|
return Material(
|
||||||
color: isSelect
|
color: isSelect
|
||||||
? Theme.of(context).colorScheme.primaryContainer
|
? colorScheme.primaryContainer
|
||||||
: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
|
: colorScheme.surfaceVariant.withOpacity(0.5),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
onSelect!(searchText);
|
onSelect?.call(searchText);
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
onLongSelect!(searchText);
|
feedBack();
|
||||||
|
onLongSelect?.call(searchText);
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 11),
|
||||||
const EdgeInsets.only(top: 5, bottom: 5, left: 11, right: 11),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
searchText!,
|
searchText!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelect
|
color: isSelect
|
||||||
? Theme.of(context).colorScheme.primary
|
? colorScheme.primary
|
||||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user