mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: slide to dismiss subreply page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -2111,6 +2111,19 @@ List<SettingsModel> get extraSettings => [
|
|||||||
GStorage.collapsibleVideoPage = value;
|
GStorage.collapsibleVideoPage = value;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
SettingsModel(
|
||||||
|
settingsType: SettingsType.sw1tch,
|
||||||
|
title: '侧滑关闭二级评论页面',
|
||||||
|
leading: Transform.rotate(
|
||||||
|
angle: pi * 1.5,
|
||||||
|
child: Icon(Icons.touch_app),
|
||||||
|
),
|
||||||
|
setKey: SettingBoxKey.slideDismissReplyPage,
|
||||||
|
defaultVal: Platform.isIOS,
|
||||||
|
onChanged: (value) {
|
||||||
|
GStorage.slideDismissReplyPage = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
enableFeedback: true,
|
enableFeedback: true,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
|||||||
import 'package:PiliPlus/pages/video/detail/reply_new/reply_page.dart';
|
import 'package:PiliPlus/pages/video/detail/reply_new/reply_page.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/global_data.dart';
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -57,6 +58,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
late final _savedReplies = {};
|
late final _savedReplies = {};
|
||||||
late final itemPositionsListener = ItemPositionsListener.create();
|
late final itemPositionsListener = ItemPositionsListener.create();
|
||||||
late final _key = GlobalKey<ScaffoldState>();
|
late final _key = GlobalKey<ScaffoldState>();
|
||||||
|
late final _listKey = GlobalKey();
|
||||||
|
|
||||||
dynamic get firstFloor =>
|
dynamic get firstFloor =>
|
||||||
widget.firstFloor ?? _videoReplyReplyController.firstFloor;
|
widget.firstFloor ?? _videoReplyReplyController.firstFloor;
|
||||||
@@ -114,9 +116,73 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Offset? _downPos;
|
||||||
|
bool? _isSliding;
|
||||||
|
late final Rx<double> padding = 0.0.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return GStorage.slideDismissReplyPage
|
||||||
|
? GestureDetector(
|
||||||
|
onPanDown: (event) {
|
||||||
|
_downPos = event.localPosition;
|
||||||
|
},
|
||||||
|
onPanUpdate: (event) {
|
||||||
|
if (_isSliding == false) {
|
||||||
|
return;
|
||||||
|
} else if (_isSliding == null) {
|
||||||
|
if (_downPos != null && _downPos!.dx <= 25) {
|
||||||
|
Offset cumulativeDelta = event.localPosition - _downPos!;
|
||||||
|
if (cumulativeDelta.dx.abs() > 3 * cumulativeDelta.dy.abs()) {
|
||||||
|
_isSliding = true;
|
||||||
|
setState(() {
|
||||||
|
padding.value = event.localPosition.dx;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_isSliding = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (_isSliding == true) {
|
||||||
|
setState(() {
|
||||||
|
padding.value = event.localPosition.dx;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onPanCancel: () {
|
||||||
|
if (_isSliding == true) {
|
||||||
|
if (padding.value >= 100) {
|
||||||
|
Get.back();
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
padding.value = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_downPos = null;
|
||||||
|
_isSliding = null;
|
||||||
|
},
|
||||||
|
onPanEnd: (event) {
|
||||||
|
if (_isSliding == true) {
|
||||||
|
if (padding.value >= 100) {
|
||||||
|
Get.back();
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
padding.value = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_downPos = null;
|
||||||
|
_isSliding = null;
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(top: padding.value),
|
||||||
|
child: _buildPage,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: _buildPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget get _buildPage => Scaffold(
|
||||||
key: _key,
|
key: _key,
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Column(
|
body: Column(
|
||||||
@@ -128,7 +194,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
width: 1,
|
width: 1,
|
||||||
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
color:
|
||||||
|
Theme.of(context).dividerColor.withOpacity(0.1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -159,6 +226,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
() => Stack(
|
() => Stack(
|
||||||
children: [
|
children: [
|
||||||
ScrollablePositionedList.builder(
|
ScrollablePositionedList.builder(
|
||||||
|
key: _listKey,
|
||||||
itemPositionsListener: itemPositionsListener,
|
itemPositionsListener: itemPositionsListener,
|
||||||
itemCount: _itemCount(
|
itemCount: _itemCount(
|
||||||
_videoReplyReplyController.loadingState.value),
|
_videoReplyReplyController.loadingState.value),
|
||||||
@@ -213,7 +281,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
return _sortWidget;
|
return _sortWidget;
|
||||||
} else {
|
} else {
|
||||||
return _buildBody(
|
return _buildBody(
|
||||||
_videoReplyReplyController.loadingState.value,
|
_videoReplyReplyController
|
||||||
|
.loadingState.value,
|
||||||
index - 3);
|
index - 3);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -221,7 +290,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
return _sortWidget;
|
return _sortWidget;
|
||||||
} else {
|
} else {
|
||||||
return _buildBody(
|
return _buildBody(
|
||||||
_videoReplyReplyController.loadingState.value,
|
_videoReplyReplyController
|
||||||
|
.loadingState.value,
|
||||||
index - 1);
|
index - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +310,6 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
Widget get _sortWidget => Container(
|
Widget get _sortWidget => Container(
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|||||||
@@ -391,6 +391,9 @@ class GStorage {
|
|||||||
static bool collapsibleVideoPage = GStorage.setting
|
static bool collapsibleVideoPage = GStorage.setting
|
||||||
.get(SettingBoxKey.collapsibleVideoPage, defaultValue: true);
|
.get(SettingBoxKey.collapsibleVideoPage, defaultValue: true);
|
||||||
|
|
||||||
|
static bool slideDismissReplyPage = GStorage.setting
|
||||||
|
.get(SettingBoxKey.slideDismissReplyPage, defaultValue: Platform.isIOS);
|
||||||
|
|
||||||
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
||||||
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
||||||
|
|
||||||
@@ -645,6 +648,7 @@ class SettingBoxKey {
|
|||||||
springDescription = 'springDescription',
|
springDescription = 'springDescription',
|
||||||
collapsibleVideoPage = 'collapsibleVideoPage',
|
collapsibleVideoPage = 'collapsibleVideoPage',
|
||||||
enableHttp2 = 'enableHttp2',
|
enableHttp2 = 'enableHttp2',
|
||||||
|
slideDismissReplyPage = 'slideDismissReplyPage',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user