🐛 Bug fixes

This commit is contained in:
LittleSheep 2024-12-11 22:28:16 +08:00
parent 2abc9808e2
commit 3b1d291037
4 changed files with 22 additions and 57 deletions

View File

@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 70; objectVersion = 54;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */

View File

@ -58,7 +58,6 @@ final _appRoutes = [
path: '/write/:mode', path: '/write/:mode',
name: 'postEditor', name: 'postEditor',
builder: (context, state) => AppBackground( builder: (context, state) => AppBackground(
isLessOptimization: true,
child: PostEditorScreen( child: PostEditorScreen(
mode: state.pathParameters['mode']!, mode: state.pathParameters['mode']!,
postEditId: int.tryParse( postEditId: int.tryParse(
@ -77,7 +76,6 @@ final _appRoutes = [
path: '/search', path: '/search',
name: 'postSearch', name: 'postSearch',
builder: (context, state) => const AppBackground( builder: (context, state) => const AppBackground(
isLessOptimization: true,
child: PostSearchScreen(), child: PostSearchScreen(),
), ),
), ),
@ -119,7 +117,6 @@ final _appRoutes = [
path: '/:scope/:alias', path: '/:scope/:alias',
name: 'chatRoom', name: 'chatRoom',
builder: (context, state) => AppBackground( builder: (context, state) => AppBackground(
isLessOptimization: true,
child: ChatRoomScreen( child: ChatRoomScreen(
scope: state.pathParameters['scope']!, scope: state.pathParameters['scope']!,
alias: state.pathParameters['alias']!, alias: state.pathParameters['alias']!,
@ -159,7 +156,6 @@ final _appRoutes = [
secondaryAnimation: secondaryAnimation, secondaryAnimation: secondaryAnimation,
fillColor: Colors.transparent, fillColor: Colors.transparent,
child: AppBackground( child: AppBackground(
isLessOptimization: true,
child: child, child: child,
), ),
); );
@ -195,7 +191,6 @@ final _appRoutes = [
secondaryAnimation: secondaryAnimation, secondaryAnimation: secondaryAnimation,
fillColor: Colors.transparent, fillColor: Colors.transparent,
child: AppBackground( child: AppBackground(
isLessOptimization: true,
child: child, child: child,
), ),
); );

View File

@ -130,7 +130,7 @@ class _AttachmentListState extends State<AttachmentList> {
} }
return AspectRatio( return AspectRatio(
aspectRatio: widget.data.firstOrNull?.metadata['ratio'] ?? 1, aspectRatio: (widget.data.firstOrNull?.metadata['ratio'] ?? 1).toDouble(),
child: Container( child: Container(
constraints: BoxConstraints(maxHeight: constraints.maxHeight), constraints: BoxConstraints(maxHeight: constraints.maxHeight),
child: ScrollConfiguration( child: ScrollConfiguration(
@ -142,7 +142,7 @@ class _AttachmentListState extends State<AttachmentList> {
return Container( return Container(
constraints: constraints, constraints: constraints,
child: AspectRatio( child: AspectRatio(
aspectRatio: widget.data[idx]?.metadata['ratio'] ?? 1, aspectRatio: (widget.data[idx]?.metadata['ratio'] ?? 1).toDouble(),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
context.pushTransparentRoute( context.pushTransparentRoute(

View File

@ -7,12 +7,11 @@ import 'package:responsive_framework/responsive_framework.dart';
class AppBackground extends StatelessWidget { class AppBackground extends StatelessWidget {
final Widget child; final Widget child;
final bool isLessOptimization;
final bool isRoot; final bool isRoot;
const AppBackground({ const AppBackground({
super.key, super.key,
required this.child, required this.child,
this.isLessOptimization = false,
this.isRoot = false, this.isRoot = false,
}); });
@ -23,52 +22,25 @@ class AppBackground extends StatelessWidget {
) { ) {
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio; final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
if (isLessOptimization) { final size = MediaQuery.of(context).size;
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,
),
);
}
return Container( return Container(
color: Theme.of(context).colorScheme.surface, color: Theme.of(context).colorScheme.surface,
child: LayoutBuilder( child: Container(
builder: (context, constraints) { decoration: BoxDecoration(
return Container( backgroundBlendMode: BlendMode.darken,
decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface,
backgroundBlendMode: BlendMode.darken, image: DecorationImage(
color: Theme.of(context).colorScheme.surface, opacity: 0.2,
image: DecorationImage( image: ResizeImage(
opacity: 0.2, FileImage(imageFile),
image: ResizeImage( width: (size.width * devicePixelRatio).round(),
FileImage(imageFile), height: (size.height * devicePixelRatio).round(),
width: (constraints.maxWidth * devicePixelRatio).round(), policy: ResizeImagePolicy.fit,
height: (constraints.maxHeight * devicePixelRatio).round(),
policy: ResizeImagePolicy.fit,
),
fit: BoxFit.cover,
),
), ),
child: child, fit: BoxFit.cover,
); ),
}, ),
child: child,
), ),
); );
} }
@ -77,11 +49,9 @@ class AppBackground extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScaffoldMessenger( return ScaffoldMessenger(
child: FutureBuilder( child: FutureBuilder(
future: future: kIsWeb ? Future.value(null) : getApplicationDocumentsDirectory(),
kIsWeb ? Future.value(null) : getApplicationDocumentsDirectory(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (isRoot || if (isRoot || ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) {
ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) {
if (snapshot.hasData) { if (snapshot.hasData) {
final path = '${snapshot.data!.path}/app_background_image'; final path = '${snapshot.data!.path}/app_background_image';
final file = File(path); final file = File(path);