Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-06-21 18:59:48 +08:00
parent 604d78ad6a
commit 2d66b1d8ca
4 changed files with 1113 additions and 1116 deletions

View File

@@ -59,10 +59,8 @@ class SSearchController extends GetxController {
controller.text = Get.parameters['text']!;
}
if (recordSearchHistory.value) {
historyList =
List<String>.from(GStorage.historyWord.get('cacheList') ?? []).obs;
}
if (searchSuggestion) {
_ctr = StreamController<String>();

View File

@@ -80,7 +80,7 @@ class _SearchPageState extends State<SearchPage> {
if (_searchController.searchSuggestion) _searchSuggest(),
if (context.orientation == Orientation.portrait) ...[
if (_searchController.enableHotKey) hotSearch(theme),
if (_searchController.recordSearchHistory.value) _history(theme),
_history(theme),
if (_searchController.enableSearchRcmd) hotSearch(theme, false)
] else
Row(
@@ -97,7 +97,6 @@ class _SearchPageState extends State<SearchPage> {
],
),
),
if (_searchController.recordSearchHistory.value)
Expanded(child: _history(theme)),
],
),
@@ -207,28 +206,6 @@ class _SearchPageState extends State<SearchPage> {
),
),
),
// deprecated
// SizedBox(
// height: 34,
// child: TextButton(
// onPressed: () => Get.toNamed('/dynTopicRcmd'),
// child: Row(
// children: [
// Text(
// '话题',
// strutStyle:
// const StrutStyle(leading: 0, height: 1),
// style: style,
// ),
// Icon(
// size: 18,
// Icons.keyboard_arrow_right,
// color: outline,
// ),
// ],
// ),
// ),
// ),
],
)
: text,
@@ -272,9 +249,13 @@ class _SearchPageState extends State<SearchPage> {
}
Widget _history(ThemeData theme) {
final secondary = theme.colorScheme.secondary;
return Obx(
() => Padding(
() {
if (_searchController.historyList.isEmpty) {
return const SizedBox.shrink();
}
final secondary = theme.colorScheme.secondary;
return Padding(
padding: EdgeInsets.fromLTRB(
10,
context.orientation == Orientation.landscape
@@ -288,7 +269,6 @@ class _SearchPageState extends State<SearchPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (_searchController.historyList.isNotEmpty)
Padding(
padding: const EdgeInsets.fromLTRB(6, 0, 6, 6),
child: Row(
@@ -301,28 +281,30 @@ class _SearchPageState extends State<SearchPage> {
),
const SizedBox(width: 12),
Obx(
() => SizedBox(
() {
bool enable =
_searchController.recordSearchHistory.value;
return SizedBox(
width: 34,
height: 34,
child: IconButton(
iconSize: 22,
tooltip: _searchController.recordSearchHistory.value
? '记录搜索'
: '无痕搜索',
icon: _searchController.recordSearchHistory.value
tooltip: enable ? '记录搜索' : '无痕搜索',
icon: enable
? historyIcon(theme)
: historyIcon(theme).disable(),
style: IconButton.styleFrom(padding: EdgeInsets.zero),
style:
IconButton.styleFrom(padding: EdgeInsets.zero),
onPressed: () {
enable = !enable;
_searchController.recordSearchHistory.value =
!_searchController.recordSearchHistory.value;
enable;
GStorage.setting.put(
SettingBoxKey.recordSearchHistory,
_searchController.recordSearchHistory.value,
);
SettingBoxKey.recordSearchHistory, enable);
},
),
),
);
},
),
const Spacer(),
SizedBox(
@@ -351,8 +333,7 @@ class _SearchPageState extends State<SearchPage> {
],
),
),
Obx(
() => Wrap(
Wrap(
spacing: 8,
runSpacing: 8,
direction: Axis.horizontal,
@@ -367,10 +348,10 @@ class _SearchPageState extends State<SearchPage> {
)
.toList(),
),
),
],
),
),
);
},
);
}

View File

@@ -13,6 +13,4 @@ enum PlaySpeed {
final double value;
const PlaySpeed(this.value);
String get desc => value == 1.0 ? '正常' : value.toString();
}

View File

@@ -693,6 +693,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
color: Colors.white,
fontSize: 12,
);
return LayoutBuilder(
builder: (context, constraints) {
final maxWidth = constraints.maxWidth;
final maxHeight = constraints.maxHeight;
return Stack(
fit: StackFit.passthrough,
key: _playerKey,
@@ -720,8 +724,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// 如果起点太靠上则屏蔽
if (details.localFocalPoint.dy < 40) return;
if (details.localFocalPoint.dx < 40) return;
if (details.localFocalPoint.dx > context.width - 40) return;
if (details.localFocalPoint.dy > context.height - 40) return;
if (details.localFocalPoint.dx > maxWidth - 40) return;
if (details.localFocalPoint.dy > maxHeight - 40) return;
if (details.pointerCount == 2) {
interacting = true;
}
@@ -737,7 +741,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
if (interacting || _initialFocalPoint == Offset.zero) return;
Offset cumulativeDelta =
details.localFocalPoint - _initialFocalPoint;
if (details.pointerCount == 2 && cumulativeDelta.distance < 1.5) {
if (details.pointerCount == 2 &&
cumulativeDelta.distance < 1.5) {
interacting = true;
_gestureType = null;
return;
@@ -746,12 +751,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
/// 锁定时禁用
if (plPlayerController.controlsLock.value) return;
RenderBox renderBox =
_playerKey.currentContext!.findRenderObject() as RenderBox;
if (_gestureType == null) {
if (cumulativeDelta.distance < 1) return;
if (cumulativeDelta.dx.abs() > 3 * cumulativeDelta.dy.abs()) {
if (cumulativeDelta.dx.abs() >
3 * cumulativeDelta.dy.abs()) {
_gestureType = 'horizontal';
} else if (cumulativeDelta.dy.abs() >
3 * cumulativeDelta.dx.abs()) {
@@ -762,9 +765,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// _gestureType = 'vertical';
final double totalWidth = renderBox.size.width;
final double tapPosition = details.localFocalPoint.dx;
final double sectionWidth = totalWidth / 3;
final double sectionWidth = maxWidth / 3;
if (tapPosition < sectionWidth) {
if (!plPlayerController.enableSlideVolumeBrightness) {
return;
@@ -797,17 +799,18 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
final int curSliderPosition =
plPlayerController.sliderPosition.value.inMilliseconds;
final double width = renderBox.size.width;
final Duration pos = Duration(
milliseconds: curSliderPosition +
(plPlayerController.sliderScale * delta.dx / width)
(plPlayerController.sliderScale *
delta.dx /
maxWidth)
.round()); // TODO
final Duration result =
pos.clamp(Duration.zero, plPlayerController.duration.value);
final height = renderBox.size.height * 0.125;
final Duration result = pos.clamp(
Duration.zero, plPlayerController.duration.value);
final height = maxHeight * 0.125;
if (details.localFocalPoint.dy <= height &&
(details.localFocalPoint.dx >= width * 0.875 ||
details.localFocalPoint.dx <= width * 0.125)) {
(details.localFocalPoint.dx >= maxWidth * 0.875 ||
details.localFocalPoint.dx <= maxWidth * 0.125)) {
plPlayerController.cancelSeek = true;
plPlayerController.showPreview.value = false;
if (plPlayerController.hasToast != true) {
@@ -849,10 +852,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
if (plPlayerController.showSeekPreview &&
plPlayerController.cancelSeek != true) {
try {
plPlayerController.previewDx.value = result.inMilliseconds /
plPlayerController.previewDx.value =
result.inMilliseconds /
plPlayerController
.durationSeconds.value.inMilliseconds *
renderBox.size.width;
maxWidth;
if (!plPlayerController.showPreview.value) {
plPlayerController.showPreview.value = true;
}
@@ -860,7 +864,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
} else if (_gestureType == 'left') {
// 左边区域 👈
final double level = renderBox.size.height * 3;
final double level = maxHeight * 3;
final double brightness =
_brightnessValue.value - delta.dy / level;
final double result = brightness.clamp(0.0, 1.0);
@@ -895,10 +899,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
} else if (_gestureType == 'right') {
// 右边区域
final double level = renderBox.size.height * 0.5;
final double level = maxHeight * 0.5;
EasyThrottle.throttle(
'setVolume', const Duration(milliseconds: 20), () {
final double volume = _volumeValue.value - delta.dy / level;
final double volume =
_volumeValue.value - delta.dy / level;
final double result = volume.clamp(0.0, 1.0);
setVolume(result);
});
@@ -942,11 +947,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
!plPlayerController.enableSlideFS) {
return;
}
RenderBox renderBox =
_playerKey.currentContext!.findRenderObject() as RenderBox;
final double totalWidth = renderBox.size.width;
final double tapPosition = details.localPosition.dx;
final double sectionWidth = totalWidth / 3;
final double sectionWidth = maxWidth / 3;
late String gestureType;
if (tapPosition < sectionWidth) {
if (!plPlayerController.enableSlideVolumeBrightness) {
@@ -975,7 +977,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
if (_gestureType == 'left') {
// 左边区域 👈
final double level = renderBox.size.height * 3;
final double level = maxHeight * 3;
final double brightness =
_brightnessValue.value - details.delta.dy / level;
final double result = brightness.clamp(0.0, 1.0);
@@ -1009,7 +1011,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
} else if (_gestureType == 'right') {
// 右边区域
final double level = renderBox.size.height * 0.5;
final double level = maxHeight * 0.5;
EasyThrottle.throttle(
'setVolume', const Duration(milliseconds: 20), () {
final double volume =
@@ -1036,11 +1038,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
doubleTapFuc('center');
return;
}
RenderBox renderBox =
_playerKey.currentContext!.findRenderObject() as RenderBox;
final double totalWidth = renderBox.size.width;
final double tapPosition = details.localPosition.dx;
final double sectionWidth = totalWidth / 4;
final double sectionWidth = maxWidth / 4;
String type = 'left';
if (tapPosition < sectionWidth) {
type = 'left';
@@ -1074,7 +1073,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
translation: const Offset(0.0, 0.3), // 上下偏移量(负数向上偏移)
child: AnimatedOpacity(
curve: Curves.easeInOut,
opacity: plPlayerController.longPressStatus.value ? 1.0 : 0.0,
opacity:
plPlayerController.longPressStatus.value ? 1.0 : 0.0,
duration: const Duration(milliseconds: 150),
child: Container(
alignment: Alignment.center,
@@ -1088,8 +1088,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: Obx(
() => Text(
'${plPlayerController.enableAutoLongPressSpeed ? (plPlayerController.longPressStatus.value ? plPlayerController.lastPlaybackSpeed : plPlayerController.playbackSpeed) * 2 : plPlayerController.longPressSpeed}倍速中',
style:
const TextStyle(color: Colors.white, fontSize: 13),
style: const TextStyle(
color: Colors.white, fontSize: 13),
),
),
),
@@ -1109,7 +1109,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: Obx(
() => AnimatedOpacity(
curve: Curves.easeInOut,
opacity: plPlayerController.isSliderMoving.value ? 1.0 : 0.0,
opacity:
plPlayerController.isSliderMoving.value ? 1.0 : 0.0,
duration: const Duration(milliseconds: 150),
child: IntrinsicWidth(
child: Container(
@@ -1135,13 +1136,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
const SizedBox(width: 2),
Obx(
() => Text(
plPlayerController
.durationSeconds.value.inMinutes >=
plPlayerController.durationSeconds.value
.inMinutes >=
60
? printDurationWithHours(
plPlayerController.durationSeconds.value)
: printDuration(
plPlayerController.durationSeconds.value),
plPlayerController
.durationSeconds.value)
: printDuration(plPlayerController
.durationSeconds.value),
style: textStyle,
),
),
@@ -1166,8 +1168,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
opacity: _volumeIndicator.value ? 1.0 : 0.0,
duration: const Duration(milliseconds: 150),
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 5),
decoration: const BoxDecoration(
color: Color(0x88000000),
borderRadius: BorderRadius.all(Radius.circular(64)),
@@ -1212,8 +1214,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
opacity: _brightnessIndicator.value ? 1.0 : 0.0,
duration: const Duration(milliseconds: 150),
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 5),
decoration: const BoxDecoration(
color: Color(0x88000000),
borderRadius: BorderRadius.all(Radius.circular(64)),
@@ -1305,12 +1307,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: FilledButton.tonal(
style: FilledButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
backgroundColor: theme.colorScheme.secondaryContainer
backgroundColor: theme
.colorScheme.secondaryContainer
.withValues(alpha: 0.8),
visualDensity: VisualDensity.compact,
padding: const EdgeInsets.all(15),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6)),
borderRadius:
BorderRadius.all(Radius.circular(6)),
),
),
onPressed: () async {
@@ -1346,8 +1350,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
/// 进度条 live模式下禁用
Obx(
() {
final int value = plPlayerController.sliderPositionSeconds.value;
final int max = plPlayerController.durationSeconds.value.inSeconds;
final int value =
plPlayerController.sliderPositionSeconds.value;
final int max =
plPlayerController.durationSeconds.value.inSeconds;
final int buffer = plPlayerController.bufferedSeconds.value;
if (plPlayerController.showControls.value) {
return const SizedBox.shrink();
@@ -1405,7 +1411,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
timeLabelLocation: TimeLabelLocation.none,
thumbColor: primary,
barHeight: 3.5,
thumbRadius: draggingFixedProgressBar.value ? 7 : 2.5,
thumbRadius:
draggingFixedProgressBar.value ? 7 : 2.5,
// onDragStart: (duration) {
// feedBack();
// plPlayerController.onChangedSliderStart();
@@ -1443,7 +1450,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: CustomPaint(
size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: plPlayerController.segmentList,
segmentColors:
plPlayerController.segmentList,
),
),
),
@@ -1458,7 +1466,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: CustomPaint(
size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: plPlayerController.viewPointList,
segmentColors:
plPlayerController.viewPointList,
),
),
),
@@ -1489,15 +1498,16 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
SafeArea(
child: Obx(
() => Visibility(
visible:
plPlayerController.videoType.value != 'live' && isFullScreen,
visible: plPlayerController.videoType.value != 'live' &&
isFullScreen,
child: Align(
alignment: Alignment.centerLeft,
child: FractionalTranslation(
translation: const Offset(1, -0.4),
child: Visibility(
visible: plPlayerController.showControls.value &&
(isFullScreen || plPlayerController.controlsLock.value),
(isFullScreen ||
plPlayerController.controlsLock.value),
child: DecoratedBox(
decoration: const BoxDecoration(
color: Color(0x45000000),
@@ -1508,7 +1518,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
plPlayerController.controlsLock.value
? FontAwesomeIcons.lock
: FontAwesomeIcons.lockOpen,
semanticLabel: plPlayerController.controlsLock.value
semanticLabel:
plPlayerController.controlsLock.value
? '解锁'
: '锁定',
size: 15,
@@ -1561,13 +1572,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// title: const Text('点击保存'),
titlePadding: EdgeInsets.zero,
contentPadding: const EdgeInsets.all(8),
insetPadding:
EdgeInsets.only(left: context.width / 2),
insetPadding: EdgeInsets.only(
left: context.width / 2),
//移除圆角
shape: const RoundedRectangleBorder(),
content: GestureDetector(
onTap: () async {
String name = DateTime.now().toString();
String name =
DateTime.now().toString();
final SaveResult result =
await SaverGallery.saveImage(
value,
@@ -1588,8 +1600,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
},
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: context.width / 3,
maxHeight: context.height / 3,
maxWidth: maxWidth / 3,
maxHeight: maxHeight / 3,
),
child: Image.memory(value),
),
@@ -1624,7 +1636,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
colors: [Colors.black26, Colors.transparent],
),
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
child:
Column(mainAxisSize: MainAxisSize.min, children: [
Image.asset(
'assets/images/loading.gif',
height: 25,
@@ -1655,7 +1668,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
/// 点击 快进/快退
Obx(
() => _mountSeekBackwardButton.value || _mountSeekForwardButton.value
() => _mountSeekBackwardButton.value ||
_mountSeekForwardButton.value
? Positioned.fill(
child: Row(
children: [
@@ -1669,13 +1683,15 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: child,
),
child: BackwardSeekIndicator(
duration:
plPlayerController.fastForBackwardDuration,
duration: plPlayerController
.fastForBackwardDuration,
onSubmitted: (Duration value) {
_mountSeekBackwardButton.value = false;
final Player player = widget
.plPlayerController.videoPlayerController!;
Duration result = player.state.position - value;
.plPlayerController
.videoPlayerController!;
Duration result =
player.state.position - value;
result = result.clamp(
Duration.zero,
player.state.duration,
@@ -1701,13 +1717,15 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: child,
),
child: ForwardSeekIndicator(
duration:
plPlayerController.fastForBackwardDuration,
duration: plPlayerController
.fastForBackwardDuration,
onSubmitted: (Duration value) {
_mountSeekForwardButton.value = false;
final Player player = widget
.plPlayerController.videoPlayerController!;
Duration result = player.state.position + value;
.plPlayerController
.videoPlayerController!;
Duration result =
player.state.position + value;
result = result.clamp(
Duration.zero,
player.state.duration,
@@ -1729,6 +1747,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
],
);
},
);
}
}
@@ -1785,7 +1805,8 @@ Widget buildDmChart(
}
Widget buildSeekPreviewWidget(PlPlayerController plPlayerController) {
return Obx(() {
return Obx(
() {
if (!plPlayerController.showPreview.value ||
plPlayerController.videoShot?['status'] != true) {
if (plPlayerController.videoShot == null) {
@@ -1857,13 +1878,12 @@ Widget buildSeekPreviewWidget(PlPlayerController plPlayerController) {
);
} catch (e) {
if (kDebugMode) debugPrint('seek preview: $e');
return SizedBox.shrink(
key: ValueKey(plPlayerController.previewDx.value),
);
return const SizedBox.shrink();
}
},
);
});
},
);
}
Widget buildViewPointWidget(