mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
tweaks (#1252)
* opt: cache * opt: MediaListPanel * feat: nested replyreply panel * tweaks * opt: abstract class * opt: PageStorageKey * opt: contextExt * opt: EpisodePanel * opt * opt: context instead GlobalKey * feat: jump to reply * refa: reply_reply * fix: jump * fix: index * update Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * opt: keepalive * reapply: nested replyreply * mod: spacing * opt: CommonSlidePageState * fix drag bottomsheet Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * opt reply jump Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * opt reply2reply Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * tweaks Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * tweaks Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * reapply: jumpToReply * fix: padding * fix: anim * fix some panels Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * opt: implements Scaffold * opt: remove keepalive * revert: GlobalKey * tweaks Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
b9a55ccbce
commit
37fb63c3b1
@@ -23,6 +23,7 @@ import 'package:PiliPlus/common/widgets/custom_layout.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/common/image_preview_type.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
@@ -64,7 +65,7 @@ class CustomGridView extends StatelessWidget {
|
||||
required this.picArr,
|
||||
this.onViewImage,
|
||||
this.onDismissed,
|
||||
this.callback,
|
||||
this.fullScreen = false,
|
||||
});
|
||||
|
||||
final double maxWidth;
|
||||
@@ -72,29 +73,36 @@ class CustomGridView extends StatelessWidget {
|
||||
final List<ImageModel> picArr;
|
||||
final VoidCallback? onViewImage;
|
||||
final ValueChanged<int>? onDismissed;
|
||||
final Function(List<String>, int)? callback;
|
||||
final bool fullScreen;
|
||||
|
||||
void onTap(int index) {
|
||||
if (callback != null) {
|
||||
callback!(picArr.map((item) => item.url).toList(), index);
|
||||
static bool horizontalPreview = Pref.horizontalPreview;
|
||||
|
||||
void onTap(BuildContext context, int index) {
|
||||
final imgList = picArr.map(
|
||||
(item) {
|
||||
bool isLive = item.isLivePhoto;
|
||||
return SourceModel(
|
||||
sourceType: isLive ? SourceType.livePhoto : SourceType.networkImage,
|
||||
url: item.url,
|
||||
liveUrl: isLive ? item.liveUrl : null,
|
||||
width: isLive ? item.width.toInt() : null,
|
||||
height: isLive ? item.height.toInt() : null,
|
||||
);
|
||||
},
|
||||
).toList();
|
||||
onViewImage?.call();
|
||||
if (horizontalPreview &&
|
||||
!fullScreen &&
|
||||
!context.mediaQuerySize.isPortrait) {
|
||||
PageUtils.onHorizontalPreview(
|
||||
context,
|
||||
imgList,
|
||||
index,
|
||||
);
|
||||
} else {
|
||||
onViewImage?.call();
|
||||
PageUtils.imageView(
|
||||
initialPage: index,
|
||||
imgList: picArr.map(
|
||||
(item) {
|
||||
bool isLive = item.isLivePhoto;
|
||||
return SourceModel(
|
||||
sourceType: isLive
|
||||
? SourceType.livePhoto
|
||||
: SourceType.networkImage,
|
||||
url: item.url,
|
||||
liveUrl: isLive ? item.liveUrl : null,
|
||||
width: isLive ? item.width.toInt() : null,
|
||||
height: isLive ? item.height.toInt() : null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
imgList: imgList,
|
||||
onDismissed: onDismissed,
|
||||
);
|
||||
}
|
||||
@@ -195,7 +203,7 @@ class CustomGridView extends StatelessWidget {
|
||||
child: Hero(
|
||||
tag: item.url,
|
||||
child: GestureDetector(
|
||||
onTap: () => onTap(index),
|
||||
onTap: () => onTap(context, index),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.center,
|
||||
|
||||
@@ -246,7 +246,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
||||
children: [
|
||||
InteractiveViewerBoundary(
|
||||
controller: _transformationController,
|
||||
boundaryWidth: MediaQuery.sizeOf(context).width,
|
||||
boundaryWidth: MediaQuery.widthOf(context),
|
||||
onScaleChanged: _onScaleChanged,
|
||||
onLeftBoundaryHit: _onLeftBoundaryHit,
|
||||
onRightBoundaryHit: _onRightBoundaryHit,
|
||||
|
||||
@@ -22,6 +22,14 @@ class _KeepAliveWrapperState extends State<KeepAliveWrapper>
|
||||
return widget.builder(context);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(KeepAliveWrapper oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.wantKeepAlive != widget.wantKeepAlive) {
|
||||
updateKeepAlive();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => widget.wantKeepAlive;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,9 @@ abstract class MarqueeRender extends RenderBox
|
||||
if (value._ticker != null) {
|
||||
value._ticker!.absorbTicker(_ticker._ticker!);
|
||||
} else {
|
||||
value.createTicker(_onTick);
|
||||
value
|
||||
..createTicker(_onTick)
|
||||
..initStart();
|
||||
}
|
||||
}
|
||||
_ticker.cancel();
|
||||
@@ -223,7 +225,9 @@ abstract class MarqueeRender extends RenderBox
|
||||
|
||||
if (_distance > 0) {
|
||||
updateSize();
|
||||
_ticker.createTicker(_onTick);
|
||||
_ticker
|
||||
..createTicker(_onTick)
|
||||
..initStart();
|
||||
} else {
|
||||
_ticker.cancel();
|
||||
}
|
||||
@@ -394,13 +398,29 @@ class _MarqueeSimulation extends Simulation {
|
||||
);
|
||||
}
|
||||
|
||||
class ContextSingleTicker {
|
||||
class ContextSingleTicker implements TickerProvider {
|
||||
Ticker? _ticker;
|
||||
BuildContext context;
|
||||
final bool autoStart;
|
||||
|
||||
ContextSingleTicker(this.context);
|
||||
ContextSingleTicker(this.context, {this.autoStart = true});
|
||||
|
||||
void createTicker(TickerCallback onTick) {
|
||||
void initStart() {
|
||||
if (autoStart) {
|
||||
_ticker?.start();
|
||||
}
|
||||
}
|
||||
|
||||
void startIfNeeded() {
|
||||
if (_ticker case final ticker?) {
|
||||
if (!ticker.isActive) {
|
||||
ticker.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Ticker createTicker(TickerCallback onTick) {
|
||||
assert(() {
|
||||
if (_ticker == null) {
|
||||
return true;
|
||||
@@ -422,10 +442,11 @@ class ContextSingleTicker {
|
||||
_ticker = Ticker(
|
||||
onTick,
|
||||
debugLabel: kDebugMode ? 'created by ${describeIdentity(this)}' : null,
|
||||
)..start();
|
||||
);
|
||||
_tickerModeNotifier = TickerMode.getNotifier(context)
|
||||
..addListener(updateTicker);
|
||||
updateTicker(); // Sets _ticker.mute correctly.
|
||||
return _ticker!;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
|
||||
1557
lib/common/widgets/scaffold/bottom_sheet.dart
Normal file
1557
lib/common/widgets/scaffold/bottom_sheet.dart
Normal file
File diff suppressed because it is too large
Load Diff
3556
lib/common/widgets/scaffold/scaffold.dart
Normal file
3556
lib/common/widgets/scaffold/scaffold.dart
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user