mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-28 05:10:14 +08:00
@@ -14,6 +14,13 @@ extension IterableExt<T> on Iterable<T> {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
T? firstWhereOrNull(bool Function(T element) test) {
|
||||
for (var element in this) {
|
||||
if (test(element)) return element;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
extension ListExt<T> on List<T> {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:math' show pow;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
extension ImageExtension on num {
|
||||
@@ -13,3 +15,10 @@ extension IntExt on int? {
|
||||
int? operator +(int other) => this == null ? null : this! + other;
|
||||
int? operator -(int other) => this == null ? null : this! - other;
|
||||
}
|
||||
|
||||
extension DoubleExt on double {
|
||||
double toPrecision(int fractionDigits) {
|
||||
var mod = pow(10, fractionDigits.toDouble()).toDouble();
|
||||
return ((this * mod).round().toDouble() / mod);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:PiliPlus/utils/extension/num_ext.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode, debugPrint;
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
|
||||
abstract final class NumUtils {
|
||||
static final _numRegExp = RegExp(r'([\d\.]+)([千万亿])?');
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||
import 'package:PiliPlus/pages/common/publish/publish_route.dart';
|
||||
import 'package:PiliPlus/pages/contact/view.dart';
|
||||
import 'package:PiliPlus/pages/fav_panel/view.dart';
|
||||
import 'package:PiliPlus/pages/share/view.dart';
|
||||
@@ -20,6 +21,7 @@ import 'package:PiliPlus/services/shutdown_timer_service.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/extension.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
@@ -32,7 +34,7 @@ import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show FilteringTextInputFormatter;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
abstract final class PageUtils {
|
||||
@@ -652,49 +654,50 @@ abstract final class PageUtils {
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
Get.generalDialog(
|
||||
barrierLabel: '',
|
||||
barrierDismissible: true,
|
||||
pageBuilder: (context, animation, secondaryAnimation) {
|
||||
if (context.isPortrait) {
|
||||
Get.key.currentState!.push(
|
||||
PublishRoute(
|
||||
pageBuilder: (context, animation, secondaryAnimation) {
|
||||
if (context.isPortrait) {
|
||||
return SafeArea(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: 0.7,
|
||||
widthFactor: 1.0,
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: isFullScreen() && padding != null
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(bottom: padding),
|
||||
child: child,
|
||||
)
|
||||
: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
return SafeArea(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: 0.7,
|
||||
widthFactor: 1.0,
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: isFullScreen() && padding != null
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(bottom: padding),
|
||||
child: child,
|
||||
)
|
||||
: child,
|
||||
widthFactor: 0.5,
|
||||
heightFactor: 1.0,
|
||||
alignment: Alignment.centerRight,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
return SafeArea(
|
||||
child: FractionallySizedBox(
|
||||
widthFactor: 0.5,
|
||||
heightFactor: 1.0,
|
||||
alignment: Alignment.centerRight,
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 350),
|
||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||
final begin = context.isPortrait
|
||||
? const Offset(0.0, 1.0)
|
||||
: const Offset(1.0, 0.0);
|
||||
return SlideTransition(
|
||||
position: animation.drive(
|
||||
Tween(
|
||||
begin: begin,
|
||||
end: Offset.zero,
|
||||
).chain(CurveTween(curve: Curves.easeInOut)),
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 350),
|
||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||
Offset begin = context.isPortrait
|
||||
? const Offset(0.0, 1.0)
|
||||
: const Offset(1.0, 0.0);
|
||||
var tween = Tween(
|
||||
begin: begin,
|
||||
end: Offset.zero,
|
||||
).chain(CurveTween(curve: Curves.easeInOut));
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
routeSettings: RouteSettings(arguments: Get.arguments),
|
||||
);
|
||||
},
|
||||
settings: RouteSettings(arguments: Get.arguments),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,9 +99,10 @@ abstract final class ReplyUtils {
|
||||
await Future.delayed(const Duration(seconds: 8));
|
||||
}
|
||||
void showReplyCheckResult(String message, {bool isBan = false}) {
|
||||
Get.dialog(
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
barrierDismissible: isManual,
|
||||
AlertDialog(
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('评论检查结果'),
|
||||
content: SelectableText(message),
|
||||
actions: [
|
||||
|
||||
@@ -34,7 +34,7 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gt3_flutter_plugin/gt3_flutter_plugin.dart';
|
||||
|
||||
abstract final class RequestUtils {
|
||||
@@ -310,9 +310,10 @@ abstract final class RequestUtils {
|
||||
}
|
||||
var res = await DynamicsHttp.dynamicDetail(id: id, clearCookie: true);
|
||||
final isSuccess = res.isSuccess;
|
||||
Get.dialog(
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
barrierDismissible: isManual,
|
||||
AlertDialog(
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('动态检查结果'),
|
||||
content: SelectableText(
|
||||
'${isSuccess ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'}${dynText != null ? ' \n\n动态内容: $dynText' : ''}',
|
||||
@@ -534,8 +535,9 @@ abstract final class RequestUtils {
|
||||
}
|
||||
|
||||
if (PlatformUtils.isDesktop) {
|
||||
final json = await Get.dialog<Map<String, dynamic>>(
|
||||
GeetestWebviewDialog(gt!, challenge!),
|
||||
final json = await showDialog<Map<String, dynamic>>(
|
||||
context: Get.context!,
|
||||
builder: (context) => GeetestWebviewDialog(gt!, challenge!),
|
||||
);
|
||||
if (json != null) {
|
||||
captchaData
|
||||
@@ -543,7 +545,7 @@ abstract final class RequestUtils {
|
||||
..seccode = json['geetest_seccode']
|
||||
..geetest = GeetestData(
|
||||
challenge: json['geetest_challenge'],
|
||||
gt: gt,
|
||||
gt: gt!,
|
||||
);
|
||||
gaiaVgateValidate();
|
||||
}
|
||||
@@ -651,8 +653,9 @@ abstract final class RequestUtils {
|
||||
if (res.isSuccess) {
|
||||
final data = res.data;
|
||||
final show = !data.name.isNullOrEmpty;
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) => AlertDialog(
|
||||
title: SelectableText(
|
||||
show ? data.name! : data.rejectPage?.title ?? '',
|
||||
),
|
||||
|
||||
@@ -33,7 +33,7 @@ import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user