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
|
||||
- GT3Captcha-iOS
|
||||
- GT3Captcha-iOS (0.15.8.3)
|
||||
- image_picker_ios (0.0.1):
|
||||
- Flutter
|
||||
- media_kit_libs_ios_video (1.0.4):
|
||||
- Flutter
|
||||
- media_kit_native_event_loop (1.0.0):
|
||||
@ -80,6 +82,7 @@ DEPENDENCIES:
|
||||
- flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`)
|
||||
- fluttertoast (from `.symlinks/plugins/fluttertoast/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_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`)
|
||||
- media_kit_video (from `.symlinks/plugins/media_kit_video/ios`)
|
||||
@ -129,6 +132,8 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/fluttertoast/ios"
|
||||
gt3_flutter_plugin:
|
||||
:path: ".symlinks/plugins/gt3_flutter_plugin/ios"
|
||||
image_picker_ios:
|
||||
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||
media_kit_libs_ios_video:
|
||||
:path: ".symlinks/plugins/media_kit_libs_ios_video/ios"
|
||||
media_kit_native_event_loop:
|
||||
@ -179,6 +184,7 @@ SPEC CHECKSUMS:
|
||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||
gt3_flutter_plugin: 5bd2c08d3c19cbb6ee3b08f4358439e54c8ab2ee
|
||||
GT3Captcha-iOS: 5e3b1077834d8a9d6f4d64a447a30af3e14affe6
|
||||
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
|
||||
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
|
||||
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
|
||||
media_kit_video: 5da63f157170e5bf303bf85453b7ef6971218a2e
|
||||
|
||||
@ -15,6 +15,4 @@ class Constants {
|
||||
// 59b43e04ad6965f34319062b478f83dd TV端
|
||||
static const String appSec = '59b43e04ad6965f34319062b478f83dd';
|
||||
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_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: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 'widgets/badge.dart';
|
||||
import 'widgets/stat/danmu.dart';
|
||||
import 'widgets/stat/view.dart';
|
||||
|
||||
class EpisodeBottomSheet {
|
||||
final List<dynamic> episodes;
|
||||
final int currentCid;
|
||||
final dynamic dataType;
|
||||
final BuildContext context;
|
||||
final Function changeFucCall;
|
||||
final int? cid;
|
||||
final double? sheetHeight;
|
||||
bool isFullScreen = false;
|
||||
final UgcSeason? ugcSeason;
|
||||
|
||||
EpisodeBottomSheet({
|
||||
required this.episodes,
|
||||
required this.currentCid,
|
||||
required this.dataType,
|
||||
required this.context,
|
||||
required this.changeFucCall,
|
||||
this.cid,
|
||||
this.sheetHeight,
|
||||
this.isFullScreen = false,
|
||||
this.ugcSeason,
|
||||
});
|
||||
|
||||
Widget buildEpisodeListItem(
|
||||
dynamic episode,
|
||||
int index,
|
||||
bool isCurrentIndex,
|
||||
) {
|
||||
Widget buildShowContent() {
|
||||
return PagesBottomSheet(
|
||||
episodes: episodes,
|
||||
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 onSurface = Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
@ -45,128 +276,308 @@ class EpisodeBottomSheet {
|
||||
title = '第${episode.title}话 ${episode.longTitle!}';
|
||||
break;
|
||||
}
|
||||
|
||||
return isFullScreen || episode?.cover == null || episode?.cover == ''
|
||||
? ListTile(
|
||||
onTap: () {
|
||||
SmartDialog.showToast('切换至「$title」');
|
||||
changeFucCall.call(episode, index);
|
||||
},
|
||||
dense: false,
|
||||
leading: isCurrentIndex
|
||||
? Image.asset(
|
||||
'assets/images/live.gif',
|
||||
color: primary,
|
||||
height: 12,
|
||||
? _buildListTile(context, title, primary, onSurface)
|
||||
: _buildInkWell(context, title, primary, onSurface);
|
||||
}
|
||||
|
||||
Widget _buildListTile(
|
||||
BuildContext context, String title, Color primary, Color onSurface) {
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
if (isCurrentIndex) {
|
||||
return;
|
||||
}
|
||||
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: () {
|
||||
SmartDialog.showToast('切换至「$title」');
|
||||
if (isCurrentIndex) {
|
||||
return;
|
||||
}
|
||||
SmartDialog.showToast('切换至「${episode.title}」');
|
||||
changeFucCall.call(episode, index);
|
||||
},
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 14, right: 14, top: 8, bottom: 8),
|
||||
child: Row(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 130, height: 75, src: episode?.cover ?? ''),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isCurrentIndex ? primary : onSurface,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
dataType == VideoEpidoesType.bangumiEpisode
|
||||
? '第${index + 1}话'
|
||||
: '第${index + 1}p',
|
||||
style: textStyle),
|
||||
const SizedBox(height: 1),
|
||||
Text(
|
||||
episode.title,
|
||||
maxLines: 1,
|
||||
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,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// The [BuildContext] of the widget that calls the bottom sheet.
|
||||
PersistentBottomSheetController show(BuildContext context) {
|
||||
final PersistentBottomSheetController btmSheetCtr = showBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return buildShowContent(context);
|
||||
},
|
||||
if (dataType == VideoEpidoesType.bangumiEpisode &&
|
||||
episode.badge != '' &&
|
||||
episode.badge != null)
|
||||
Positioned(
|
||||
right: 8,
|
||||
top: 18,
|
||||
child: Text(
|
||||
episode.badge,
|
||||
style: const TextStyle(fontSize: 11, color: Color(0xFFFF6699)),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
class MediaBangumiSkeleton extends StatefulWidget {
|
||||
class MediaBangumiSkeleton extends StatelessWidget {
|
||||
const MediaBangumiSkeleton({super.key});
|
||||
|
||||
@override
|
||||
State<MediaBangumiSkeleton> createState() => _MediaBangumiSkeletonState();
|
||||
}
|
||||
|
||||
class _MediaBangumiSkeletonState extends State<MediaBangumiSkeleton> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color bgColor = Theme.of(context).colorScheme.onInverseSurface;
|
||||
@ -35,25 +30,25 @@ class _MediaBangumiSkeletonState extends State<MediaBangumiSkeleton> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: bgColor,
|
||||
width: 200,
|
||||
height: 20,
|
||||
margin: const EdgeInsets.only(bottom: 15),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: bgColor,
|
||||
width: 150,
|
||||
height: 13,
|
||||
margin: const EdgeInsets.only(bottom: 5),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: bgColor,
|
||||
width: 150,
|
||||
height: 13,
|
||||
margin: const EdgeInsets.only(bottom: 5),
|
||||
),
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
color: bgColor,
|
||||
width: 150,
|
||||
height: 13,
|
||||
),
|
||||
@ -64,7 +59,7 @@ class _MediaBangumiSkeletonState extends State<MediaBangumiSkeleton> {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
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 {
|
||||
const HttpError({
|
||||
required this.errMsg,
|
||||
required this.fn,
|
||||
this.fn,
|
||||
this.btnText,
|
||||
this.isShowBtn = true,
|
||||
this.isInSliver = true,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@ -14,46 +15,41 @@ class HttpError extends StatelessWidget {
|
||||
final Function()? fn;
|
||||
final String? btnText;
|
||||
final bool isShowBtn;
|
||||
final bool isInSliver;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 400,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/images/error.svg",
|
||||
height: 200,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
errMsg ?? '请求异常',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (isShowBtn)
|
||||
FilledButton.tonal(
|
||||
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),
|
||||
),
|
||||
Color primary = Theme.of(context).colorScheme.primary;
|
||||
final errorContent = SizedBox(
|
||||
height: 400,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset("assets/images/error.svg", height: 200),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
errMsg ?? '请求异常',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (isShowBtn)
|
||||
FilledButton.tonal(
|
||||
onPressed: () => fn?.call(),
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
return primary.withAlpha(20);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
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%
|
||||
this.quality,
|
||||
this.origAspectRatio,
|
||||
this.radius,
|
||||
});
|
||||
|
||||
final String? src;
|
||||
@ -30,6 +31,18 @@ class NetworkImgLayer extends StatelessWidget {
|
||||
final Duration? fadeInDuration;
|
||||
final int? quality;
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
@ -72,13 +85,7 @@ class NetworkImgLayer extends StatelessWidget {
|
||||
return src != '' && src != null
|
||||
? ClipRRect(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
borderRadius: BorderRadius.circular(
|
||||
type == 'avatar'
|
||||
? 50
|
||||
: type == 'emote'
|
||||
? 0
|
||||
: StyleString.imgRadius.x,
|
||||
),
|
||||
borderRadius: getBorderRadius(type, radius),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: imageUrl,
|
||||
width: width,
|
||||
@ -107,11 +114,7 @@ class NetworkImgLayer extends StatelessWidget {
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(type == 'avatar'
|
||||
? 50
|
||||
: type == 'emote'
|
||||
? 0
|
||||
: StyleString.imgRadius.x),
|
||||
borderRadius: getBorderRadius(type, radius),
|
||||
),
|
||||
child: type == 'bg'
|
||||
? 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
|
||||
static const String replyList = '/x/v2/reply';
|
||||
static const String replyList = '/x/v2/reply/main';
|
||||
|
||||
// 楼中楼
|
||||
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 searchHistory = '/x/web-goblin/history/search';
|
||||
static const String searchHistory = '/x/web-interface/history/search';
|
||||
|
||||
// 热搜
|
||||
static const String hotSearchList =
|
||||
@ -301,10 +301,6 @@ class Api {
|
||||
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';
|
||||
|
||||
// 我的订阅
|
||||
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';
|
||||
|
||||
@ -499,7 +495,7 @@ class Api {
|
||||
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';
|
||||
@ -593,6 +589,24 @@ class Api {
|
||||
static const String liveRoomEntry =
|
||||
'${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 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 'index.dart';
|
||||
import 'package:html/parser.dart' as html_parser;
|
||||
import 'package:html/dom.dart' as html_dom;
|
||||
|
||||
class BangumiHttp {
|
||||
static Future bangumiList({int? page}) async {
|
||||
@ -18,8 +21,19 @@ class BangumiHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future bangumiFollow({int? mid}) async {
|
||||
var res = await Request().get(Api.bangumiFollow, data: {'vmid': mid});
|
||||
static Future getRecentBangumi({
|
||||
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) {
|
||||
return {
|
||||
'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 {
|
||||
Document rootTree = parse(response.data);
|
||||
// log(response.data.body.toString());
|
||||
Element body = rootTree.body!;
|
||||
Element appDom = body.querySelector('#app')!;
|
||||
Element authorHeader = appDom.querySelector('.fixed-author-header')!;
|
||||
@ -52,7 +51,6 @@ class HtmlHttp {
|
||||
.className
|
||||
.split(' ')[1]
|
||||
.split('-')[2];
|
||||
// List imgList = opusDetail.querySelectorAll('bili-album__preview__picture__img');
|
||||
return {
|
||||
'status': true,
|
||||
'avatar': avatar,
|
||||
@ -76,20 +74,10 @@ class HtmlHttp {
|
||||
Element body = rootTree.body!;
|
||||
Element appDom = body.querySelector('#app')!;
|
||||
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();
|
||||
// 动态详情
|
||||
Element opusDetail = appDom.querySelector('.article-content')!;
|
||||
// 发布时间
|
||||
// String updateTime =
|
||||
// opusDetail.querySelector('.opus-module-author__pub__text')!.text;
|
||||
// print(updateTime);
|
||||
|
||||
//
|
||||
String opusContent =
|
||||
opusDetail.querySelector('#read-article-holder')!.innerHtml;
|
||||
RegExp digitRegExp = RegExp(r'\d+');
|
||||
|
||||
@ -8,7 +8,6 @@ import 'package:cookie_jar/cookie_jar.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/io.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:pilipala/utils/id_utils.dart';
|
||||
import '../utils/storage.dart';
|
||||
@ -171,15 +170,6 @@ class Request {
|
||||
|
||||
dio = Dio(options);
|
||||
|
||||
/// fix 第三方登录 302重定向 跟iOS代理问题冲突
|
||||
// ..httpClientAdapter = Http2Adapter(
|
||||
// ConnectionManager(
|
||||
// idleTimeout: const Duration(milliseconds: 10000),
|
||||
// onClientCreate: (_, ClientSetting config) =>
|
||||
// config.onBadCertificate = (_) => true,
|
||||
// ),
|
||||
// );
|
||||
|
||||
/// 设置代理
|
||||
if (enableSystemProxy) {
|
||||
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(url, {data, queryParameters, options, cancelToken, extra}) async {
|
||||
// print('post-data: $data');
|
||||
Response response;
|
||||
try {
|
||||
response = await dio.post(
|
||||
@ -262,7 +267,6 @@ class Request {
|
||||
options ?? Options(contentType: Headers.formUrlEncodedContentType),
|
||||
cancelToken: cancelToken,
|
||||
);
|
||||
// print('post success: ${response.data}');
|
||||
return response;
|
||||
} on DioException catch (e) {
|
||||
Response errResponse = Response(
|
||||
@ -318,7 +322,7 @@ class Request {
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -3,8 +3,7 @@
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import '../utils/storage.dart';
|
||||
import 'package:pilipala/utils/login.dart';
|
||||
|
||||
class ApiInterceptor extends Interceptor {
|
||||
@override
|
||||
@ -19,20 +18,9 @@ class ApiInterceptor extends Interceptor {
|
||||
@override
|
||||
void onResponse(Response response, ResponseInterceptorHandler handler) {
|
||||
try {
|
||||
if (response.statusCode == 302) {
|
||||
final List<String> locations = response.headers['location']!;
|
||||
if (locations.isNotEmpty) {
|
||||
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 (_) {}
|
||||
}
|
||||
}
|
||||
// 在响应之后处理数据
|
||||
if (response.data is Map && response.data['code'] == -101) {
|
||||
LoginUtils.loginOut();
|
||||
}
|
||||
} catch (err) {
|
||||
print('ApiInterceptor: $err');
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'dart:convert';
|
||||
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/reply.dart';
|
||||
import 'package:pilipala/models/msg/system.dart';
|
||||
@ -63,7 +65,7 @@ class MsgHttp {
|
||||
.toList(),
|
||||
};
|
||||
} catch (err) {
|
||||
print('err🔟: $err');
|
||||
debugPrint('err: $err');
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
@ -278,10 +280,10 @@ class MsgHttp {
|
||||
'data': MessageLikeModel.fromJson(res.data['data']),
|
||||
};
|
||||
} catch (err) {
|
||||
return {'status': false, 'date': [], 'msg': err.toString()};
|
||||
return {'status': false, 'data': [], 'msg': err.toString()};
|
||||
}
|
||||
} 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']};
|
||||
}
|
||||
}
|
||||
|
||||
// @我的
|
||||
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/emote.dart';
|
||||
import 'api.dart';
|
||||
@ -6,17 +11,16 @@ import 'init.dart';
|
||||
class ReplyHttp {
|
||||
static Future replyList({
|
||||
required int oid,
|
||||
required int pageNum,
|
||||
required String nextOffset,
|
||||
required int type,
|
||||
int? ps,
|
||||
int sort = 1,
|
||||
}) async {
|
||||
var res = await Request().get(Api.replyList, data: {
|
||||
'oid': oid,
|
||||
'pn': pageNum,
|
||||
'type': type,
|
||||
'sort': sort,
|
||||
'ps': ps ?? 20
|
||||
'pagination_str': jsonEncode({'offset': nextOffset}),
|
||||
'mode': sort + 2,
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
@ -52,19 +56,13 @@ class ReplyHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': ReplyData.fromJson(res.data['data']),
|
||||
'data': ReplyReplyData.fromJson(res.data['data']),
|
||||
};
|
||||
} else {
|
||||
Map errMap = {
|
||||
-400: '请求错误',
|
||||
-404: '无此项',
|
||||
12002: '评论区已关闭',
|
||||
12009: '评论主体的type不合法',
|
||||
};
|
||||
return {
|
||||
'status': false,
|
||||
'date': [],
|
||||
'msg': errMap[res.data['code']] ?? '请求异常',
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -136,4 +134,44 @@ class ReplyHttp {
|
||||
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:developer';
|
||||
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:pilipala/models/video/later.dart';
|
||||
import '../common/constants.dart';
|
||||
import '../models/model_hot_video_item.dart';
|
||||
import '../models/user/fav_detail.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 {
|
||||
var res = await Request().post(
|
||||
@ -283,30 +262,6 @@ class UserHttp {
|
||||
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(
|
||||
@ -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) {
|
||||
RegExp scriptRegExp = RegExp(r'<script>([\s\S]*?)<\/script>');
|
||||
Iterable<Match> matches = scriptRegExp.allMatches(htmlContent);
|
||||
@ -537,4 +467,83 @@ class UserHttp {
|
||||
.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 'package:dio/dio.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import '../common/constants.dart';
|
||||
import '../models/common/reply_type.dart';
|
||||
@ -95,6 +97,8 @@ class VideoHttp {
|
||||
for (var i in res.data['data']['items']) {
|
||||
// 屏蔽推广和拉黑用户
|
||||
if (i['card_goto'] != 'ad_av' &&
|
||||
i['card_goto'] != 'ad_web_s' &&
|
||||
i['card_goto'] != 'ad_web' &&
|
||||
(!enableRcmdDynamic ? i['card_goto'] != 'picture' : true) &&
|
||||
(i['args'] != null &&
|
||||
!blackMidsList.contains(i['args']['up_mid']))) {
|
||||
@ -346,23 +350,37 @@ class VideoHttp {
|
||||
required String message,
|
||||
int? root,
|
||||
int? parent,
|
||||
List<Map<dynamic, dynamic>>? pictures,
|
||||
}) async {
|
||||
if (message == '') {
|
||||
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(
|
||||
Api.replyAdd,
|
||||
data: {
|
||||
'type': type.index,
|
||||
'oid': oid,
|
||||
'root': root == null || root == 0 ? '' : root,
|
||||
'parent': parent == null || parent == 0 ? '' : parent,
|
||||
'message': message,
|
||||
'csrf': await Request.getCsrf(),
|
||||
queryParameters: {
|
||||
'w_rid': sign['w_rid'],
|
||||
'wts': sign['wts'],
|
||||
},
|
||||
data: formData,
|
||||
);
|
||||
log(res.toString());
|
||||
if (res.data['code'] == 0) {
|
||||
log(res.toString());
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
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: {
|
||||
'cid': cid,
|
||||
'bvid': bvid,
|
||||
if (bvid != null) 'bvid': bvid,
|
||||
if (aid != null) 'aid': aid,
|
||||
});
|
||||
try {
|
||||
if (res.data['code'] == 0) {
|
||||
|
||||
@ -144,6 +144,7 @@ class EpisodeItem {
|
||||
this.link,
|
||||
this.longTitle,
|
||||
this.pubTime,
|
||||
this.pubdate,
|
||||
this.pv,
|
||||
this.releaseDate,
|
||||
this.rights,
|
||||
@ -155,6 +156,7 @@ class EpisodeItem {
|
||||
this.subtitle,
|
||||
this.title,
|
||||
this.vid,
|
||||
this.stat,
|
||||
});
|
||||
|
||||
int? aid;
|
||||
@ -173,6 +175,7 @@ class EpisodeItem {
|
||||
String? link;
|
||||
String? longTitle;
|
||||
int? pubTime;
|
||||
int? pubdate;
|
||||
int? pv;
|
||||
String? releaseDate;
|
||||
Map? rights;
|
||||
@ -184,6 +187,7 @@ class EpisodeItem {
|
||||
String? subtitle;
|
||||
String? title;
|
||||
String? vid;
|
||||
String? stat;
|
||||
|
||||
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
||||
aid = json['aid'];
|
||||
@ -202,6 +206,7 @@ class EpisodeItem {
|
||||
link = json['link'];
|
||||
longTitle = json['long_title'];
|
||||
pubTime = json['pub_time'];
|
||||
pubdate = json['pub_time'];
|
||||
pv = json['pv'];
|
||||
releaseDate = json['release_date'];
|
||||
rights = json['rights'];
|
||||
@ -211,7 +216,7 @@ class EpisodeItem {
|
||||
skip = json['skip'];
|
||||
status = json['status'];
|
||||
subtitle = json['subtitle'];
|
||||
title = json['title'];
|
||||
title = json['long_title'];
|
||||
vid = json['vid'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@ class BangumiListItemModel {
|
||||
this.title,
|
||||
this.titleIcon,
|
||||
this.progress,
|
||||
this.progressIndex,
|
||||
});
|
||||
|
||||
String? badge;
|
||||
@ -66,8 +67,8 @@ class BangumiListItemModel {
|
||||
String? subTitle;
|
||||
String? title;
|
||||
String? titleIcon;
|
||||
|
||||
String? progress;
|
||||
int? progressIndex;
|
||||
|
||||
BangumiListItemModel.fromJson(Map<String, dynamic> json) {
|
||||
badge = json['badge'] == '' ? null : json['badge'];
|
||||
@ -87,7 +88,9 @@ class BangumiListItemModel {
|
||||
subTitle = json['sub_title'];
|
||||
title = json['title'];
|
||||
titleIcon = json['title_icon'];
|
||||
|
||||
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:pilipala/pages/mine/index.dart';
|
||||
import '../../pages/dynamics/index.dart';
|
||||
import '../../pages/home/index.dart';
|
||||
import '../../pages/media/index.dart';
|
||||
import '../../pages/rank/index.dart';
|
||||
|
||||
List defaultNavigationBars = [
|
||||
@ -51,15 +50,15 @@ List defaultNavigationBars = [
|
||||
{
|
||||
'id': 3,
|
||||
'icon': const Icon(
|
||||
Icons.video_collection_outlined,
|
||||
Icons.person_outline,
|
||||
size: 20,
|
||||
),
|
||||
'selectIcon': const Icon(
|
||||
Icons.video_collection,
|
||||
Icons.person,
|
||||
size: 21,
|
||||
),
|
||||
'label': "媒体库",
|
||||
'label': "我的",
|
||||
'count': 0,
|
||||
'page': const MediaPage(),
|
||||
}
|
||||
'page': const MinePage(),
|
||||
},
|
||||
];
|
||||
|
||||
@ -63,7 +63,7 @@ class LiveFollowingItemModel {
|
||||
String? roomNews;
|
||||
String? watchIcon;
|
||||
String? textSmall;
|
||||
String? roomCover;
|
||||
String? cover;
|
||||
String? pic;
|
||||
int? parentAreaId;
|
||||
int? areaId;
|
||||
@ -90,7 +90,7 @@ class LiveFollowingItemModel {
|
||||
this.roomNews,
|
||||
this.watchIcon,
|
||||
this.textSmall,
|
||||
this.roomCover,
|
||||
this.cover,
|
||||
this.pic,
|
||||
this.parentAreaId,
|
||||
this.areaId,
|
||||
@ -108,7 +108,8 @@ class LiveFollowingItemModel {
|
||||
isAttention = json['is_attention'];
|
||||
clipNum = json['clipnum'];
|
||||
fansNum = json['fans_num'];
|
||||
areaName = json['area_name'];
|
||||
areaName =
|
||||
json['area_name'] == '' ? json['area_name_v2'] : json['area_name'];
|
||||
areaValue = json['area_value'];
|
||||
tags = json['tags'];
|
||||
recentRecordIdV2 = json['recent_record_id_v2'];
|
||||
@ -118,7 +119,7 @@ class LiveFollowingItemModel {
|
||||
roomNews = json['room_news'];
|
||||
watchIcon = json['watch_icon'];
|
||||
textSmall = json['text_small'];
|
||||
roomCover = json['room_cover'];
|
||||
cover = json['room_cover'];
|
||||
pic = json['room_cover'];
|
||||
parentAreaId = json['parent_area_id'];
|
||||
areaId = json['area_id'];
|
||||
|
||||
@ -8,6 +8,7 @@ class MemberInfoModel {
|
||||
this.level,
|
||||
this.isFollowed,
|
||||
this.topPhoto,
|
||||
this.silence,
|
||||
this.official,
|
||||
this.vip,
|
||||
this.liveRoom,
|
||||
@ -21,6 +22,7 @@ class MemberInfoModel {
|
||||
int? level;
|
||||
bool? isFollowed;
|
||||
String? topPhoto;
|
||||
int? silence;
|
||||
Map? official;
|
||||
Vip? vip;
|
||||
LiveRoom? liveRoom;
|
||||
@ -34,6 +36,7 @@ class MemberInfoModel {
|
||||
level = json['level'];
|
||||
isFollowed = json['is_followed'];
|
||||
topPhoto = json['top_photo'];
|
||||
silence = json['silence'] ?? 0;
|
||||
official = json['official'];
|
||||
vip = Vip.fromJson(json['vip']);
|
||||
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;
|
||||
|
||||
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
|
||||
? []
|
||||
: json["items"].map<MessageLikeItem>((e) {
|
||||
|
||||
@ -13,8 +13,9 @@ class SessionDataModel {
|
||||
|
||||
SessionDataModel.fromJson(Map<String, dynamic> json) {
|
||||
sessionList = json['session_list']
|
||||
?.map<SessionList>((e) => SessionList.fromJson(e))
|
||||
.toList();
|
||||
?.map<SessionList>((e) => SessionList.fromJson(e))
|
||||
.toList() ??
|
||||
[];
|
||||
hasMore = json['has_more'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
class ReplyContent {
|
||||
ReplyContent({
|
||||
this.message,
|
||||
this.message2,
|
||||
this.atNameToMid, // @的用户的mid null
|
||||
this.members, // 被@的用户List 如果有的话 []
|
||||
this.emote, // 表情包 如果有的话 null
|
||||
@ -13,6 +14,7 @@ class ReplyContent {
|
||||
});
|
||||
|
||||
String? message;
|
||||
String? message2;
|
||||
Map? atNameToMid;
|
||||
List<MemberItemModel>? members;
|
||||
Map? emote;
|
||||
@ -24,10 +26,17 @@ class ReplyContent {
|
||||
Map? topicsMeta;
|
||||
|
||||
ReplyContent.fromJson(Map<String, dynamic> json) {
|
||||
message = json['message']
|
||||
message = message2 = json['message']
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll(''', "'");
|
||||
.replaceAll(''', "'")
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll(''', "'")
|
||||
.replaceAll(' ', ' ');
|
||||
|
||||
atNameToMid = json['at_name_to_mid'] ?? {};
|
||||
members = json['members'] != null
|
||||
? json['members']
|
||||
@ -39,8 +48,8 @@ class ReplyContent {
|
||||
pictures = json['pictures'] ?? [];
|
||||
vote = json['vote'] ?? {};
|
||||
richText = json['rich_text'] ?? {};
|
||||
// 不包含@ 笔记 图片的时候,文字可折叠
|
||||
isText = atNameToMid!.isEmpty && vote!.isEmpty && pictures!.isEmpty;
|
||||
// 不包含@ 笔记的时候,文字可折叠
|
||||
isText = atNameToMid!.isEmpty && vote!.isEmpty;
|
||||
topicsMeta = json['topics_meta'] ?? {};
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,21 +6,21 @@ import 'upper.dart';
|
||||
|
||||
class ReplyData {
|
||||
ReplyData({
|
||||
this.page,
|
||||
this.cursor,
|
||||
this.config,
|
||||
this.replies,
|
||||
this.topReplies,
|
||||
this.upper,
|
||||
});
|
||||
|
||||
ReplyPage? page;
|
||||
ReplyCursor? cursor;
|
||||
ReplyConfig? config;
|
||||
late List<ReplyItemModel>? replies;
|
||||
late List<ReplyItemModel>? topReplies;
|
||||
ReplyUpper? upper;
|
||||
|
||||
ReplyData.fromJson(Map<String, dynamic> json) {
|
||||
page = ReplyPage.fromJson(json['page']);
|
||||
cursor = ReplyCursor.fromJson(json['cursor']);
|
||||
config = ReplyConfig.fromJson(json['config']);
|
||||
replies = json['replies'] != null
|
||||
? json['replies']
|
||||
@ -38,3 +38,100 @@ class ReplyData {
|
||||
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.dialog,
|
||||
this.count,
|
||||
this.rcount,
|
||||
this.floor,
|
||||
this.state,
|
||||
this.fansgrade,
|
||||
@ -41,6 +42,7 @@ class ReplyItemModel {
|
||||
int? parent;
|
||||
int? dialog;
|
||||
int? count;
|
||||
int? rcount;
|
||||
int? floor;
|
||||
int? state;
|
||||
int? fansgrade;
|
||||
@ -72,6 +74,7 @@ class ReplyItemModel {
|
||||
parent = json['parent'];
|
||||
dialog = json['dialog'];
|
||||
count = json['count'];
|
||||
rcount = json['rcount'] ?? 0;
|
||||
floor = json['floor'];
|
||||
state = json['state'];
|
||||
fansgrade = json['fansgrade'];
|
||||
|
||||
@ -377,6 +377,7 @@ class Part {
|
||||
int? page;
|
||||
String? from;
|
||||
String? pagePart;
|
||||
String? title;
|
||||
int? duration;
|
||||
String? vid;
|
||||
String? weblink;
|
||||
@ -389,6 +390,7 @@ class Part {
|
||||
this.page,
|
||||
this.from,
|
||||
this.pagePart,
|
||||
this.title,
|
||||
this.duration,
|
||||
this.vid,
|
||||
this.weblink,
|
||||
@ -406,6 +408,7 @@ class Part {
|
||||
page = json["page"];
|
||||
from = json["from"];
|
||||
pagePart = json["part"];
|
||||
title = json["part"];
|
||||
duration = json["duration"];
|
||||
vid = json["vid"];
|
||||
weblink = json["weblink"];
|
||||
@ -649,6 +652,9 @@ class EpisodeItem {
|
||||
Part? page;
|
||||
String? bvid;
|
||||
String? cover;
|
||||
int? pubdate;
|
||||
int? duration;
|
||||
Stat? stat;
|
||||
|
||||
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
||||
seasonId = json['season_id'];
|
||||
@ -661,6 +667,9 @@ class EpisodeItem {
|
||||
page = Part.fromJson(json['page']);
|
||||
bvid = json['bvid'];
|
||||
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:pilipala/http/index.dart';
|
||||
import 'package:pilipala/models/github/latest.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/index.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../utils/cache_manage.dart';
|
||||
@ -124,7 +125,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
onTap: () => _aboutController.webSiteUrl(),
|
||||
title: const Text('访问官网'),
|
||||
trailing: Text(
|
||||
'https://pilipalanet.mysxl.cn',
|
||||
'https://pilipala.life',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
),
|
||||
@ -168,7 +169,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
onTap: () => _aboutController.tgChanel(),
|
||||
title: const Text('TG频道'),
|
||||
trailing: Text(
|
||||
'https://t.me/+lm_oOVmF0RJiODk1',
|
||||
'https://t.me/+1DFtqS6usUM5MDNl',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
),
|
||||
@ -321,29 +322,35 @@ class AboutController extends GetxController {
|
||||
// tg频道
|
||||
tgChanel() {
|
||||
Clipboard.setData(
|
||||
const ClipboardData(text: 'https://t.me/+lm_oOVmF0RJiODk1'),
|
||||
const ClipboardData(text: 'https://t.me/+1DFtqS6usUM5MDNl'),
|
||||
);
|
||||
SmartDialog.showToast(
|
||||
'已复制,即将在浏览器打开',
|
||||
displayTime: const Duration(milliseconds: 500),
|
||||
).then(
|
||||
(value) => launchUrl(
|
||||
Uri.parse('https://t.me/+lm_oOVmF0RJiODk1'),
|
||||
Uri.parse('https://t.me/+1DFtqS6usUM5MDNl'),
|
||||
mode: LaunchMode.externalApplication,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
aPay() {
|
||||
try {
|
||||
launchUrl(
|
||||
Uri.parse(
|
||||
'alipayqr://platformapi/startapp?saId=10000007&qrcode=https://qr.alipay.com/fkx14623ddwl1ping3ddd73'),
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
const List<String> sources = [
|
||||
'assets/images/pay/wechat.png',
|
||||
'assets/images/pay/alipay.jpg'
|
||||
];
|
||||
Navigator.of(Get.context!).push(
|
||||
HeroDialogRoute<void>(
|
||||
builder: (BuildContext context) => InteractiveviewerGallery(
|
||||
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();
|
||||
RxList<BangumiListItemModel> bangumiList = <BangumiListItemModel>[].obs;
|
||||
RxList<BangumiListItemModel> bangumiFollowList = <BangumiListItemModel>[].obs;
|
||||
RxInt total = 0.obs;
|
||||
int _currentPage = 1;
|
||||
bool isLoadingMore = true;
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
@ -54,9 +55,10 @@ class BangumiController extends GetxController {
|
||||
if (userInfo == null) {
|
||||
return;
|
||||
}
|
||||
var result = await BangumiHttp.bangumiFollow(mid: userInfo.mid);
|
||||
var result = await BangumiHttp.getRecentBangumi(mid: userInfo.mid);
|
||||
if (result['status']) {
|
||||
bangumiFollowList.value = result['data'].list;
|
||||
total.value = result['data'].total;
|
||||
} else {}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ 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/bangumi.dart';
|
||||
import 'package:pilipala/http/constants.dart';
|
||||
import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
@ -23,7 +24,7 @@ class BangumiIntroController extends GetxController {
|
||||
// 视频bvid
|
||||
String bvid = Get.parameters['bvid']!;
|
||||
var seasonId = Get.parameters['seasonId'] != null
|
||||
? int.parse(Get.parameters['seasonId']!)
|
||||
? int.tryParse(Get.parameters['seasonId']!)
|
||||
: null;
|
||||
var epId = Get.parameters['epId'] != null
|
||||
? int.tryParse(Get.parameters['epId']!)
|
||||
@ -52,28 +53,35 @@ class BangumiIntroController extends GetxController {
|
||||
Rx<FavFolderData> favFolderData = FavFolderData().obs;
|
||||
List addMediaIdsNew = [];
|
||||
List delMediaIdsNew = [];
|
||||
// 关注状态 默认未关注
|
||||
RxMap followStatus = {}.obs;
|
||||
// 追番状态 1想看 2在看 3已看
|
||||
RxBool isFollowed = false.obs;
|
||||
RxInt followStatus = 1.obs;
|
||||
int _tempThemeValue = -1;
|
||||
var userInfo;
|
||||
PersistentBottomSheetController? bottomSheetController;
|
||||
List<Map<String, dynamic>> followStatusList = [
|
||||
{'title': '标记为 「想看」', 'status': 1},
|
||||
{'title': '标记为 「在看」', 'status': 2},
|
||||
{'title': '标记为 「已看」', 'status': 3},
|
||||
{'title': '取消追番', 'status': -1},
|
||||
];
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
print('bangumi: ${Get.parameters.toString()}');
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userLogin = userInfo != null;
|
||||
if (userLogin && seasonId != null) {
|
||||
bangumiStatus();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取番剧简介&选集
|
||||
Future queryBangumiIntro() async {
|
||||
if (userLogin) {
|
||||
// 获取点赞状态
|
||||
queryHasLikeVideo();
|
||||
// 获取投币状态
|
||||
queryHasCoinVideo();
|
||||
// 获取收藏状态
|
||||
queryHasFavVideo();
|
||||
// 获取点赞投币收藏状态
|
||||
bangumiActionStatus();
|
||||
}
|
||||
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
||||
if (result['status']) {
|
||||
@ -83,26 +91,15 @@ class BangumiIntroController extends GetxController {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 获取点赞状态
|
||||
Future queryHasLikeVideo() async {
|
||||
var result = await VideoHttp.hasLikeVideo(bvid: bvid);
|
||||
// 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));
|
||||
// 获取番剧点赞投币收藏状态
|
||||
Future bangumiActionStatus() async {
|
||||
var result = await BangumiHttp.bangumiActionStatus(epId: epId!);
|
||||
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 {
|
||||
hasFav.value = false;
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +107,7 @@ class BangumiIntroController extends GetxController {
|
||||
Future actionLikeVideo() async {
|
||||
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
||||
if (result['status']) {
|
||||
SmartDialog.showToast(!hasLike.value ? '点赞成功 👍' : '取消赞');
|
||||
SmartDialog.showToast(!hasLike.value ? '点赞成功' : '取消赞');
|
||||
hasLike.value = !hasLike.value;
|
||||
bangumiDetail.value.stat!['likes'] =
|
||||
bangumiDetail.value.stat!['likes'] + (!hasLike.value ? 1 : -1);
|
||||
@ -147,7 +144,7 @@ class BangumiIntroController extends GetxController {
|
||||
var res = await VideoHttp.coinVideo(
|
||||
bvid: bvid, multiply: _tempThemeValue);
|
||||
if (res['status']) {
|
||||
SmartDialog.showToast('投币成功 👏');
|
||||
SmartDialog.showToast('投币成功');
|
||||
hasCoin.value = true;
|
||||
bangumiDetail.value.stat!['coins'] =
|
||||
bangumiDetail.value.stat!['coins'] +
|
||||
@ -185,9 +182,11 @@ class BangumiIntroController extends GetxController {
|
||||
addMediaIdsNew = [];
|
||||
delMediaIdsNew = [];
|
||||
// 重新获取收藏状态
|
||||
queryHasFavVideo();
|
||||
SmartDialog.showToast('✅ 操作成功');
|
||||
bangumiActionStatus();
|
||||
SmartDialog.showToast('操作成功');
|
||||
Get.back();
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,15 +238,22 @@ class BangumiIntroController extends GetxController {
|
||||
|
||||
// 追番
|
||||
Future bangumiAdd() async {
|
||||
var result =
|
||||
await VideoHttp.bangumiAdd(seasonId: bangumiDetail.value.seasonId);
|
||||
var result = await VideoHttp.bangumiAdd(
|
||||
seasonId: seasonId ?? bangumiDetail.value.seasonId);
|
||||
if (result['status']) {
|
||||
followStatus.value = 2;
|
||||
isFollowed.value = true;
|
||||
}
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
|
||||
// 取消追番
|
||||
Future bangumiDel() async {
|
||||
var result =
|
||||
await VideoHttp.bangumiDel(seasonId: bangumiDetail.value.seasonId);
|
||||
var result = await VideoHttp.bangumiDel(
|
||||
seasonId: seasonId ?? bangumiDetail.value.seasonId);
|
||||
if (result['status']) {
|
||||
isFollowed.value = false;
|
||||
}
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
|
||||
@ -302,18 +308,48 @@ class BangumiIntroController extends GetxController {
|
||||
episodes: episodes,
|
||||
currentCid: videoDetailCtr.cid.value,
|
||||
dataType: dataType,
|
||||
context: Get.context!,
|
||||
sheetHeight: Get.size.height,
|
||||
isFullScreen: true,
|
||||
changeFucCall: (item, index) {
|
||||
changeSeasonOrbangu(item.bvid, item.cid, item.aid, item.cover);
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
).buildShowContent(Get.context!),
|
||||
).buildShowContent(),
|
||||
);
|
||||
}
|
||||
|
||||
hiddenEpisodeBottomSheet() {
|
||||
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/introduction/widgets/action_item.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/storage.dart';
|
||||
import '../../../common/widgets/http_error.dart';
|
||||
@ -146,17 +147,34 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
||||
}
|
||||
|
||||
// 收藏
|
||||
showFavBottomSheet() {
|
||||
showFavBottomSheet() async {
|
||||
if (bangumiIntroController.userInfo.mid == null) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
final mediaQueryData = MediaQuery.of(context);
|
||||
final contentHeight = mediaQueryData.size.height - kToolbarHeight;
|
||||
final double initialChildSize =
|
||||
(contentHeight - Get.width * 9 / 16) / contentHeight;
|
||||
await showModalBottomSheet(
|
||||
context: Get.context!,
|
||||
useSafeArea: true,
|
||||
isScrollControlled: true,
|
||||
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: [
|
||||
Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 115,
|
||||
height: 115 / 0.75,
|
||||
src: widget.bangumiDetail!.cover!,
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
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(
|
||||
text:
|
||||
@ -207,104 +239,65 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () => showIntroDetail(),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: SizedBox(
|
||||
height: 115 / 0.75,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.bangumiDetail!.title!,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
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,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 4, 6, 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.bangumiDetail!.title!,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
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: 20),
|
||||
Obx(
|
||||
() => BangumiStatusWidget(
|
||||
ctr: bangumiIntroController,
|
||||
isFollowed:
|
||||
bangumiIntroController.isFollowed.value,
|
||||
),
|
||||
),
|
||||
),
|
||||
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 Spacer(),
|
||||
Text(
|
||||
'简介:${widget.bangumiDetail!.evaluate!}',
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: t.colorScheme.outline,
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
view: widget.bangumiDetail!.stat!['views'],
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
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(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'最近追番',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
Obx(
|
||||
() => 0 != _bangumidController.total.value
|
||||
? Text(
|
||||
'我的追番(${_bangumidController.total.value})',
|
||||
style:
|
||||
Theme.of(context).textTheme.titleMedium,
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
@ -183,8 +188,10 @@ class _BangumiPageState extends State<BangumiPage>
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () {
|
||||
_futureBuilderFuture =
|
||||
_bangumidController.queryBangumiListFeed();
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_bangumidController.queryBangumiListFeed();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/bangumi/info.dart';
|
||||
import 'package:pilipala/pages/video/detail/index.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
import '../../../common/pages_bottom_sheet.dart';
|
||||
import '../../../models/common/video_episode_type.dart';
|
||||
import '../introduction/controller.dart';
|
||||
@ -44,7 +43,6 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
late int cid;
|
||||
String heroTag = Get.arguments['heroTag'];
|
||||
late final VideoDetailController videoDetailCtr;
|
||||
final ItemScrollController itemScrollController = ItemScrollController();
|
||||
late PersistentBottomSheetController? _bottomSheetController;
|
||||
|
||||
@override
|
||||
@ -151,7 +149,6 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
changeFucCall: changeFucCall,
|
||||
sheetHeight: widget.sheetHeight,
|
||||
dataType: VideoEpidoesType.bangumiEpisode,
|
||||
context: context,
|
||||
).show(context);
|
||||
},
|
||||
child: Text(
|
||||
@ -176,59 +173,60 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
return Container(
|
||||
width: 150,
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
child: Material(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
onTap: () => changeFucCall(page, i),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 10,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
if (isSelected) ...<Widget>[
|
||||
Image.asset('assets/images/live.png',
|
||||
color: primary, height: 12),
|
||||
const SizedBox(width: 6)
|
||||
],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: () => changeFucCall(page, i),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 10,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
if (isSelected) ...<Widget>[
|
||||
Image.asset('assets/images/live.png',
|
||||
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(
|
||||
'第${i + 1}话',
|
||||
page.badge!,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: isSelected ? primary : onSurface,
|
||||
fontSize: 12,
|
||||
color: primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
if (page.badge != null) ...[
|
||||
const Spacer(),
|
||||
Text(
|
||||
page.badge!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: primary,
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
page.longTitle!,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: isSelected ? primary : onSurface,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
page.longTitle!,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: isSelected ? primary : onSurface,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)
|
||||
],
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -25,6 +25,7 @@ class BangumiCardV extends StatelessWidget {
|
||||
RoutePush.bangumiPush(
|
||||
bangumiItem.seasonId,
|
||||
null,
|
||||
progressIndex: bangumiItem.progressIndex,
|
||||
heroTag: heroTag,
|
||||
);
|
||||
},
|
||||
|
||||
@ -77,17 +77,19 @@ class _BlackListPageState extends State<BlackListPage> {
|
||||
List<BlackListItem> list = _blackListController.blackList;
|
||||
return Obx(
|
||||
() => list.isEmpty
|
||||
? CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(errMsg: '你没有拉黑任何人哦~_~', fn: () => {})
|
||||
],
|
||||
? HttpError(
|
||||
errMsg: '你没有拉黑任何人哦~_~',
|
||||
fn: () => {},
|
||||
isInSliver: false,
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount: list.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ListTile(
|
||||
onTap: () {},
|
||||
onTap: () => Get.toNamed(
|
||||
'/member?mid=${list[index].mid}',
|
||||
arguments: {'face': list[index].face}),
|
||||
leading: NetworkImgLayer(
|
||||
width: 45,
|
||||
height: 45,
|
||||
@ -119,13 +121,10 @@ class _BlackListPageState extends State<BlackListPage> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => _blackListController.queryBlacklist(),
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => _blackListController.queryBlacklist(),
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -14,7 +14,7 @@ class DynamicDetailController extends GetxController {
|
||||
int? type;
|
||||
dynamic item;
|
||||
int? floor;
|
||||
int currentPage = 0;
|
||||
String nextOffset = "";
|
||||
bool isLoadingMore = false;
|
||||
RxString noMore = ''.obs;
|
||||
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
||||
@ -26,6 +26,7 @@ class DynamicDetailController extends GetxController {
|
||||
RxString sortTypeLabel = ReplySortType.time.labels.obs;
|
||||
Box setting = GStrorage.setting;
|
||||
RxInt replyReqCode = 200.obs;
|
||||
bool isEnd = false;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -48,26 +49,30 @@ class DynamicDetailController extends GetxController {
|
||||
}
|
||||
|
||||
Future queryReplyList({reqType = 'init'}) async {
|
||||
if (isLoadingMore || noMore.value == '没有更多了' || isEnd) {
|
||||
return;
|
||||
}
|
||||
isLoadingMore = true;
|
||||
if (reqType == 'init') {
|
||||
currentPage = 0;
|
||||
nextOffset = '';
|
||||
noMore.value = '';
|
||||
}
|
||||
var res = await ReplyHttp.replyList(
|
||||
oid: oid!,
|
||||
pageNum: currentPage + 1,
|
||||
nextOffset: nextOffset,
|
||||
type: type!,
|
||||
sort: _sortType.index,
|
||||
);
|
||||
if (res['status']) {
|
||||
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) {
|
||||
currentPage++;
|
||||
noMore.value = '加载中...';
|
||||
if (replies.length < 20) {
|
||||
noMore.value = '没有更多了';
|
||||
}
|
||||
noMore.value = isEnd ? '没有更多了' : '加载中...';
|
||||
} else {
|
||||
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
|
||||
noMore.value =
|
||||
replyList.isEmpty && nextOffset == "" ? '还没有评论' : '没有更多了';
|
||||
}
|
||||
if (reqType == 'init') {
|
||||
// 添加置顶回复
|
||||
@ -113,4 +118,9 @@ class DynamicDetailController extends GetxController {
|
||||
var res = await HtmlHttp.reqHtml(id, 'opus');
|
||||
oid = res['commentId'];
|
||||
}
|
||||
|
||||
// 上拉加载
|
||||
Future onLoad() async {
|
||||
queryReplyList(reqType: 'onLoad');
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
with TickerProviderStateMixin {
|
||||
late DynamicDetailController _dynamicDetailController;
|
||||
late AnimationController fabAnimationCtr;
|
||||
Future? _futureBuilderFuture;
|
||||
late Future _futureBuilderFuture;
|
||||
late StreamController<bool> titleStreamC =
|
||||
StreamController<bool>.broadcast(); // appBar title
|
||||
late ScrollController scrollController;
|
||||
@ -140,7 +140,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 300) {
|
||||
EasyThrottle.throttle('replylist', const Duration(seconds: 2), () {
|
||||
_dynamicDetailController.queryReplyList(reqType: 'onLoad');
|
||||
_dynamicDetailController.onLoad();
|
||||
});
|
||||
}
|
||||
|
||||
@ -278,8 +278,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map data = snapshot.data as Map;
|
||||
if (snapshot.data['status']) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && snapshot.data['status']) {
|
||||
RxList<ReplyItemModel> replyList =
|
||||
_dynamicDetailController.replyList;
|
||||
// 请求成功
|
||||
@ -345,8 +345,11 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
fn: () => setState(() {
|
||||
_futureBuilderFuture =
|
||||
_dynamicDetailController.queryReplyList();
|
||||
}),
|
||||
);
|
||||
}
|
||||
} 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/no_data.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/main_stream.dart';
|
||||
import 'package:pilipala/utils/route_push.dart';
|
||||
@ -18,7 +17,6 @@ import 'package:pilipala/utils/storage.dart';
|
||||
import '../mine/controller.dart';
|
||||
import 'controller.dart';
|
||||
import 'widgets/dynamic_panel.dart';
|
||||
import 'up_dynamic/route_panel.dart';
|
||||
import 'widgets/up_panel.dart';
|
||||
|
||||
class DynamicsPage extends StatefulWidget {
|
||||
@ -90,32 +88,34 @@ class _DynamicsPageState extends State<DynamicsPage>
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Obx(() {
|
||||
if (_dynamicsController.mid.value != -1 &&
|
||||
_dynamicsController.upInfo.value.uname != null) {
|
||||
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(
|
||||
'${_dynamicsController.upInfo.value.uname!}的动态',
|
||||
key: ValueKey<String>(
|
||||
_dynamicsController.upInfo.value.uname!),
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge!
|
||||
.fontSize,
|
||||
)),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final mid = _dynamicsController.mid.value;
|
||||
final uname = _dynamicsController.upInfo.value.uname;
|
||||
|
||||
if (mid == -1 || uname == null) {
|
||||
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(
|
||||
() => _dynamicsController.userLogin.value
|
||||
@ -206,16 +206,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
||||
return Obx(
|
||||
() => UpPanel(
|
||||
upData: _dynamicsController.upData.value,
|
||||
onClickUpCb: (data) {
|
||||
// _dynamicsController.onTapUp(data);
|
||||
Navigator.push(
|
||||
context,
|
||||
PlPopupRoute(
|
||||
child: OverlayPanel(
|
||||
ctr: _dynamicsController, upInfo: data),
|
||||
),
|
||||
);
|
||||
},
|
||||
dynamicsController: _dynamicsController,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
||||
@ -3,20 +3,19 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.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 'package:pilipala/pages/dynamics/index.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:status_bar_control/status_bar_control.dart';
|
||||
import 'rich_node_panel.dart';
|
||||
import '../forward/index.dart';
|
||||
|
||||
class ActionPanel extends StatefulWidget {
|
||||
const ActionPanel({
|
||||
super.key,
|
||||
required this.item,
|
||||
});
|
||||
// ignore: prefer_typing_uninitialized_variables
|
||||
|
||||
final DynamicItemModel item;
|
||||
|
||||
@override
|
||||
@ -32,9 +31,6 @@ class _ActionPanelState extends State<ActionPanel>
|
||||
RxDouble height = 0.0.obs;
|
||||
RxBool isExpand = false.obs;
|
||||
late double statusHeight;
|
||||
TextEditingController _inputController = TextEditingController();
|
||||
FocusNode myFocusNode = FocusNode();
|
||||
String _inputText = '';
|
||||
|
||||
void Function()? handleState(Future Function() action) {
|
||||
return isProcessing
|
||||
@ -60,7 +56,7 @@ class _ActionPanelState extends State<ActionPanel>
|
||||
// 动态点赞
|
||||
Future onLikeDynamic() async {
|
||||
feedBack();
|
||||
var item = widget.item!;
|
||||
var item = widget.item;
|
||||
String dynamicId = item.idStr!;
|
||||
// 1 已点赞 2 不喜欢 0 未操作
|
||||
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 {
|
||||
final userInfo = _dynamicsController.userInfo;
|
||||
if (userInfo == null) {
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
}
|
||||
int mid = userInfo.mid;
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
enableDrag: false,
|
||||
enableDrag: true,
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (context) {
|
||||
return Obx(
|
||||
() => AnimatedContainer(
|
||||
duration: Durations.medium1,
|
||||
onEnd: () async {
|
||||
if (isExpand.value) {
|
||||
await Future.delayed(const Duration(milliseconds: 80));
|
||||
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,
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
return DynamicForwardPage(
|
||||
item: widget.item,
|
||||
mid: mid,
|
||||
cb: () => setState(() {
|
||||
stat.forward!.count =
|
||||
(int.parse(stat.forward!.count ?? '0') + 1).toString();
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
var color = Theme.of(context).colorScheme.outline;
|
||||
var primary = Theme.of(context).colorScheme.primary;
|
||||
height.value = defaultHeight;
|
||||
print('height.value: ${height.value}');
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
|
||||
@ -66,76 +66,85 @@ Widget liveRcmdPanel(item, context, {floor = 1}) {
|
||||
},
|
||||
child: LayoutBuilder(builder: (context, box) {
|
||||
double width = box.maxWidth;
|
||||
return Stack(
|
||||
children: [
|
||||
Hero(
|
||||
tag: liveRcmd.roomId.toString(),
|
||||
child: NetworkImgLayer(
|
||||
type: floor == 1 ? 'emote' : null,
|
||||
width: width,
|
||||
height: width / StyleString.aspectRatio,
|
||||
src: item.modules.moduleDynamic.major.liveRcmd.cover,
|
||||
),
|
||||
),
|
||||
PBadge(
|
||||
text: watchedShow['text_large'],
|
||||
top: 6,
|
||||
right: 56,
|
||||
bottom: null,
|
||||
left: null,
|
||||
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 ??
|
||||
''),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
return Container(
|
||||
margin: floor == 1
|
||||
? const EdgeInsets.only(
|
||||
left: StyleString.safeSpace, right: StyleString.safeSpace)
|
||||
: EdgeInsets.zero,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(StyleString.imgRadius)),
|
||||
child: Stack(
|
||||
children: [
|
||||
Hero(
|
||||
tag: liveRcmd.roomId.toString(),
|
||||
child: NetworkImgLayer(
|
||||
type: floor == 1 ? 'emote' : null,
|
||||
width: width,
|
||||
height: width / StyleString.aspectRatio,
|
||||
src: item.modules.moduleDynamic.major.liveRcmd.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
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/models/dynamics/up.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/global_data_cache.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
import '../controller.dart';
|
||||
import '../up_dynamic/route_panel.dart';
|
||||
|
||||
class UpPanel extends StatefulWidget {
|
||||
final FollowUpModel upData;
|
||||
final Function? onClickUpCb;
|
||||
final DynamicsController dynamicsController;
|
||||
|
||||
const UpPanel({
|
||||
super.key,
|
||||
required this.upData,
|
||||
this.onClickUpCb,
|
||||
required this.dynamicsController,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -23,7 +28,7 @@ class UpPanel extends StatefulWidget {
|
||||
|
||||
class _UpPanelState extends State<UpPanel> {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
int currentMid = -1;
|
||||
RxInt currentMid = (-1).obs;
|
||||
late double contentWidth = 56;
|
||||
List<UpItem> upList = [];
|
||||
List<LiveUserItem> liveList = [];
|
||||
@ -37,26 +42,44 @@ class _UpPanelState extends State<UpPanel> {
|
||||
}
|
||||
|
||||
void onClickUp(data, i) {
|
||||
currentMid = data.mid;
|
||||
widget.onClickUpCb?.call(data);
|
||||
// int liveLen = liveList.length;
|
||||
// int upLen = upList.length;
|
||||
// double itemWidth = contentWidth + itemPadding.horizontal;
|
||||
// double screenWidth = MediaQuery.sizeOf(context).width;
|
||||
// double moveDistance = 0.0;
|
||||
// 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;
|
||||
// } else {
|
||||
// moveDistance = (upLen + liveLen) * itemWidth + 46 - screenWidth;
|
||||
// }
|
||||
// data.hasUpdate = false;
|
||||
// scrollController.animateTo(
|
||||
// moveDistance,
|
||||
// duration: const Duration(milliseconds: 200),
|
||||
// curve: Curves.linear,
|
||||
// );
|
||||
// setState(() {});
|
||||
currentMid.value = data.mid;
|
||||
Navigator.push(
|
||||
context,
|
||||
PlPopupRoute(
|
||||
child: OverlayPanel(
|
||||
ctr: widget.dynamicsController,
|
||||
upInfo: data,
|
||||
),
|
||||
),
|
||||
).then((value) => {currentMid.value = -1});
|
||||
}
|
||||
|
||||
void onClickUpAni(data, i) {
|
||||
final screenWidth = MediaQuery.sizeOf(context).width;
|
||||
final itemWidth = contentWidth + itemPadding.horizontal;
|
||||
final liveLen = liveList.length;
|
||||
final upLen = upList.length;
|
||||
|
||||
currentMid.value = data.mid;
|
||||
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
|
||||
@ -144,14 +167,17 @@ class _UpPanelState extends State<UpPanel> {
|
||||
}
|
||||
|
||||
Widget upItemBuild(data, i) {
|
||||
bool isCurrent = currentMid == data.mid || currentMid == -1;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
feedBack();
|
||||
if (data.type == 'up') {
|
||||
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') {
|
||||
LiveItemModel liveItem = LiveItemModel.fromJson({
|
||||
@ -177,60 +203,66 @@ class _UpPanelState extends State<UpPanel> {
|
||||
},
|
||||
child: Padding(
|
||||
padding: itemPadding,
|
||||
child: AnimatedOpacity(
|
||||
opacity: isCurrent ? 1 : 0.3,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Badge(
|
||||
smallSize: 8,
|
||||
label: data.type == 'live' ? const Text('Live') : null,
|
||||
textColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
alignment: data.type == 'live'
|
||||
? AlignmentDirectional.topCenter
|
||||
: AlignmentDirectional.topEnd,
|
||||
padding: const EdgeInsets.only(left: 6, right: 6),
|
||||
isLabelVisible: data.type == 'live' ||
|
||||
(data.type == 'up' && (data.hasUpdate ?? false)),
|
||||
backgroundColor: data.type == 'live'
|
||||
? Theme.of(context).colorScheme.secondaryContainer
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
child: data.face != ''
|
||||
? NetworkImgLayer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
src: data.face,
|
||||
type: 'avatar',
|
||||
)
|
||||
: const CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundImage: AssetImage(
|
||||
'assets/images/noface.jpeg',
|
||||
child: Obx(
|
||||
() => AnimatedOpacity(
|
||||
opacity: currentMid.value == data.mid || currentMid.value == -1
|
||||
? 1
|
||||
: 0.3,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Badge(
|
||||
smallSize: 8,
|
||||
label: data.type == 'live' ? const Text('Live') : null,
|
||||
textColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
alignment: data.type == 'live'
|
||||
? AlignmentDirectional.topCenter
|
||||
: AlignmentDirectional.topEnd,
|
||||
padding: const EdgeInsets.only(left: 6, right: 6),
|
||||
isLabelVisible: data.type == 'live' ||
|
||||
(data.type == 'up' && (data.hasUpdate ?? false)),
|
||||
backgroundColor: data.type == 'live'
|
||||
? Theme.of(context).colorScheme.secondaryContainer
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
child: data.face != ''
|
||||
? NetworkImgLayer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
src: data.face,
|
||||
type: 'avatar',
|
||||
)
|
||||
: const CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundImage: AssetImage(
|
||||
'assets/images/noface.jpeg',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: SizedBox(
|
||||
width: contentWidth,
|
||||
child: Text(
|
||||
data.uname,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: false,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: currentMid == data.mid
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelMedium!.fontSize),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: SizedBox(
|
||||
width: contentWidth,
|
||||
child: Text(
|
||||
data.uname,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: false,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: currentMid.value == data.mid
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -78,72 +78,83 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) {
|
||||
],
|
||||
LayoutBuilder(builder: (context, box) {
|
||||
double width = box.maxWidth;
|
||||
return Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
type: floor == 1 ? 'emote' : null,
|
||||
width: width,
|
||||
height: width / StyleString.aspectRatio,
|
||||
src: content.cover,
|
||||
),
|
||||
if (content.badge != null && content.badge['text'] != null)
|
||||
PBadge(
|
||||
text: content.badge['text'],
|
||||
top: 8.0,
|
||||
right: 10.0,
|
||||
bottom: null,
|
||||
left: null,
|
||||
return Container(
|
||||
margin: floor == 1
|
||||
? const EdgeInsets.only(
|
||||
left: StyleString.safeSpace, right: StyleString.safeSpace)
|
||||
: EdgeInsets.zero,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(StyleString.imgRadius)),
|
||||
child: Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
type: floor == 1 ? 'emote' : null,
|
||||
width: width,
|
||||
height: width / StyleString.aspectRatio,
|
||||
src: content.cover,
|
||||
),
|
||||
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.black54,
|
||||
],
|
||||
),
|
||||
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(content.durationText ?? ''),
|
||||
if (content.durationText != null)
|
||||
const SizedBox(width: 10),
|
||||
Text(content.stat.play + '次围观'),
|
||||
const SizedBox(width: 10),
|
||||
Text(content.stat.danmaku + '条弹幕')
|
||||
if (content.badge != null && content.badge['text'] != null)
|
||||
PBadge(
|
||||
text: content.badge['text'],
|
||||
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.black54,
|
||||
],
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'assets/images/play.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
),
|
||||
],
|
||||
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(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),
|
||||
|
||||
@ -103,17 +103,14 @@ class _FansPageState extends State<FansPage> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () {
|
||||
_futureBuilderFuture =
|
||||
_fansController.queryFans('init');
|
||||
},
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture = _fansController.queryFans('init');
|
||||
});
|
||||
},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -112,23 +112,19 @@ class _FavPageState extends State<FavPage> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
btnText: data?['code'] == -101 ? '去登录' : null,
|
||||
fn: () {
|
||||
if (data?['code'] == -101) {
|
||||
RoutePush.loginRedirectPush();
|
||||
} else {
|
||||
setState(() {
|
||||
_futureBuilderFuture = _favController.queryFavFolder();
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
btnText: data?['code'] == -101 ? '去登录' : null,
|
||||
fn: () {
|
||||
if (data?['code'] == -101) {
|
||||
RoutePush.loginRedirectPush();
|
||||
} else {
|
||||
setState(() {
|
||||
_futureBuilderFuture = _favController.queryFavFolder();
|
||||
});
|
||||
}
|
||||
},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/utils/logic_utils.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
class FavItem extends StatelessWidget {
|
||||
@ -96,7 +97,7 @@ class VideoContent extends StatelessWidget {
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
[23, 1].contains(favFolderItem.attr) ? '私密' : '公开',
|
||||
LogicUtils.isPublic(favFolderItem.attr) ? '公开' : '私密',
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||
|
||||
@ -21,6 +21,7 @@ class FavDetailController extends GetxController {
|
||||
RxString loadingText = '加载中...'.obs;
|
||||
RxInt mediaCount = 0.obs;
|
||||
late String isOwner;
|
||||
late bool hasMore = true;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -35,7 +36,7 @@ class FavDetailController extends GetxController {
|
||||
}
|
||||
|
||||
Future<dynamic> queryUserFavFolderDetail({type = 'init'}) async {
|
||||
if (type == 'onLoad' && favList.length >= mediaCount.value) {
|
||||
if (type == 'onLoad' && !hasMore) {
|
||||
loadingText.value = '没有更多了';
|
||||
return;
|
||||
}
|
||||
@ -47,17 +48,18 @@ class FavDetailController extends GetxController {
|
||||
);
|
||||
if (res['status']) {
|
||||
favInfo.value = res['data'].info;
|
||||
hasMore = res['data'].hasMore;
|
||||
if (currentPage == 1 && type == 'init') {
|
||||
favList.value = res['data'].medias;
|
||||
mediaCount.value = res['data'].info['media_count'];
|
||||
} else if (type == 'onLoad') {
|
||||
favList.addAll(res['data'].medias);
|
||||
}
|
||||
if (favList.length >= mediaCount.value) {
|
||||
if (!hasMore) {
|
||||
loadingText.value = '没有更多了';
|
||||
}
|
||||
currentPage += 1;
|
||||
}
|
||||
currentPage += 1;
|
||||
isLoadingMore = false;
|
||||
return res;
|
||||
}
|
||||
@ -126,7 +128,7 @@ class FavDetailController extends GetxController {
|
||||
'title': item!.title,
|
||||
'intro': item!.intro,
|
||||
'cover': item!.cover,
|
||||
'privacy': [23, 1].contains(item!.attr) ? 1 : 0,
|
||||
'privacy': [22, 0].contains(item!.attr) ? 0 : 1,
|
||||
},
|
||||
);
|
||||
title.value = res['title'];
|
||||
|
||||
@ -193,7 +193,9 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
padding: const EdgeInsets.only(top: 15, bottom: 8, left: 14),
|
||||
child: Obx(
|
||||
() => Text(
|
||||
'共${_favDetailController.mediaCount}条视频',
|
||||
_favDetailController.mediaCount > 0
|
||||
? '共${_favDetailController.mediaCount}条视频'
|
||||
: '',
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||
@ -215,7 +217,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
List favList = _favDetailController.favList;
|
||||
return Obx(
|
||||
() => favList.isEmpty
|
||||
? const SliverToBoxAdapter(child: SizedBox())
|
||||
? const NoData()
|
||||
: SliverList(
|
||||
delegate:
|
||||
SliverChildBuilderDelegate((context, index) {
|
||||
@ -247,18 +249,20 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).padding.bottom + 60,
|
||||
height: MediaQuery.of(context).padding.bottom + 90,
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom),
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_favDetailController.loadingText.value,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: 13),
|
||||
),
|
||||
),
|
||||
child: Obx(() {
|
||||
final mediaCount = _favDetailController.mediaCount;
|
||||
final loadingText = _favDetailController.loadingText.value;
|
||||
final textColor = Theme.of(context).colorScheme.outline;
|
||||
|
||||
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:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
@ -48,24 +47,27 @@ class FollowItem extends StatelessWidget {
|
||||
height: 34,
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
await showFlexibleBottomSheet(
|
||||
bottomSheetBorderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16),
|
||||
),
|
||||
minHeight: 1,
|
||||
initHeight: 1,
|
||||
maxHeight: 1,
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context,
|
||||
ScrollController scrollController, double offset) {
|
||||
return GroupPanel(
|
||||
mid: item.mid!,
|
||||
scrollController: scrollController,
|
||||
await showModalBottomSheet(
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
isScrollControlled: true,
|
||||
builder: (BuildContext context) {
|
||||
return DraggableScrollableSheet(
|
||||
initialChildSize: 0.6,
|
||||
minChildSize: 0,
|
||||
maxChildSize: 1,
|
||||
snap: true,
|
||||
expand: false,
|
||||
snapSizes: const [0.6],
|
||||
builder: (BuildContext context,
|
||||
ScrollController scrollController) {
|
||||
return GroupPanel(
|
||||
mid: item.mid!,
|
||||
scrollController: scrollController,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
anchors: [1],
|
||||
isSafeArea: true,
|
||||
);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
|
||||
@ -94,13 +94,14 @@ class _FollowListState extends State<FollowList> {
|
||||
: const CustomScrollView(slivers: [NoData()]),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => widget.ctr.queryFollowings('init'),
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture = widget.ctr.queryFollowings('init');
|
||||
});
|
||||
},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -112,13 +112,10 @@ class _OwnerFollowListState extends State<OwnerFollowList>
|
||||
: const CustomScrollView(slivers: [NoData()]),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => widget.ctr.queryFollowings('init'),
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => widget.ctr.queryFollowings('init'),
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -82,10 +82,10 @@ class _FollowSearchPageState extends State<FollowSearchPage> {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
var data = snapshot.data;
|
||||
if (data == null) {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(errMsg: snapshot.data['msg'], fn: reRequest)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
fn: reRequest,
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
if (data['status']) {
|
||||
@ -101,15 +101,17 @@ class _FollowSearchPageState extends State<FollowSearchPage> {
|
||||
);
|
||||
}),
|
||||
)
|
||||
: CustomScrollView(
|
||||
slivers: [HttpError(errMsg: '未搜索到结果', fn: reRequest)],
|
||||
: HttpError(
|
||||
errMsg: '未搜索到结果',
|
||||
fn: reRequest,
|
||||
isInSliver: false,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(errMsg: snapshot.data['msg'], fn: reRequest)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
fn: reRequest,
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -5,7 +5,7 @@ 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/pages/mine/index.dart';
|
||||
import 'package:pilipala/pages/main/index.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import './controller.dart';
|
||||
|
||||
@ -19,6 +19,8 @@ class HomePage extends StatefulWidget {
|
||||
class _HomePageState extends State<HomePage>
|
||||
with AutomaticKeepAliveClientMixin, TickerProviderStateMixin {
|
||||
final HomeController _homeController = Get.put(HomeController());
|
||||
final MainController mainController = Get.put(MainController());
|
||||
|
||||
List videoList = [];
|
||||
late Stream<bool> stream;
|
||||
|
||||
@ -33,15 +35,14 @@ class _HomePageState extends State<HomePage>
|
||||
|
||||
showUserBottomSheet() {
|
||||
feedBack();
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (_) => const SizedBox(
|
||||
height: 450,
|
||||
child: MinePage(),
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
isScrollControlled: true,
|
||||
);
|
||||
final MainController mainController = Get.put(MainController());
|
||||
int mineItemIndex = mainController.navigationBars
|
||||
.indexWhere((item) => item['label'] == "我的");
|
||||
if (mineItemIndex != -1) {
|
||||
mainController.pageController.jumpToPage(mineItemIndex);
|
||||
} else {
|
||||
Get.toNamed('/mine');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -394,14 +395,17 @@ class SearchBar extends StatelessWidget {
|
||||
color: colorScheme.onSecondaryContainer,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Obx(
|
||||
() => Text(
|
||||
ctr!.defaultSearch.value,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: colorScheme.outline),
|
||||
Expanded(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
ctr!.defaultSearch.value,
|
||||
maxLines: 1,
|
||||
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:hive/hive.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/pages/mine/view.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
@ -54,19 +53,9 @@ class HomeAppBar extends StatelessWidget {
|
||||
// icon: const Icon(CupertinoIcons.bell, size: 22),
|
||||
// ),
|
||||
const SizedBox(width: 6),
|
||||
|
||||
/// TODO
|
||||
if (userInfo != null) ...[
|
||||
GestureDetector(
|
||||
onTap: () => showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (_) => const SizedBox(
|
||||
height: 450,
|
||||
child: MinePage(),
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
isScrollControlled: true,
|
||||
),
|
||||
onTap: () => Get.toNamed('/mine'),
|
||||
child: NetworkImgLayer(
|
||||
type: 'avatar',
|
||||
width: 32,
|
||||
@ -77,15 +66,7 @@ class HomeAppBar extends StatelessWidget {
|
||||
const SizedBox(width: 10),
|
||||
] else ...[
|
||||
IconButton(
|
||||
onPressed: () => showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (_) => const SizedBox(
|
||||
height: 450,
|
||||
child: MinePage(),
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
isScrollControlled: true,
|
||||
),
|
||||
onPressed: () => Get.toNamed('/mine'),
|
||||
icon: const Icon(CupertinoIcons.person, size: 22),
|
||||
),
|
||||
],
|
||||
|
||||
@ -15,7 +15,7 @@ class HtmlRenderController extends GetxController {
|
||||
RxInt oid = (-1).obs;
|
||||
late Map response;
|
||||
int? floor;
|
||||
int currentPage = 0;
|
||||
String nextOffset = "";
|
||||
bool isLoadingMore = false;
|
||||
RxString noMore = ''.obs;
|
||||
RxList<ReplyItemModel> replyList = <ReplyItemModel>[].obs;
|
||||
@ -52,21 +52,21 @@ class HtmlRenderController extends GetxController {
|
||||
Future queryReplyList({reqType = 'init'}) async {
|
||||
var res = await ReplyHttp.replyList(
|
||||
oid: oid.value,
|
||||
pageNum: currentPage + 1,
|
||||
nextOffset: nextOffset,
|
||||
type: type,
|
||||
sort: _sortType.index,
|
||||
);
|
||||
if (res['status']) {
|
||||
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) {
|
||||
currentPage++;
|
||||
noMore.value = '加载中...';
|
||||
if (replies.length < 20) {
|
||||
if (res['data'].cursor.isEnd == true) {
|
||||
noMore.value = '没有更多了';
|
||||
}
|
||||
} else {
|
||||
noMore.value = currentPage == 0 ? '还没有评论' : '没有更多了';
|
||||
noMore.value = nextOffset == "" ? '还没有评论' : '没有更多了';
|
||||
}
|
||||
if (reqType == 'init') {
|
||||
// 添加置顶回复
|
||||
@ -102,7 +102,7 @@ class HtmlRenderController extends GetxController {
|
||||
}
|
||||
sortTypeTitle.value = _sortType.titles;
|
||||
sortTypeLabel.value = _sortType.labels;
|
||||
currentPage = 0;
|
||||
nextOffset = "";
|
||||
replyList.clear();
|
||||
queryReplyList(reqType: 'init');
|
||||
}
|
||||
|
||||
@ -380,13 +380,10 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -22,11 +22,11 @@ class LaterController extends GetxController {
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
}
|
||||
|
||||
Future queryLaterList() async {
|
||||
Future queryLaterList({type = 'init'}) async {
|
||||
if (userInfo == null) {
|
||||
return {'status': false, 'msg': '账号未登录', 'code': -101};
|
||||
}
|
||||
isLoading.value = true;
|
||||
isLoading.value = type == 'init';
|
||||
var res = await UserHttp.seeYouLater();
|
||||
if (res['status']) {
|
||||
count = res['data']['count'];
|
||||
|
||||
@ -66,67 +66,74 @@ class _LaterPageState extends State<LaterPage> {
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
body: CustomScrollView(
|
||||
controller: _laterController.scrollController,
|
||||
slivers: [
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
return Obx(
|
||||
() => _laterController.laterList.isNotEmpty &&
|
||||
!_laterController.isLoading.value
|
||||
? SliverList(
|
||||
delegate:
|
||||
SliverChildBuilderDelegate((context, index) {
|
||||
var videoItem = _laterController.laterList[index];
|
||||
return VideoCardH(
|
||||
videoItem: videoItem,
|
||||
source: 'later',
|
||||
onPressedFn: () => _laterController.toViewDel(
|
||||
aid: videoItem.aid));
|
||||
}, childCount: _laterController.laterList.length),
|
||||
)
|
||||
: _laterController.isLoading.value
|
||||
? const SliverToBoxAdapter(
|
||||
child: Center(child: Text('加载中')),
|
||||
)
|
||||
: const NoData(),
|
||||
);
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _laterController.queryLaterList(type: 'onRefresh');
|
||||
},
|
||||
child: CustomScrollView(
|
||||
controller: _laterController.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
return Obx(
|
||||
() => _laterController.laterList.isNotEmpty &&
|
||||
!_laterController.isLoading.value
|
||||
? SliverList(
|
||||
delegate:
|
||||
SliverChildBuilderDelegate((context, index) {
|
||||
var videoItem =
|
||||
_laterController.laterList[index];
|
||||
return VideoCardH(
|
||||
videoItem: videoItem,
|
||||
source: 'later',
|
||||
onPressedFn: () => _laterController
|
||||
.toViewDel(aid: videoItem.aid));
|
||||
}, 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 {
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
btnText: data?['code'] == -101 ? '去登录' : null,
|
||||
fn: () {
|
||||
if (data?['code'] == -101) {
|
||||
RoutePush.loginRedirectPush();
|
||||
} else {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_laterController.queryLaterList();
|
||||
});
|
||||
}
|
||||
},
|
||||
// 骨架屏
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
}, childCount: 10),
|
||||
);
|
||||
}
|
||||
} 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(
|
||||
() => _laterController.laterList.isNotEmpty
|
||||
|
||||
@ -14,6 +14,7 @@ class LiveController extends GetxController {
|
||||
RxList<LiveItemModel> liveList = <LiveItemModel>[].obs;
|
||||
RxList<LiveFollowingItemModel> liveFollowingList =
|
||||
<LiveFollowingItemModel>[].obs;
|
||||
RxInt liveFollowingCount = 0.obs;
|
||||
bool flag = false;
|
||||
OverlayEntry? popupDialog;
|
||||
Box setting = GStrorage.setting;
|
||||
@ -27,9 +28,6 @@ class LiveController extends GetxController {
|
||||
|
||||
// 获取推荐
|
||||
Future queryLiveList(type) async {
|
||||
// if (type == 'init') {
|
||||
// _currentPage = 1;
|
||||
// }
|
||||
var res = await LiveHttp.liveList(
|
||||
pn: _currentPage,
|
||||
);
|
||||
@ -68,13 +66,14 @@ class LiveController extends GetxController {
|
||||
|
||||
//
|
||||
Future fetchLiveFollowing() async {
|
||||
var res = await LiveHttp.liveFollowing(pn: 1, ps: 20);
|
||||
var res = await LiveHttp.liveFollowing(pn: 1, ps: 10);
|
||||
if (res['status']) {
|
||||
liveFollowingList.value =
|
||||
(res['data'].list as List<LiveFollowingItemModel>)
|
||||
.where((LiveFollowingItemModel item) =>
|
||||
item.liveStatus == 1 && item.recordLiveTime == 0) // 根据条件过滤
|
||||
.toList();
|
||||
liveFollowingCount.value = res['data'].liveCount;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -162,34 +162,61 @@ class _LivePageState extends State<LivePage>
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Obx(
|
||||
() => Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: ' 我的关注 ',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Obx(
|
||||
() => Text.rich(
|
||||
TextSpan(
|
||||
text: ' ${_liveController.liveFollowingList.length}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: ' 我的关注 ',
|
||||
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(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture2,
|
||||
@ -201,8 +228,7 @@ class _LivePageState extends State<LivePage>
|
||||
Map? data = snapshot.data;
|
||||
if (data?['status']) {
|
||||
RxList list = _liveController.liveFollowingList;
|
||||
// ignore: invalid_use_of_protected_member
|
||||
return Obx(() => LiveFollowingListView(list: list.value));
|
||||
return LiveFollowingListView(list: list);
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 80,
|
||||
@ -230,69 +256,71 @@ class _LivePageState extends State<LivePage>
|
||||
}
|
||||
|
||||
class LiveFollowingListView extends StatelessWidget {
|
||||
final List list;
|
||||
final RxList list;
|
||||
|
||||
const LiveFollowingListView({super.key, required this.list});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 100,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
final LiveFollowingItemModel item = list[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(3, 12, 3, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/liveRoom?roomid=${item.roomId}',
|
||||
arguments: {
|
||||
'liveItem': item,
|
||||
'heroTag': item.roomId.toString()
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 54,
|
||||
height: 54,
|
||||
padding: const EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(27),
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 1.5,
|
||||
return Obx(
|
||||
() => SizedBox(
|
||||
height: 100,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
final LiveFollowingItemModel item = list[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(3, 12, 3, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/liveRoom?roomid=${item.roomId}',
|
||||
arguments: {
|
||||
'liveItem': item,
|
||||
'heroTag': item.roomId.toString()
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 54,
|
||||
height: 54,
|
||||
padding: const EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(27),
|
||||
border: Border.all(
|
||||
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,
|
||||
height: 50,
|
||||
type: 'avatar',
|
||||
src: list[index].face,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
SizedBox(
|
||||
width: 62,
|
||||
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(
|
||||
list[index].uname,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: list.length,
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: list.length,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ import 'package:flutter/material.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/badge.dart';
|
||||
import 'package:pilipala/models/live/follow.dart';
|
||||
import 'package:pilipala/models/live/item.dart';
|
||||
import 'package:pilipala/utils/image_save.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
@ -9,7 +11,7 @@ import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
|
||||
// 视频卡片 - 垂直布局
|
||||
class LiveCardV extends StatelessWidget {
|
||||
final LiveItemModel liveItem;
|
||||
final dynamic liveItem;
|
||||
final int crossAxisCount;
|
||||
|
||||
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 {
|
||||
final LiveItemModel? liveItem;
|
||||
final dynamic liveItem;
|
||||
|
||||
const VideoStat({
|
||||
Key? key,
|
||||
@ -178,25 +183,20 @@ class VideoStat extends StatelessWidget {
|
||||
liveItem!.areaName!,
|
||||
style: const TextStyle(fontSize: 11, color: Colors.white),
|
||||
),
|
||||
Text(
|
||||
liveItem!.watchedShow!['text_small'],
|
||||
style: const TextStyle(fontSize: 11, color: Colors.white),
|
||||
),
|
||||
if (liveItem is LiveItemModel) ...[
|
||||
Text(
|
||||
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:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/http/common.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
@ -25,6 +26,7 @@ class MainController extends GetxController {
|
||||
late PageController pageController;
|
||||
int selectedIndex = 0;
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
dynamic userInfo;
|
||||
RxBool userLogin = false.obs;
|
||||
late Rx<DynamicBadgeMode> dynamicBadgeType = DynamicBadgeMode.number.obs;
|
||||
late bool enableGradientBg;
|
||||
@ -38,7 +40,7 @@ class MainController extends GetxController {
|
||||
}
|
||||
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: false);
|
||||
|
||||
var userInfo = userInfoCache.get('userInfoCache');
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userLogin.value = userInfo != null;
|
||||
dynamicBadgeType.value = DynamicBadgeMode.values[setting.get(
|
||||
SettingBoxKey.dynamicBadgeMode,
|
||||
@ -73,12 +75,20 @@ class MainController extends GetxController {
|
||||
}
|
||||
int dynamicItemIndex =
|
||||
navigationBars.indexWhere((item) => item['label'] == "动态");
|
||||
int mineItemIndex =
|
||||
navigationBars.indexWhere((item) => item['label'] == "我的");
|
||||
var res = await CommonHttp.unReadDynamic();
|
||||
var data = res['data'];
|
||||
if (dynamicItemIndex != -1) {
|
||||
navigationBars[dynamicItemIndex]['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();
|
||||
}
|
||||
|
||||
|
||||
@ -7,10 +7,11 @@ import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/common/dynamic_badge_mode.dart';
|
||||
import 'package:pilipala/pages/dynamics/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/utils/event_bus.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import './controller.dart';
|
||||
|
||||
@ -26,7 +27,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
late HomeController _homeController;
|
||||
RankController? _rankController;
|
||||
late DynamicsController _dynamicController;
|
||||
late MediaController _mediaController;
|
||||
late MineController _mineController;
|
||||
|
||||
int? _lastSelectTime; //上次点击时间
|
||||
Box setting = GStrorage.setting;
|
||||
@ -92,24 +93,22 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
_dynamicController.flag = false;
|
||||
}
|
||||
|
||||
if (currentPage is MediaPage) {
|
||||
_mediaController.queryFavFolder();
|
||||
if (currentPage is MinePage) {
|
||||
_mineController.queryFavFolder();
|
||||
_mineController.queryUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
void controllerInit() {
|
||||
_homeController = Get.put(HomeController());
|
||||
_dynamicController = Get.put(DynamicsController());
|
||||
_mediaController = Get.put(MediaController());
|
||||
_mineController = Get.put(MineController());
|
||||
if (_mainController.pagesIds.contains(1)) {
|
||||
_rankController = Get.put(RankController());
|
||||
}
|
||||
if (_mainController.pagesIds.contains(2)) {
|
||||
_dynamicController = Get.put(DynamicsController());
|
||||
}
|
||||
if (_mainController.pagesIds.contains(3)) {
|
||||
_mediaController = Get.put(MediaController());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -126,6 +125,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
double sheetHeight = MediaQuery.sizeOf(context).height -
|
||||
MediaQuery.of(context).padding.top -
|
||||
MediaQuery.sizeOf(context).width * 9 / 16;
|
||||
GlobalDataCache().sheetHeight = sheetHeight;
|
||||
localCache.put('sheetHeight', sheetHeight);
|
||||
localCache.put('statusBarHeight', statusBarHeight);
|
||||
|
||||
@ -205,20 +205,21 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
destinations: <Widget>[
|
||||
..._mainController.navigationBars.map((e) {
|
||||
return NavigationDestination(
|
||||
icon: Badge(
|
||||
label: _mainController
|
||||
.dynamicBadgeType.value ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible: _mainController
|
||||
.dynamicBadgeType.value !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
),
|
||||
icon: _mainController
|
||||
.dynamicBadgeType.value ==
|
||||
DynamicBadgeMode.number
|
||||
? Badge(
|
||||
label: Text(e['count'].toString()),
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
6, 0, 6, 0),
|
||||
isLabelVisible: _mainController
|
||||
.dynamicBadgeType
|
||||
.value !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
)
|
||||
: e['icon'],
|
||||
selectedIcon: e['selectIcon'],
|
||||
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
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
mid = int.tryParse(Get.parameters['mid']!) ?? -2;
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
ownerMid = userInfo != null ? userInfo.mid : -1;
|
||||
isOwner.value = mid == ownerMid;
|
||||
@ -43,6 +43,11 @@ class MemberController extends GetxController {
|
||||
|
||||
// 获取用户信息
|
||||
Future<Map<String, dynamic>> getInfo() async {
|
||||
if (mid == -2) {
|
||||
SmartDialog.showToast('用户ID获取异常');
|
||||
return {'status': false, 'msg': '用户ID获取异常'};
|
||||
}
|
||||
|
||||
await getMemberStat();
|
||||
await getMemberView();
|
||||
var res = await MemberHttp.memberInfo(mid: mid);
|
||||
@ -117,18 +122,13 @@ class MemberController extends GetxController {
|
||||
|
||||
// 合并关注/取关和拉黑逻辑
|
||||
Future modifyRelation(String actionType) async {
|
||||
if (userInfo == null) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
|
||||
String contentText;
|
||||
int act;
|
||||
if (actionType == 'follow') {
|
||||
contentText = memberInfo.value.isFollowed! ? '确定取消关注UP主?' : '确定关注UP主?';
|
||||
act = memberInfo.value.isFollowed! ? 2 : 1;
|
||||
} else if (actionType == 'block') {
|
||||
contentText = attribute.value != 128 ? '确定拉黑UP主?' : '确定从黑名单移除UP主?';
|
||||
contentText = attribute.value != 128 ? '确定拉黑UP主?' : '确定从黑名单移除UP主?';
|
||||
act = attribute.value != 128 ? 5 : 6;
|
||||
} else {
|
||||
return;
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
import 'dart:async';
|
||||
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:get/get.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/models/member/info.dart';
|
||||
import 'package:pilipala/pages/member/index.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'widgets/commen_widget.dart';
|
||||
import 'widgets/conis.dart';
|
||||
@ -36,7 +39,7 @@ class _MemberPageState extends State<MemberPage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
mid = int.tryParse(Get.parameters['mid']!) ?? -1;
|
||||
heroTag = Get.arguments['heroTag'] ?? Utils.makeHeroTag(mid);
|
||||
_memberController = Get.put(MemberController(), tag: heroTag);
|
||||
_futureBuilderFuture = _memberController.getInfo();
|
||||
@ -100,8 +103,14 @@ class _MemberPageState extends State<MemberPage>
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => Get.toNamed(
|
||||
'/memberSearch?mid=$mid&uname=${_memberController.memberInfo.value.name!}'),
|
||||
onPressed: () {
|
||||
if (mid == -1) {
|
||||
SmartDialog.showToast('用户ID获取异常');
|
||||
return;
|
||||
}
|
||||
Get.toNamed(
|
||||
'/memberSearch?mid=$mid&uname=${_memberController.memberInfo.value.name ?? ''}');
|
||||
},
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
PopupMenuButton(
|
||||
@ -147,6 +156,25 @@ class _MemberPageState extends State<MemberPage>
|
||||
bottom: MediaQuery.of(context).padding.bottom + 20,
|
||||
),
|
||||
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(),
|
||||
|
||||
/// 动态链接
|
||||
@ -311,6 +339,7 @@ class _MemberPageState extends State<MemberPage>
|
||||
Rx<MemberInfoModel> memberInfo = _memberController.memberInfo;
|
||||
return Obx(
|
||||
() => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ProfilePanel(ctr: _memberController),
|
||||
@ -369,7 +398,7 @@ class _MemberPageState extends State<MemberPage>
|
||||
.value.vip!.label!['img_label_uri_hans_static'],
|
||||
height: 20,
|
||||
),
|
||||
]
|
||||
],
|
||||
],
|
||||
),
|
||||
if (memberInfo.value.official!['title'] != '') ...[
|
||||
@ -386,6 +415,39 @@ class _MemberPageState extends State<MemberPage>
|
||||
),
|
||||
],
|
||||
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 ?? ''),
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
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/models/live/item.dart';
|
||||
import 'package:pilipala/models/member/info.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/index.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
class ProfilePanel extends StatelessWidget {
|
||||
@ -71,11 +71,27 @@ class ProfilePanel extends StatelessWidget {
|
||||
tag: ctr.heroTag!,
|
||||
child: Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 90,
|
||||
height: 90,
|
||||
type: 'avatar',
|
||||
src: !loadingStatus ? memberInfo.face : ctr.face.value,
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
HeroDialogRoute<void>(
|
||||
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 &&
|
||||
memberInfo.liveRoom != null &&
|
||||
@ -237,7 +253,7 @@ class ProfilePanel extends StatelessWidget {
|
||||
Widget buildEditProfileButton(BuildContext context) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
SmartDialog.showToast('功能开发中 💪');
|
||||
Get.toNamed('/mineEdit');
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 80),
|
||||
|
||||
@ -41,6 +41,7 @@ class MemberSeasonsPanel extends StatelessWidget {
|
||||
'category': '1',
|
||||
'mid': item.meta!.mid.toString(),
|
||||
'seriesId': item.meta!.seriesId.toString(),
|
||||
'seasonId': item.meta!.seasonId.toString(),
|
||||
'seasonName': item.meta!.name!,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/http/search.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 {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
late int mid;
|
||||
int pn = 1;
|
||||
int count = 0;
|
||||
RxInt count = 0.obs;
|
||||
RxMap<String, String> currentOrder = <String, String>{}.obs;
|
||||
RxList<Map<String, String>> orderList = [
|
||||
{'type': 'pubdate', 'label': '最新发布'},
|
||||
@ -17,12 +20,18 @@ class MemberArchiveController extends GetxController {
|
||||
].obs;
|
||||
RxList<VListItemModel> archivesList = <VListItemModel>[].obs;
|
||||
RxBool isLoading = false.obs;
|
||||
late int ownerMid;
|
||||
RxBool isOwner = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
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 (type == 'init') {
|
||||
archivesList.value = res['data'].list.vlist;
|
||||
count.value = res['data'].page['count'];
|
||||
}
|
||||
if (type == 'onLoad') {
|
||||
archivesList.addAll(res['data'].list.vlist);
|
||||
}
|
||||
count = res['data'].page['count'];
|
||||
pn += 1;
|
||||
}
|
||||
isLoading.value = false;
|
||||
@ -69,4 +78,29 @@ class MemberArchiveController extends GetxController {
|
||||
Future onLoad() async {
|
||||
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,
|
||||
title: Obx(
|
||||
() => Text(
|
||||
'他的投稿 - ${_memberArchivesController.currentOrder['label']}',
|
||||
style: Theme.of(context).textTheme.titleMedium),
|
||||
'${_memberArchivesController.isOwner.value ? '我' : 'Ta'}的投稿 - ${_memberArchivesController.currentOrder['label']}',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
// 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:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/member/article.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
|
||||
class MemberArticleController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
@ -12,15 +13,21 @@ class MemberArticleController extends GetxController {
|
||||
bool hasMore = true;
|
||||
RxBool isLoading = false.obs;
|
||||
RxList<MemberArticleItemModel> articleList = <MemberArticleItemModel>[].obs;
|
||||
late int ownerMid;
|
||||
RxBool isOwner = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
ownerMid = GlobalDataCache().userInfo != null
|
||||
? GlobalDataCache().userInfo!.mid!
|
||||
: -1;
|
||||
isOwner.value = mid == -1 || mid == ownerMid;
|
||||
}
|
||||
|
||||
Future getMemberArticle(type) async {
|
||||
if (isLoading.value) {
|
||||
if (isLoading.value || !hasMore) {
|
||||
return;
|
||||
}
|
||||
isLoading.value = true;
|
||||
|
||||
@ -50,7 +50,12 @@ class _MemberArticlePageState extends State<MemberArticlePage> {
|
||||
appBar: AppBar(
|
||||
titleSpacing: 0,
|
||||
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(
|
||||
future: _futureBuilderFuture,
|
||||
@ -113,12 +118,14 @@ class _MemberArticlePageState extends State<MemberArticlePage> {
|
||||
'articleType': 'opus',
|
||||
});
|
||||
},
|
||||
leading: NetworkImgLayer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
type: 'emote',
|
||||
src: item.cover['url'],
|
||||
),
|
||||
leading: item?.cover != null
|
||||
? NetworkImgLayer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
type: 'emote',
|
||||
src: item?.cover?['url'] ?? '',
|
||||
)
|
||||
: const SizedBox(),
|
||||
title: Text(
|
||||
item.content,
|
||||
maxLines: 2,
|
||||
@ -138,16 +145,10 @@ class _MemberArticlePageState extends State<MemberArticlePage> {
|
||||
}
|
||||
|
||||
Widget _buildError(String errMsg) {
|
||||
return CustomScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: HttpError(
|
||||
errMsg: errMsg,
|
||||
fn: () {},
|
||||
),
|
||||
),
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: errMsg,
|
||||
fn: () {},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/dynamics/result.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
|
||||
class MemberDynamicsController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
@ -10,11 +11,17 @@ class MemberDynamicsController extends GetxController {
|
||||
int count = 0;
|
||||
bool hasMore = true;
|
||||
RxList<DynamicItemModel> dynamicsList = <DynamicItemModel>[].obs;
|
||||
late int ownerMid;
|
||||
RxBool isOwner = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
ownerMid = GlobalDataCache().userInfo != null
|
||||
? GlobalDataCache().userInfo!.mid!
|
||||
: -1;
|
||||
isOwner.value = mid == -1 || mid == ownerMid;
|
||||
}
|
||||
|
||||
Future getMemberDynamic(type) async {
|
||||
|
||||
@ -56,7 +56,12 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
|
||||
appBar: AppBar(
|
||||
titleSpacing: 0,
|
||||
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(
|
||||
controller: _memberDynamicController.scrollController,
|
||||
|
||||
@ -164,13 +164,10 @@ class _MemberSearchPageState extends State<MemberSearchPage>
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -24,7 +24,8 @@ class MemberSeasonsController extends GetxController {
|
||||
seasonId = int.parse(Get.parameters['seasonId']!);
|
||||
}
|
||||
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');
|
||||
}
|
||||
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() {
|
||||
super.initState();
|
||||
category = Get.parameters['category']!;
|
||||
_futureBuilderFuture = category == '0'
|
||||
? _memberSeasonsController.getSeasonDetail('onRefresh')
|
||||
: _memberSeasonsController.getSeriesDetail('onRefresh');
|
||||
_futureBuilderFuture = _memberSeasonsController.onRefresh();
|
||||
scrollController = _memberSeasonsController.scrollController;
|
||||
scrollController.addListener(
|
||||
() {
|
||||
|
||||
@ -1,3 +1,27 @@
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.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: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 {
|
||||
const MessageAtPage({super.key});
|
||||
@ -8,12 +18,179 @@ class MessageAtPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
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']);
|
||||
if (res['status']) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.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/http/search.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/models/msg/like.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
import '../utils/index.dart';
|
||||
import 'controller.dart';
|
||||
|
||||
class MessageLikePage extends StatefulWidget {
|
||||
@ -59,44 +58,40 @@ class _MessageLikePageState extends State<MessageLikePage> {
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
if (snapshot.data['status']) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
final likeItems = _messageLikeCtr.likeItems;
|
||||
return Obx(
|
||||
() => ListView.separated(
|
||||
controller: scrollController,
|
||||
itemBuilder: (context, index) => LikeItem(
|
||||
item: likeItems[index],
|
||||
index: index,
|
||||
messageLikeCtr: _messageLikeCtr,
|
||||
),
|
||||
itemCount: likeItems.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
indent: 66,
|
||||
endIndent: 14,
|
||||
height: 1,
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
);
|
||||
},
|
||||
),
|
||||
() => likeItems.isEmpty
|
||||
? const CustomScrollView(slivers: [NoData()])
|
||||
: ListView.separated(
|
||||
controller: scrollController,
|
||||
itemBuilder: (context, index) => LikeItem(
|
||||
item: likeItems[index],
|
||||
index: index,
|
||||
messageLikeCtr: _messageLikeCtr,
|
||||
),
|
||||
itemCount: likeItems.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
indent: 66,
|
||||
endIndent: 14,
|
||||
height: 1,
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_messageLikeCtr.queryMessageLike();
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture = _messageLikeCtr.queryMessageLike();
|
||||
});
|
||||
},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -126,39 +121,13 @@ class LikeItem extends StatelessWidget {
|
||||
final nickNameList = item.users!.map((e) => e.nickname).take(2).toList();
|
||||
int usersLen = item.users!.length > 3 ? 3 : item.users!.length;
|
||||
final Uri uri = Uri.parse(item.item!.uri!);
|
||||
final String path = uri.path;
|
||||
final String bvid = path.split('/').last;
|
||||
|
||||
/// bilibili://
|
||||
final Uri nativeUri = Uri.parse(item.item!.nativeUri!);
|
||||
final Map<String, String> queryParameters = nativeUri.queryParameters;
|
||||
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(
|
||||
onTap: () async {
|
||||
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');
|
||||
}
|
||||
MessageUtils.onClickMessage(context, uri, nativeUri, type);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
@ -247,6 +216,7 @@ class LikeItem extends StatelessWidget {
|
||||
width: 60,
|
||||
height: 60,
|
||||
src: item.item!.image,
|
||||
radius: 6,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -4,10 +4,10 @@ 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/http/search.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/models/msg/reply.dart';
|
||||
import 'package:pilipala/pages/message/utils/index.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
|
||||
class MessageReplyPage extends StatefulWidget {
|
||||
@ -59,41 +59,38 @@ class _MessageReplyPageState extends State<MessageReplyPage> {
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
if (snapshot.data['status']) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
final replyItems = _messageReplyCtr.replyItems;
|
||||
return Obx(
|
||||
() => ListView.separated(
|
||||
controller: scrollController,
|
||||
itemBuilder: (context, index) =>
|
||||
ReplyItem(item: replyItems[index]),
|
||||
itemCount: replyItems.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
indent: 66,
|
||||
endIndent: 14,
|
||||
height: 1,
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
);
|
||||
},
|
||||
),
|
||||
() => replyItems.isEmpty
|
||||
? const CustomScrollView(slivers: [NoData()])
|
||||
: ListView.separated(
|
||||
controller: scrollController,
|
||||
itemBuilder: (context, index) =>
|
||||
ReplyItem(item: replyItems[index]),
|
||||
itemCount: replyItems.length,
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
indent: 66,
|
||||
endIndent: 14,
|
||||
height: 1,
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_messageReplyCtr.queryMessageReply();
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_messageReplyCtr.queryMessageReply();
|
||||
});
|
||||
},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -115,28 +112,14 @@ class ReplyItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
Color outline = Theme.of(context).colorScheme.outline;
|
||||
final String heroTag = Utils.makeHeroTag(item.user!.mid);
|
||||
final String bvid = item.item!.uri!.split('/').last;
|
||||
// 页码
|
||||
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;
|
||||
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 {
|
||||
final int cid = 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,
|
||||
},
|
||||
);
|
||||
MessageUtils.onClickMessage(context, uri, nativeUri, type);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
@ -220,6 +203,7 @@ class ReplyItem extends StatelessWidget {
|
||||
width: 60,
|
||||
height: 60,
|
||||
src: item.item!.image,
|
||||
radius: 6,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.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';
|
||||
|
||||
class MessageSystemPage extends StatefulWidget {
|
||||
@ -63,18 +66,15 @@ class _MessageSystemPageState extends State<MessageSystemPage> {
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_messageSystemCtr.queryMessageSystem();
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_messageSystemCtr.queryMessageSystem();
|
||||
});
|
||||
},
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -114,9 +114,73 @@ class SystemItem extends StatelessWidget {
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
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:pilipala/http/user.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/stat.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class MineController extends GetxController {
|
||||
// 用户信息 头像、昵称、lv
|
||||
Rx<UserInfoData> userInfo = UserInfoData().obs;
|
||||
RxBool userLogin = false.obs;
|
||||
// 用户状态 动态、关注、粉丝
|
||||
Rx<UserStat> userStat = UserStat().obs;
|
||||
RxBool userLogin = false.obs;
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
Box setting = GStrorage.setting;
|
||||
// 用户信息 头像、昵称、lv
|
||||
Rx<UserInfoData> userInfo = UserInfoData().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
|
||||
onInit() {
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
if (userInfoCache.get('userInfoCache') != null) {
|
||||
@ -109,7 +132,10 @@ class MineController extends GetxController {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
Get.toNamed('/follow?mid=${userInfo.value.mid}', preventDuplicates: false);
|
||||
Get.toNamed(
|
||||
'/follow?mid=${userInfo.value.mid}',
|
||||
preventDuplicates: false,
|
||||
);
|
||||
}
|
||||
|
||||
pushFans() {
|
||||
@ -117,7 +143,10 @@ class MineController extends GetxController {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
Get.toNamed('/fan?mid=${userInfo.value.mid}', preventDuplicates: false);
|
||||
Get.toNamed(
|
||||
'/fan?mid=${userInfo.value.mid}',
|
||||
preventDuplicates: false,
|
||||
);
|
||||
}
|
||||
|
||||
pushDynamic() {
|
||||
@ -125,7 +154,22 @@ class MineController extends GetxController {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
Get.toNamed('/memberDynamics?mid=${userInfo.value.mid}',
|
||||
preventDuplicates: false);
|
||||
Get.toNamed(
|
||||
'/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_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/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/stat.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'controller.dart';
|
||||
|
||||
class MinePage extends StatefulWidget {
|
||||
@ -16,19 +17,23 @@ class MinePage extends StatefulWidget {
|
||||
State<MinePage> createState() => _MinePageState();
|
||||
}
|
||||
|
||||
class _MinePageState extends State<MinePage> {
|
||||
final MineController mineController = Get.put(MineController());
|
||||
class _MinePageState extends State<MinePage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final MineController ctr = Get.put(MineController());
|
||||
late Future _futureBuilderFuture;
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_futureBuilderFuture = mineController.queryUserInfo();
|
||||
|
||||
mineController.userLogin.listen((status) {
|
||||
_futureBuilderFuture = ctr.queryUserInfo();
|
||||
ctr.queryFavFolder();
|
||||
ctr.userLogin.listen((status) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_futureBuilderFuture = mineController.queryUserInfo();
|
||||
_futureBuilderFuture = ctr.queryUserInfo();
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -36,71 +41,212 @@ class _MinePageState extends State<MinePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
scrolledUnderElevation: 0,
|
||||
elevation: 0,
|
||||
toolbarHeight: kTextTabBarHeight + 20,
|
||||
backgroundColor: Colors.transparent,
|
||||
centerTitle: false,
|
||||
title: const Text(
|
||||
'PLPL',
|
||||
style: TextStyle(
|
||||
height: 2.8,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Jura-Bold',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => mineController.onChangeTheme(),
|
||||
icon: Icon(
|
||||
mineController.themeType.value == ThemeType.dark
|
||||
? CupertinoIcons.sun_max
|
||||
: CupertinoIcons.moon,
|
||||
size: 22,
|
||||
),
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
onPressed: () => Get.toNamed('/search'),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => Get.toNamed('/setting', preventDuplicates: false),
|
||||
icon: const Icon(
|
||||
CupertinoIcons.slider_horizontal_3,
|
||||
icon: Icon(
|
||||
ctr.themeType.value == ThemeType.dark
|
||||
? 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(
|
||||
builder: (context, constraint) {
|
||||
return SingleChildScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
child: SizedBox(
|
||||
height: constraint.maxHeight,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
if (snapshot.data['status']) {
|
||||
return Obx(
|
||||
() => userInfoBuild(mineController, context));
|
||||
} else {
|
||||
return userInfoBuild(mineController, context);
|
||||
}
|
||||
} else {
|
||||
return userInfoBuild(mineController, context);
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await ctr.queryUserInfo();
|
||||
},
|
||||
child: SingleChildScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(
|
||||
parent: BouncingScrollPhysics()),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 110),
|
||||
child: Column(
|
||||
children: [
|
||||
Obx(() => _buildProfileSection(context, ctr.userInfo.value)),
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
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) {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 5),
|
||||
GestureDetector(
|
||||
onTap: () => _mineController.onLogin(),
|
||||
child: ClipOval(
|
||||
child: Container(
|
||||
width: 85,
|
||||
height: 85,
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
child: Center(
|
||||
child: _mineController.userInfo.value.face != null
|
||||
? NetworkImgLayer(
|
||||
src: _mineController.userInfo.value.face,
|
||||
width: 85,
|
||||
height: 85)
|
||||
: Image.asset('assets/images/noface.jpeg'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Widget _buildStatItem(
|
||||
BuildContext context,
|
||||
String count,
|
||||
String label,
|
||||
Function onTap,
|
||||
) {
|
||||
TextStyle style = TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
||||
fontWeight: FontWeight.bold);
|
||||
return InkWell(
|
||||
onTap: () => onTap(),
|
||||
// onTap: () {},
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(count, style: style),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
style: Theme.of(context).textTheme.labelMedium!.copyWith(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
TextStyle style = TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontWeight: FontWeight.bold);
|
||||
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>[
|
||||
InkWell(
|
||||
onTap: () => _mineController.pushDynamic(),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
transitionBuilder:
|
||||
(Widget child, Animation<double> animation) {
|
||||
return ScaleTransition(
|
||||
scale: animation, child: child);
|
||||
},
|
||||
child: Text(
|
||||
(_mineController.userStat.value.dynamicCount ??
|
||||
'-')
|
||||
.toString(),
|
||||
key: ValueKey<String>(_mineController
|
||||
.userStat.value.dynamicCount
|
||||
.toString()),
|
||||
style: style),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuSection(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return SizedBox(
|
||||
height: constraints.maxWidth / 4 * 0.85,
|
||||
child: GridView.count(
|
||||
primary: false,
|
||||
crossAxisCount: 4,
|
||||
padding: const EdgeInsets.all(0),
|
||||
childAspectRatio: 1.2,
|
||||
children: [
|
||||
...ctr.menuList.map((element) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!ctr.userLogin.value) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
} else {
|
||||
element['onTap']();
|
||||
}
|
||||
},
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Icon(
|
||||
element['icon'],
|
||||
size: 21,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'动态',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(element['title'])
|
||||
],
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => _mineController.pushFollow(),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
transitionBuilder:
|
||||
(Widget child, Animation<double> animation) {
|
||||
return ScaleTransition(
|
||||
scale: animation, child: child);
|
||||
},
|
||||
child: Text(
|
||||
(_mineController.userStat.value.following ??
|
||||
'-')
|
||||
.toString(),
|
||||
key: ValueKey<String>(_mineController
|
||||
.userStat.value.following
|
||||
.toString()),
|
||||
style: style),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'关注',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFavoritesSection(context) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildFavoritesTitle(context, 'fav', '收藏夹'),
|
||||
const SizedBox(height: 4),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: MediaQuery.textScalerOf(context).scale(180),
|
||||
child: FutureBuilder(
|
||||
future: ctr.queryFavFolder(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
List favFolderList = ctr.favFolderData.value.list!;
|
||||
int favFolderCount = ctr.favFolderData.value.count!;
|
||||
bool flag = favFolderCount > favFolderList.length;
|
||||
return Obx(
|
||||
() => ListView.builder(
|
||||
itemCount:
|
||||
ctr.favFolderData.value.list!.length + (flag ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (flag && index == favFolderList.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 14),
|
||||
child: Center(
|
||||
child: IconButton(
|
||||
style: ButtonStyle(
|
||||
padding: MaterialStateProperty.all(
|
||||
EdgeInsets.zero),
|
||||
backgroundColor:
|
||||
MaterialStateProperty.resolveWith(
|
||||
(states) {
|
||||
return Theme.of(context)
|
||||
.colorScheme
|
||||
.primaryContainer
|
||||
.withOpacity(0.5);
|
||||
}),
|
||||
),
|
||||
onPressed: () => Get.toNamed('/fav'),
|
||||
icon: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 18,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return FavFolderItem(
|
||||
item: ctr.favFolderData.value.list![index],
|
||||
index: index,
|
||||
);
|
||||
}
|
||||
},
|
||||
scrollDirection: Axis.horizontal,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => _mineController.pushFans(),
|
||||
borderRadius: StyleString.mdRadius,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
transitionBuilder:
|
||||
(Widget child, Animation<double> animation) {
|
||||
return ScaleTransition(
|
||||
scale: animation, child: child);
|
||||
},
|
||||
child: Text(
|
||||
(_mineController.userStat.value.follower ?? '-')
|
||||
.toString(),
|
||||
key: ValueKey<String>(_mineController
|
||||
.userStat.value.follower
|
||||
.toString()),
|
||||
style: style),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'粉丝',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
);
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 110,
|
||||
child: Center(child: Text(data?['msg'] ?? '')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 骨架屏
|
||||
return Obx(
|
||||
() => ctr.favFolderData.value.list != null
|
||||
? ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: ctr.favFolderData.value.list!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return FavFolderItem(
|
||||
item: ctr.favFolderData.value.list![index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
)
|
||||
: const SizedBox(),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
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 {
|
||||
final Icon? icon;
|
||||
final Function? onTap;
|
||||
final String? text;
|
||||
|
||||
const ActionItem({
|
||||
Key? key,
|
||||
this.icon,
|
||||
this.onTap,
|
||||
this.text,
|
||||
}) : super(key: key);
|
||||
|
||||
class FavFolderItem extends StatelessWidget {
|
||||
const FavFolderItem({super.key, this.item, this.index});
|
||||
final FavFolderItemData? item;
|
||||
final int? index;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {},
|
||||
borderRadius: StyleString.mdRadius,
|
||||
String heroTag = Utils.makeHeroTag(item!.fid);
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: index == 0 ? 20 : 0, right: 14),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
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),
|
||||
Text(
|
||||
text!,
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
' ${item!.title}',
|
||||
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 './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_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/search.dart';
|
||||
import 'package:pilipala/models/search/hot.dart';
|
||||
import 'package:pilipala/models/search/suggest.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class SSearchController extends GetxController {
|
||||
@ -12,7 +15,7 @@ class SSearchController extends GetxController {
|
||||
RxString searchKeyWord = ''.obs;
|
||||
Rx<TextEditingController> controller = TextEditingController().obs;
|
||||
RxList<HotSearchItem> hotSearchList = <HotSearchItem>[].obs;
|
||||
Box histiryWord = GStrorage.historyword;
|
||||
Box localCache = GStrorage.localCache;
|
||||
List historyCacheList = [];
|
||||
RxList historyList = [].obs;
|
||||
RxList<SearchSuggestItem> searchSuggestList = <SearchSuggestItem>[].obs;
|
||||
@ -22,23 +25,28 @@ class SSearchController extends GetxController {
|
||||
RxString defaultSearch = ''.obs;
|
||||
Box setting = GStrorage.setting;
|
||||
bool enableHotKey = true;
|
||||
bool enableSearchSuggest = true;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
// 其他页面跳转过来
|
||||
if (Get.parameters.keys.isNotEmpty) {
|
||||
if (Get.parameters['keyword'] != null) {
|
||||
onClickKeyword(Get.parameters['keyword']!);
|
||||
final parameters = Get.parameters;
|
||||
if (parameters.keys.isNotEmpty) {
|
||||
final keyword = parameters['keyword'];
|
||||
if (keyword != null) {
|
||||
onClickKeyword(keyword);
|
||||
}
|
||||
if (Get.parameters['hintText'] != null) {
|
||||
hintText = Get.parameters['hintText']!;
|
||||
searchKeyWord.value = hintText;
|
||||
|
||||
final hint = parameters['hintText'];
|
||||
if (hint != null) {
|
||||
hintText = hint;
|
||||
}
|
||||
}
|
||||
historyCacheList = histiryWord.get('cacheList') ?? [];
|
||||
historyCacheList = GlobalDataCache().historyCacheList;
|
||||
historyList.value = historyCacheList;
|
||||
enableHotKey = setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
|
||||
enableSearchSuggest = GlobalDataCache().enableSearchSuggest;
|
||||
}
|
||||
|
||||
void onChange(value) {
|
||||
@ -47,34 +55,29 @@ class SSearchController extends GetxController {
|
||||
searchSuggestList.value = [];
|
||||
return;
|
||||
}
|
||||
_debouncer.call(() => querySearchSuggest(value));
|
||||
if (enableSearchSuggest) {
|
||||
_debouncer.call(() => querySearchSuggest(value));
|
||||
}
|
||||
}
|
||||
|
||||
void onClear() {
|
||||
if (searchKeyWord.value.isNotEmpty && controller.value.text != '') {
|
||||
controller.value.clear();
|
||||
searchKeyWord.value = '';
|
||||
searchSuggestList.value = [];
|
||||
} else {
|
||||
Get.back();
|
||||
}
|
||||
controller.value.clear();
|
||||
searchKeyWord.value = '';
|
||||
searchSuggestList.value = [];
|
||||
}
|
||||
|
||||
// 搜索
|
||||
void submit() {
|
||||
// ignore: unrelated_type_equality_checks
|
||||
if (searchKeyWord == '') {
|
||||
if (searchKeyWord.value == '' && hintText.isNotEmpty && hintText == '搜索') {
|
||||
return;
|
||||
} else {
|
||||
if (searchKeyWord.value == '' && hintText != '搜索') {
|
||||
searchKeyWord.value = hintText;
|
||||
controller.value.text = hintText;
|
||||
}
|
||||
}
|
||||
List arr = historyCacheList.where((e) => e != searchKeyWord.value).toList();
|
||||
arr.insert(0, searchKeyWord.value);
|
||||
historyCacheList = arr;
|
||||
|
||||
historyList.value = historyCacheList;
|
||||
// 手动刷新
|
||||
historyList.refresh();
|
||||
histiryWord.put('cacheList', historyCacheList);
|
||||
searchFocusNode.unfocus();
|
||||
hintText = '搜索';
|
||||
cacheHistory();
|
||||
Get.toNamed('/searchResult', parameters: {'keyword': searchKeyWord.value});
|
||||
}
|
||||
|
||||
@ -117,13 +120,26 @@ class SSearchController extends GetxController {
|
||||
int index = historyList.indexOf(word);
|
||||
historyList.removeAt(index);
|
||||
historyList.refresh();
|
||||
histiryWord.put('cacheList', historyList);
|
||||
localCache.put('cacheList', historyList);
|
||||
}
|
||||
|
||||
onClearHis() {
|
||||
historyList.value = [];
|
||||
historyCacheList = [];
|
||||
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:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
@ -54,7 +53,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => _searchController.submit(),
|
||||
icon: const Icon(CupertinoIcons.search, size: 22),
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
const SizedBox(width: 10)
|
||||
],
|
||||
@ -64,18 +63,35 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
focusNode: _searchController.searchFocusNode,
|
||||
controller: _searchController.controller.value,
|
||||
textInputAction: TextInputAction.search,
|
||||
onChanged: (value) => _searchController.onChange(value),
|
||||
onChanged: _searchController.onChange,
|
||||
decoration: InputDecoration(
|
||||
hintText: _searchController.hintText,
|
||||
border: InputBorder.none,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
size: 22,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
onPressed: () => _searchController.onClear(),
|
||||
),
|
||||
suffix: Obx(() {
|
||||
RxString searchKeyWord = _searchController.searchKeyWord;
|
||||
if (searchKeyWord.value.isEmpty) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Row(
|
||||
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(),
|
||||
),
|
||||
@ -84,7 +100,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 6),
|
||||
// 搜索建议
|
||||
_searchSuggest(),
|
||||
// 热搜
|
||||
@ -135,7 +151,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 6),
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 4),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -153,7 +169,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
padding: MaterialStateProperty.all(const EdgeInsets.only(
|
||||
left: 10, top: 6, bottom: 6, right: 10)),
|
||||
),
|
||||
onPressed: () => ctr.queryHotSearchList(),
|
||||
onPressed: ctr.queryHotSearchList,
|
||||
icon: const Icon(Icons.refresh_outlined, size: 18),
|
||||
label: const Text('刷新'),
|
||||
),
|
||||
@ -187,13 +203,10 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
)
|
||||
],
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -202,6 +215,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
return HotKeyword(
|
||||
width: width,
|
||||
hotSearchList: _searchController.hotSearchList,
|
||||
onClick: () {},
|
||||
);
|
||||
} else {
|
||||
return const SizedBox();
|
||||
@ -220,13 +234,13 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
return Obx(
|
||||
() => Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(10, 25, 6, 0),
|
||||
padding: const EdgeInsets.fromLTRB(10, 20, 4, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (_searchController.historyList.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 0, 2),
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -237,10 +251,19 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
||||
.titleMedium!
|
||||
.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => _searchController.onClearHis(),
|
||||
child: const Text('清空'),
|
||||
)
|
||||
SizedBox(
|
||||
height: 34,
|
||||
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:flutter/material.dart';
|
||||
|
||||
class HotKeyword extends StatelessWidget {
|
||||
final double? width;
|
||||
final List? hotSearchList;
|
||||
final Function? onClick;
|
||||
final double width;
|
||||
final List hotSearchList;
|
||||
final Function onClick;
|
||||
|
||||
const HotKeyword({
|
||||
this.width,
|
||||
this.hotSearchList,
|
||||
this.onClick,
|
||||
required this.width,
|
||||
required this.hotSearchList,
|
||||
required this.onClick,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@ -18,45 +18,67 @@ class HotKeyword extends StatelessWidget {
|
||||
return Wrap(
|
||||
runSpacing: 0.4,
|
||||
spacing: 5.0,
|
||||
children: [
|
||||
for (var i in hotSearchList!)
|
||||
SizedBox(
|
||||
width: width! / 2 - 4,
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
onTap: () => onClick!(i.keyword),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 2,
|
||||
right: hotSearchList!.indexOf(i) % 2 == 1 ? 10 : 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 5, 4, 5),
|
||||
child: Text(
|
||||
i.keyword!,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (i.icon != null && i.icon != '')
|
||||
SizedBox(
|
||||
height: 15,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: i.icon!, height: 15.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
children: hotSearchList.map((item) {
|
||||
return HotKeywordItem(
|
||||
width: width,
|
||||
item: item,
|
||||
onClick: onClick,
|
||||
isRightPadding: hotSearchList.indexOf(item) % 2 == 1,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HotKeywordItem extends StatelessWidget {
|
||||
final double width;
|
||||
final dynamic item;
|
||||
final Function onClick;
|
||||
final bool isRightPadding;
|
||||
|
||||
const HotKeywordItem({
|
||||
required this.width,
|
||||
required this.item,
|
||||
required this.onClick,
|
||||
required this.isRightPadding,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width / 2 - 4,
|
||||
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:pilipala/utils/feed_back.dart';
|
||||
|
||||
class SearchText extends StatelessWidget {
|
||||
final String? searchText;
|
||||
@ -17,30 +18,31 @@ class SearchText extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
return Material(
|
||||
color: isSelect
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
|
||||
? colorScheme.primaryContainer
|
||||
: colorScheme.surfaceVariant.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.zero,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
onSelect!(searchText);
|
||||
onSelect?.call(searchText);
|
||||
},
|
||||
onLongPress: () {
|
||||
onLongSelect!(searchText);
|
||||
feedBack();
|
||||
onLongSelect?.call(searchText);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 5, bottom: 5, left: 11, right: 11),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 11),
|
||||
child: Text(
|
||||
searchText!,
|
||||
style: TextStyle(
|
||||
color: isSelect
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
? colorScheme.primary
|
||||
: 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