mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-05 09:37:52 +08:00
tweaks (#1862)
* opt: linter * tweaks * opt: TopImage * update * remove repaintBoundary [skip ci] --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
99128b2641
commit
6cda3a1880
@@ -6,7 +6,6 @@ import 'package:PiliPlus/grpc/dm.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_source.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/danmaku_options.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/path_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
@@ -68,8 +67,8 @@ class PlDanmakuController {
|
||||
if (elems.isEmpty) return;
|
||||
final uniques = HashMap<String, DanmakuElem>();
|
||||
|
||||
final shouldFilter = _plPlayerController.filters.count != 0;
|
||||
final danmakuWeight = DanmakuOptions.danmakuWeight;
|
||||
final filters = _plPlayerController.filters;
|
||||
final shouldFilter = filters.count != 0;
|
||||
for (final element in elems) {
|
||||
if (_isLogin) {
|
||||
element.isSelf = element.midHash == _plPlayerController.midHash;
|
||||
@@ -86,8 +85,7 @@ class PlDanmakuController {
|
||||
}
|
||||
}
|
||||
|
||||
if (element.weight < danmakuWeight ||
|
||||
(shouldFilter && _plPlayerController.filters.remove(element))) {
|
||||
if (shouldFilter && filters.remove(element)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ class _MemberPageState extends State<MemberPage> {
|
||||
late final String _heroTag;
|
||||
late final MemberController _userController;
|
||||
PageController? _headerController;
|
||||
PageController get headerController => _headerController ??= PageController();
|
||||
PageController getHeaderController() =>
|
||||
_headerController ??= PageController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -367,7 +368,7 @@ class _MemberPageState extends State<MemberPage> {
|
||||
onFollow: () => _userController.onFollow(context),
|
||||
live: _userController.live,
|
||||
silence: _userController.silence,
|
||||
headerControllerBuilder: () => headerController,
|
||||
headerControllerBuilder: getHeaderController,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -458,7 +458,7 @@ class UserInfoCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
HeaderLayoutWidget(
|
||||
header: imgUrls != null
|
||||
header: imgUrls != null && imgUrls.isNotEmpty
|
||||
? _buildCollectionHeader(context, scheme, isLight, imgUrls, width)
|
||||
: _buildHeader(
|
||||
context,
|
||||
@@ -491,12 +491,15 @@ class UserInfoCard extends StatelessWidget {
|
||||
double width,
|
||||
) {
|
||||
if (imgUrls.length == 1) {
|
||||
final img = imgUrls.first;
|
||||
return _buildHeader(
|
||||
context,
|
||||
isLight,
|
||||
width,
|
||||
imgUrls.single.cover,
|
||||
img.header,
|
||||
filter: false,
|
||||
fullCover: img.fullCover,
|
||||
alignment: Alignment(0.0, img.dy),
|
||||
);
|
||||
}
|
||||
final controller = headerControllerBuilder();
|
||||
@@ -505,7 +508,7 @@ class UserInfoCard extends StatelessWidget {
|
||||
behavior: .opaque,
|
||||
onTap: () => PageUtils.imageView(
|
||||
initialPage: controller.page?.round() ?? 0,
|
||||
imgList: imgUrls.map((e) => SourceModel(url: e.cover)).toList(),
|
||||
imgList: imgUrls.map((e) => SourceModel(url: e.fullCover)).toList(),
|
||||
onPageChanged: controller.jumpToPage,
|
||||
),
|
||||
child: Stack(
|
||||
@@ -520,14 +523,14 @@ class UserInfoCard extends StatelessWidget {
|
||||
itemBuilder: (context, index) {
|
||||
final img = imgUrls[index];
|
||||
return fromHero(
|
||||
tag: img.cover,
|
||||
tag: img.fullCover,
|
||||
child: CachedNetworkImage(
|
||||
fit: .cover,
|
||||
alignment: Alignment(0.0, img.dy),
|
||||
height: kHeaderHeight,
|
||||
width: width,
|
||||
memCacheWidth: memCacheWidth,
|
||||
imageUrl: ImageUtils.thumbnailUrl(img.cover),
|
||||
imageUrl: ImageUtils.thumbnailUrl(img.header),
|
||||
fadeInDuration: const Duration(milliseconds: 120),
|
||||
fadeOutDuration: const Duration(milliseconds: 120),
|
||||
placeholder: (_, _) =>
|
||||
@@ -557,14 +560,18 @@ class UserInfoCard extends StatelessWidget {
|
||||
double width,
|
||||
String imgUrl, {
|
||||
bool filter = true,
|
||||
String? fullCover,
|
||||
Alignment alignment = .center,
|
||||
}) {
|
||||
final img = fullCover ?? imgUrl;
|
||||
return GestureDetector(
|
||||
behavior: .opaque,
|
||||
onTap: () => PageUtils.imageView(imgList: [SourceModel(url: imgUrl)]),
|
||||
onTap: () => PageUtils.imageView(imgList: [SourceModel(url: img)]),
|
||||
child: fromHero(
|
||||
tag: imgUrl,
|
||||
tag: img,
|
||||
child: CachedNetworkImage(
|
||||
fit: .cover,
|
||||
alignment: alignment,
|
||||
height: kHeaderHeight,
|
||||
width: width,
|
||||
memCacheWidth: width.cacheSize(context),
|
||||
@@ -760,7 +767,8 @@ class _HeaderIndicatorState extends State<HeaderIndicator> {
|
||||
}
|
||||
|
||||
void _updateProgress() {
|
||||
_progress = ((widget.pageController.page ?? 0) + 1) / widget.length;
|
||||
_progress = (widget.pageController.page ?? 0) / (widget.length - 1);
|
||||
assert(_progress.isFinite && 0 <= _progress && _progress <= 1);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
@@ -292,14 +289,15 @@ class _SavePanelState extends State<SavePanel> {
|
||||
}
|
||||
SmartDialog.showLoading();
|
||||
try {
|
||||
RenderRepaintBoundary boundary =
|
||||
final boundary =
|
||||
boundaryKey.currentContext!.findRenderObject()
|
||||
as RenderRepaintBoundary;
|
||||
final image = await boundary.toImage(pixelRatio: 3);
|
||||
ByteData? byteData = await image.toByteData(format: ImageByteFormat.png);
|
||||
Uint8List pngBytes = byteData!.buffer.asUint8List();
|
||||
String picName =
|
||||
"${Constants.appName}_${DateFormat('yyyyMMddHHmmss').format(DateTime.now())}";
|
||||
final byteData = await image.toByteData(format: .png);
|
||||
image.dispose();
|
||||
final pngBytes = byteData!.buffer.asUint8List();
|
||||
final picName =
|
||||
"${Constants.appName}_${itemType}_${DateFormat('yyyyMMddHHmmss').format(DateTime.now())}";
|
||||
if (isShare) {
|
||||
Get.back();
|
||||
SmartDialog.dismiss();
|
||||
@@ -350,8 +348,7 @@ class _SavePanelState extends State<SavePanel> {
|
||||
top: 12 + padding.top,
|
||||
bottom: 80 + padding.bottom,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {},
|
||||
child: Listener(
|
||||
child: Container(
|
||||
width: maxWidth,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
@@ -361,7 +358,7 @@ class _SavePanelState extends State<SavePanel> {
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
borderRadius: const .all(.circular(12)),
|
||||
),
|
||||
child: AnimatedSize(
|
||||
curve: Curves.easeInOut,
|
||||
@@ -393,40 +390,33 @@ class _SavePanelState extends State<SavePanel> {
|
||||
Container(
|
||||
height: 81,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
),
|
||||
padding: const EdgeInsets.all(8),
|
||||
margin: const .symmetric(horizontal: 12),
|
||||
padding: const .all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onInverseSurface,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
borderRadius: const .all(.circular(8)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: cover!,
|
||||
height: coverSize,
|
||||
width: coverType == _CoverType.def16_9
|
||||
width: coverType == .def16_9
|
||||
? coverSize *
|
||||
StyleString.aspectRatio16x9
|
||||
: coverSize,
|
||||
quality: 100,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(6),
|
||||
),
|
||||
borderRadius: const .all(.circular(6)),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
Text(
|
||||
'$title\n',
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
),
|
||||
if (pubdate != null) ...[
|
||||
const Spacer(),
|
||||
@@ -466,8 +456,7 @@ class _SavePanelState extends State<SavePanel> {
|
||||
Text(
|
||||
'@$uname',
|
||||
maxLines: 1,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
style: TextStyle(
|
||||
color: theme
|
||||
.colorScheme
|
||||
@@ -485,9 +474,7 @@ class _SavePanelState extends State<SavePanel> {
|
||||
),
|
||||
Text(
|
||||
DateFormatUtils.longFormatDs
|
||||
.format(
|
||||
DateTime.now(),
|
||||
),
|
||||
.format(.now()),
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
@@ -504,12 +491,8 @@ class _SavePanelState extends State<SavePanel> {
|
||||
child: Container(
|
||||
width: 88,
|
||||
height: 88,
|
||||
margin: const EdgeInsets.all(
|
||||
12,
|
||||
),
|
||||
padding: const EdgeInsets.all(
|
||||
3,
|
||||
),
|
||||
margin: const .all(12),
|
||||
padding: const .all(3),
|
||||
color: theme.brightness.isDark
|
||||
? Colors.white
|
||||
: theme.colorScheme.surface,
|
||||
|
||||
@@ -202,9 +202,9 @@ mixin HeaderMixin<T extends StatefulWidget> on State<T> {
|
||||
data: sliderTheme,
|
||||
child: Slider(
|
||||
min: 0,
|
||||
max: 10,
|
||||
max: 11,
|
||||
value: DanmakuOptions.danmakuWeight.toDouble(),
|
||||
divisions: 10,
|
||||
divisions: 11,
|
||||
label: DanmakuOptions.danmakuWeight.toString(),
|
||||
onChanged: updateDanmakuWeight,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user