From 3b1d291037f47b148a43e13c9fb01506bb0ec4ba Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 11 Dec 2024 22:28:16 +0800 Subject: [PATCH] :bug: Bug fixes --- ios/Runner.xcodeproj/project.pbxproj | 2 +- lib/router.dart | 5 -- lib/widgets/attachment/attachment_list.dart | 4 +- lib/widgets/navigation/app_background.dart | 68 ++++++--------------- 4 files changed, 22 insertions(+), 57 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 63b82ff..d5776ee 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 70; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ diff --git a/lib/router.dart b/lib/router.dart index c8e353b..25a0b18 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -58,7 +58,6 @@ final _appRoutes = [ path: '/write/:mode', name: 'postEditor', builder: (context, state) => AppBackground( - isLessOptimization: true, child: PostEditorScreen( mode: state.pathParameters['mode']!, postEditId: int.tryParse( @@ -77,7 +76,6 @@ final _appRoutes = [ path: '/search', name: 'postSearch', builder: (context, state) => const AppBackground( - isLessOptimization: true, child: PostSearchScreen(), ), ), @@ -119,7 +117,6 @@ final _appRoutes = [ path: '/:scope/:alias', name: 'chatRoom', builder: (context, state) => AppBackground( - isLessOptimization: true, child: ChatRoomScreen( scope: state.pathParameters['scope']!, alias: state.pathParameters['alias']!, @@ -159,7 +156,6 @@ final _appRoutes = [ secondaryAnimation: secondaryAnimation, fillColor: Colors.transparent, child: AppBackground( - isLessOptimization: true, child: child, ), ); @@ -195,7 +191,6 @@ final _appRoutes = [ secondaryAnimation: secondaryAnimation, fillColor: Colors.transparent, child: AppBackground( - isLessOptimization: true, child: child, ), ); diff --git a/lib/widgets/attachment/attachment_list.dart b/lib/widgets/attachment/attachment_list.dart index eeddebc..c366a9b 100644 --- a/lib/widgets/attachment/attachment_list.dart +++ b/lib/widgets/attachment/attachment_list.dart @@ -130,7 +130,7 @@ class _AttachmentListState extends State { } return AspectRatio( - aspectRatio: widget.data.firstOrNull?.metadata['ratio'] ?? 1, + aspectRatio: (widget.data.firstOrNull?.metadata['ratio'] ?? 1).toDouble(), child: Container( constraints: BoxConstraints(maxHeight: constraints.maxHeight), child: ScrollConfiguration( @@ -142,7 +142,7 @@ class _AttachmentListState extends State { return Container( constraints: constraints, child: AspectRatio( - aspectRatio: widget.data[idx]?.metadata['ratio'] ?? 1, + aspectRatio: (widget.data[idx]?.metadata['ratio'] ?? 1).toDouble(), child: GestureDetector( onTap: () { context.pushTransparentRoute( diff --git a/lib/widgets/navigation/app_background.dart b/lib/widgets/navigation/app_background.dart index 3cf297a..5fd3b4b 100644 --- a/lib/widgets/navigation/app_background.dart +++ b/lib/widgets/navigation/app_background.dart @@ -7,12 +7,11 @@ import 'package:responsive_framework/responsive_framework.dart'; class AppBackground extends StatelessWidget { final Widget child; - final bool isLessOptimization; final bool isRoot; + const AppBackground({ super.key, required this.child, - this.isLessOptimization = false, this.isRoot = false, }); @@ -23,52 +22,25 @@ class AppBackground extends StatelessWidget { ) { final devicePixelRatio = MediaQuery.of(context).devicePixelRatio; - if (isLessOptimization) { - final size = MediaQuery.of(context).size; - return Container( - color: Theme.of(context).colorScheme.surface, - child: Container( - decoration: BoxDecoration( - backgroundBlendMode: BlendMode.darken, - color: Theme.of(context).colorScheme.surface, - image: DecorationImage( - opacity: 0.2, - image: ResizeImage( - FileImage(imageFile), - width: (size.width * devicePixelRatio).round(), - height: (size.height * devicePixelRatio).round(), - policy: ResizeImagePolicy.fit, - ), - fit: BoxFit.cover, - ), - ), - child: child, - ), - ); - } - + final size = MediaQuery.of(context).size; return Container( color: Theme.of(context).colorScheme.surface, - child: LayoutBuilder( - builder: (context, constraints) { - return Container( - decoration: BoxDecoration( - backgroundBlendMode: BlendMode.darken, - color: Theme.of(context).colorScheme.surface, - image: DecorationImage( - opacity: 0.2, - image: ResizeImage( - FileImage(imageFile), - width: (constraints.maxWidth * devicePixelRatio).round(), - height: (constraints.maxHeight * devicePixelRatio).round(), - policy: ResizeImagePolicy.fit, - ), - fit: BoxFit.cover, - ), + child: Container( + decoration: BoxDecoration( + backgroundBlendMode: BlendMode.darken, + color: Theme.of(context).colorScheme.surface, + image: DecorationImage( + opacity: 0.2, + image: ResizeImage( + FileImage(imageFile), + width: (size.width * devicePixelRatio).round(), + height: (size.height * devicePixelRatio).round(), + policy: ResizeImagePolicy.fit, ), - child: child, - ); - }, + fit: BoxFit.cover, + ), + ), + child: child, ), ); } @@ -77,11 +49,9 @@ class AppBackground extends StatelessWidget { Widget build(BuildContext context) { return ScaffoldMessenger( child: FutureBuilder( - future: - kIsWeb ? Future.value(null) : getApplicationDocumentsDirectory(), + future: kIsWeb ? Future.value(null) : getApplicationDocumentsDirectory(), builder: (context, snapshot) { - if (isRoot || - ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) { + if (isRoot || ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) { if (snapshot.hasData) { final path = '${snapshot.data!.path}/app_background_image'; final file = File(path);