Merge branch 'main' into design
This commit is contained in:
@ -20,6 +20,7 @@ import 'package:pilipala/services/disable_battery_opt.dart';
|
||||
import 'package:pilipala/services/service_locator.dart';
|
||||
import 'package:pilipala/utils/app_scheme.dart';
|
||||
import 'package:pilipala/utils/data.dart';
|
||||
import 'package:pilipala/utils/global_data.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:media_kit/media_kit.dart'; // Provides [Player], [Media], [Playlist] etc.
|
||||
import 'package:pilipala/utils/recommend_filter.dart';
|
||||
@ -64,14 +65,8 @@ void main() async {
|
||||
},
|
||||
);
|
||||
|
||||
// 小白条、导航栏沉浸
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
systemNavigationBarDividerColor: Colors.transparent,
|
||||
statusBarColor: Colors.transparent,
|
||||
));
|
||||
Data.init();
|
||||
GlobalData();
|
||||
PiliSchame.init();
|
||||
DisableBatteryOpt();
|
||||
});
|
||||
@ -134,23 +129,21 @@ class MyApp extends StatelessWidget {
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
}
|
||||
// 图片缓存
|
||||
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;
|
||||
return GetMaterialApp(
|
||||
title: 'PiLiPaLa',
|
||||
theme: ThemeData(
|
||||
|
||||
final SnackBarThemeData snackBarThemeData = SnackBarThemeData(
|
||||
actionTextColor: darkColorScheme.primary,
|
||||
backgroundColor: darkColorScheme.secondaryContainer,
|
||||
closeIconColor: darkColorScheme.secondary,
|
||||
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
|
||||
elevation: 20,
|
||||
);
|
||||
|
||||
ThemeData themeData = ThemeData(
|
||||
// fontFamily: 'HarmonyOS',
|
||||
colorScheme: currentThemeValue == ThemeType.dark
|
||||
? darkColorScheme
|
||||
: lightColorScheme,
|
||||
useMaterial3: true,
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
actionTextColor: lightColorScheme.primary,
|
||||
backgroundColor: lightColorScheme.secondaryContainer,
|
||||
closeIconColor: lightColorScheme.secondary,
|
||||
contentTextStyle: TextStyle(color: lightColorScheme.secondary),
|
||||
elevation: 20,
|
||||
),
|
||||
snackBarTheme: snackBarThemeData,
|
||||
pageTransitionsTheme: const PageTransitionsTheme(
|
||||
builders: <TargetPlatform, PageTransitionsBuilder>{
|
||||
TargetPlatform.android: ZoomPageTransitionsBuilder(
|
||||
@ -158,21 +151,29 @@ class MyApp extends StatelessWidget {
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
// fontFamily: 'HarmonyOS',
|
||||
colorScheme: currentThemeValue == ThemeType.light
|
||||
? lightColorScheme
|
||||
: darkColorScheme,
|
||||
useMaterial3: true,
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
actionTextColor: darkColorScheme.primary,
|
||||
backgroundColor: darkColorScheme.secondaryContainer,
|
||||
closeIconColor: darkColorScheme.secondary,
|
||||
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
|
||||
elevation: 20,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// 小白条、导航栏沉浸
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||
systemNavigationBarColor: GlobalData().enableMYBar
|
||||
? const Color(0x00010000)
|
||||
: themeData.canvasColor,
|
||||
systemNavigationBarDividerColor: GlobalData().enableMYBar
|
||||
? const Color(0x00010000)
|
||||
: themeData.canvasColor,
|
||||
systemNavigationBarIconBrightness: currentThemeValue == ThemeType.dark
|
||||
? Brightness.light
|
||||
: Brightness.dark,
|
||||
statusBarColor: Colors.transparent,
|
||||
));
|
||||
|
||||
// 图片缓存
|
||||
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;
|
||||
return GetMaterialApp(
|
||||
title: 'PiLiPaLa',
|
||||
theme: themeData,
|
||||
darkTheme: themeData,
|
||||
localizationsDelegates: const [
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
|
||||
@ -10,6 +10,7 @@ import 'package:pilipala/pages/media/index.dart';
|
||||
import 'package:pilipala/pages/rank/index.dart';
|
||||
import 'package:pilipala/utils/event_bus.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/global_data.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import './controller.dart';
|
||||
|
||||
@ -29,7 +30,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
|
||||
int? _lastSelectTime; //上次点击时间
|
||||
Box setting = GStrorage.setting;
|
||||
late bool enableMYBar;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -37,7 +37,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
||||
_mainController.pageController =
|
||||
PageController(initialPage: _mainController.selectedIndex);
|
||||
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||
}
|
||||
|
||||
void setIndex(int value) async {
|
||||
@ -127,7 +126,8 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
},
|
||||
children: _mainController.pages,
|
||||
),
|
||||
bottomNavigationBar: StreamBuilder(
|
||||
bottomNavigationBar: _mainController.navigationBars.length > 1
|
||||
? StreamBuilder(
|
||||
stream: _mainController.hideTabBar
|
||||
? _mainController.bottomBarStream.stream.distinct()
|
||||
: StreamController<bool>.broadcast().stream,
|
||||
@ -137,8 +137,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
offset: Offset(0, snapshot.data ? 0 : 1),
|
||||
child: Obx(
|
||||
() => enableMYBar
|
||||
child: GlobalData().enableMYBar
|
||||
? NavigationBar(
|
||||
onDestinationSelected: (value) => setIndex(value),
|
||||
selectedIndex: _mainController.selectedIndex,
|
||||
@ -147,15 +146,15 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
return NavigationDestination(
|
||||
icon: Obx(
|
||||
() => Badge(
|
||||
label:
|
||||
_mainController.dynamicBadgeType.value ==
|
||||
label: _mainController
|
||||
.dynamicBadgeType.value ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType.value !=
|
||||
isLabelVisible: _mainController
|
||||
.dynamicBadgeType.value !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
@ -169,6 +168,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
)
|
||||
: BottomNavigationBar(
|
||||
currentIndex: _mainController.selectedIndex,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
onTap: (value) => setIndex(value),
|
||||
iconSize: 16,
|
||||
selectedFontSize: 12,
|
||||
@ -178,15 +178,15 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Obx(
|
||||
() => Badge(
|
||||
label:
|
||||
_mainController.dynamicBadgeType.value ==
|
||||
label: _mainController
|
||||
.dynamicBadgeType.value ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType.value !=
|
||||
isLabelVisible: _mainController
|
||||
.dynamicBadgeType.value !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
@ -198,10 +198,10 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
onTap: () => Get.toNamed('/navbarSetting'),
|
||||
title: Text('navbar设置', style: titleStyle),
|
||||
title: Text('底部导航栏设置', style: titleStyle),
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
ListTile(
|
||||
|
||||
@ -140,8 +140,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
future: _futureBuilderFuture,
|
||||
builder: (BuildContext context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
final Map data = snapshot.data as Map;
|
||||
if (data['status']) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
// 请求成功
|
||||
return Obx(
|
||||
() => SliverList(
|
||||
@ -199,7 +199,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
errMsg: data?['msg'] ?? '请求错误',
|
||||
fn: () => setState(() {}),
|
||||
);
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
|
||||
// 流
|
||||
appbarStreamListen() {
|
||||
appbarStream = StreamController<double>();
|
||||
appbarStream = StreamController<double>.broadcast();
|
||||
_extendNestCtr.addListener(
|
||||
() {
|
||||
final double offset = _extendNestCtr.position.pixels;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@ -11,7 +13,8 @@ class DownloadUtils {
|
||||
static Future<bool> requestStoragePer() async {
|
||||
await Permission.storage.request();
|
||||
PermissionStatus status = await Permission.storage.status;
|
||||
if (status == PermissionStatus.denied) {
|
||||
if (status == PermissionStatus.denied ||
|
||||
status == PermissionStatus.permanentlyDenied) {
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
@ -40,7 +43,8 @@ class DownloadUtils {
|
||||
static Future<bool> requestPhotoPer() async {
|
||||
await Permission.photos.request();
|
||||
PermissionStatus status = await Permission.photos.status;
|
||||
if (status == PermissionStatus.denied) {
|
||||
if (status == PermissionStatus.denied ||
|
||||
status == PermissionStatus.permanentlyDenied) {
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
@ -68,9 +72,20 @@ class DownloadUtils {
|
||||
static Future<bool> downloadImg(String imgUrl,
|
||||
{String imgType = 'cover'}) async {
|
||||
try {
|
||||
if (!Platform.isAndroid || !await requestPhotoPer()) {
|
||||
return false;
|
||||
}
|
||||
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||
if (androidInfo.version.sdkInt <= 32) {
|
||||
if (!await requestStoragePer()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!await requestPhotoPer()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SmartDialog.showLoading(msg: '保存中');
|
||||
var response = await Dio()
|
||||
.get(imgUrl, options: Options(responseType: ResponseType.bytes));
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import '../models/common/index.dart';
|
||||
|
||||
Box setting = GStrorage.setting;
|
||||
|
||||
class GlobalData {
|
||||
int imgQuality = 10;
|
||||
FullScreenGestureMode fullScreenGestureMode =
|
||||
FullScreenGestureMode.values.last;
|
||||
bool enablePlayerControlAnimation = true;
|
||||
final bool enableMYBar =
|
||||
setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||
|
||||
// 私有构造函数
|
||||
GlobalData._();
|
||||
|
||||
Reference in New Issue
Block a user