📱 Fix some layout issues on device which has no safe area

This commit is contained in:
LittleSheep 2024-12-02 22:01:02 +08:00
parent 441df4090f
commit 7a617a4f8c
3 changed files with 122 additions and 132 deletions

View File

@ -1,4 +1,5 @@
import 'dart:ui'; import 'dart:ui';
import 'dart:math' as math;
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -396,7 +397,7 @@ class _PostPublisherScreenState extends State<PostPublisherScreen>
], ],
), ),
SliverToBoxAdapter(child: const Divider(height: 1)), SliverToBoxAdapter(child: const Divider(height: 1)),
Gap(MediaQuery.of(context).padding.top), Gap(math.max(MediaQuery.of(context).padding.top, 50)),
], ],
), ),
), ),

View File

@ -142,140 +142,134 @@ class _AttachmentZoomViewState extends State<AttachmentZoomView> {
Positioned( Positioned(
left: 16, left: 16,
right: 16, right: 16,
bottom: MediaQuery.of(context).padding.bottom > 16 bottom: 16,
? -MediaQuery.of(context).padding.bottom child: Material(
: 16, color: Colors.transparent,
child: SizedBox( child: Builder(builder: (context) {
height: 180, final ud = context.read<UserDirectoryProvider>();
child: Material( final item = widget.data.elementAt(
color: Colors.transparent, widget.data.length > 1
child: Builder(builder: (context) { ? _pageController.page?.round() ?? 0
final ud = context.read<UserDirectoryProvider>(); : 0,
final item = widget.data.elementAt( );
widget.data.length > 1 final account = ud.getAccountFromCache(item.accountId);
? _pageController.page?.round() ?? 0
: 0,
);
final account = ud.getAccountFromCache(item.accountId);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (item.accountId > 0) if (item.accountId > 0)
Row( Row(
children: [ children: [
IgnorePointer( IgnorePointer(
child: AccountImage( child: AccountImage(
content: account!.avatar, content: account!.avatar,
radius: 19, radius: 19,
),
), ),
const Gap(8),
Expanded(
child: IgnorePointer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'attachmentUploadBy'.tr(),
style:
Theme.of(context).textTheme.bodySmall,
),
Text(
account.nick,
style: Theme.of(context)
.textTheme
.bodyMedium,
),
],
),
),
),
if (widget.data.length > 1)
IgnorePointer(
child: Text(
'${(_pageController.page?.round() ?? 0) + 1}/${widget.data.length}',
style: GoogleFonts.robotoMono(fontSize: 13),
).padding(right: 8),
),
],
),
const Gap(4),
IgnorePointer(
child: Text(
item.alt,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
), ),
const Gap(8),
Expanded(
child: IgnorePointer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'attachmentUploadBy'.tr(),
style:
Theme.of(context).textTheme.bodySmall,
),
Text(
account.nick,
style:
Theme.of(context).textTheme.bodyMedium,
),
],
),
),
),
if (widget.data.length > 1)
IgnorePointer(
child: Text(
'${(_pageController.page?.round() ?? 0) + 1}/${widget.data.length}',
style: GoogleFonts.robotoMono(fontSize: 13),
).padding(right: 8),
),
],
),
const Gap(4),
IgnorePointer(
child: Text(
item.alt,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
), ),
), ),
const Gap(2), ),
IgnorePointer( const Gap(2),
child: Wrap( IgnorePointer(
spacing: 6, child: Wrap(
children: [ spacing: 6,
if (item.metadata['exif'] == null) children: [
Text( if (item.metadata['exif'] == null)
'#${item.rid}',
style: metaTextStyle,
),
if (item.metadata['exif']?['Model'] != null)
Text(
'attachmentShotOn'.tr(args: [
item.metadata['exif']?['Model'],
]),
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['ShutterSpeed'] != null)
Text(
item.metadata['exif']?['ShutterSpeed'],
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['ISO'] != null)
Text(
'ISO${item.metadata['exif']?['ISO']}',
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['Aperture'] != null)
Text(
'f/${item.metadata['exif']?['Aperture']}',
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['Megapixels'] != null &&
item.metadata['exif']?['Model'] != null)
Text(
'${item.metadata['exif']?['Megapixels']}MP',
style: metaTextStyle,
)
else
Text(
'${item.size} Bytes',
style: metaTextStyle,
),
Text( Text(
'${item.metadata['width']}x${item.metadata['height']}', '#${item.rid}',
style: metaTextStyle, style: metaTextStyle,
), ),
if (item.metadata['ratio'] != null) if (item.metadata['exif']?['Model'] != null)
Text(
(item.metadata['ratio'] as num)
.toStringAsFixed(2),
style: metaTextStyle,
),
Text( Text(
item.mimetype, 'attachmentShotOn'.tr(args: [
item.metadata['exif']?['Model'],
]),
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['ShutterSpeed'] != null)
Text(
item.metadata['exif']?['ShutterSpeed'],
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['ISO'] != null)
Text(
'ISO${item.metadata['exif']?['ISO']}',
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['Aperture'] != null)
Text(
'f/${item.metadata['exif']?['Aperture']}',
style: metaTextStyle,
).padding(right: 2),
if (item.metadata['exif']?['Megapixels'] != null &&
item.metadata['exif']?['Model'] != null)
Text(
'${item.metadata['exif']?['Megapixels']}MP',
style: metaTextStyle,
)
else
Text(
'${item.size} Bytes',
style: metaTextStyle, style: metaTextStyle,
), ),
], Text(
), '${item.metadata['width']}x${item.metadata['height']}',
style: metaTextStyle,
),
if (item.metadata['ratio'] != null)
Text(
(item.metadata['ratio'] as num)
.toStringAsFixed(2),
style: metaTextStyle,
),
Text(
item.mimetype,
style: metaTextStyle,
),
],
), ),
], ),
); ],
}), );
), }),
), ),
), ),
], ],

View File

@ -1,3 +1,5 @@
import 'dart:math' as math;
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
@ -277,7 +279,7 @@ class _PostContentHeader extends StatelessWidget {
context: context, context: context,
transition: PopoverTransition.other, transition: PopoverTransition.other,
bodyBuilder: (context) => SizedBox( bodyBuilder: (context) => SizedBox(
width: 400, width: math.min(400, MediaQuery.of(context).size.width - 10),
child: PublisherPopoverCard( child: PublisherPopoverCard(
data: data.publisher, data: data.publisher,
), ),
@ -507,16 +509,9 @@ class _PostTruncatedHint extends StatelessWidget {
const Gap(4), const Gap(4),
Text( Text(
'postTotalLength'.plural(data.body['content_length']), 'postTotalLength'.plural(data.body['content_length']),
).padding(right: 12) )
], ],
), ),
Row(
children: [
const Icon(Symbols.unfold_more, size: 20),
const Gap(4),
Text('postReadMore').tr(),
],
)
], ],
).opacity(0.75); ).opacity(0.75);
} }