fix safeareas

This commit is contained in:
Christien Rioux 2025-03-18 15:34:39 -04:00
parent 0d888363ff
commit 3c95c9d1a3
9 changed files with 51 additions and 194 deletions

View File

@ -54,8 +54,6 @@ PODS:
- nanopb/encode (= 3.30910.0)
- nanopb/decode (3.30910.0)
- nanopb/encode (3.30910.0)
- native_device_orientation (0.0.1):
- Flutter
- package_info_plus (0.4.5):
- Flutter
- pasteboard (0.0.1):
@ -87,7 +85,6 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`)
- native_device_orientation (from `.symlinks/plugins/native_device_orientation/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- pasteboard (from `.symlinks/plugins/pasteboard/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
@ -124,8 +121,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_native_splash/ios"
mobile_scanner:
:path: ".symlinks/plugins/mobile_scanner/ios"
native_device_orientation:
:path: ".symlinks/plugins/native_device_orientation/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
pasteboard:
@ -163,7 +158,6 @@ SPEC CHECKSUMS:
MLKitVision: 45e79d68845a2de77e2dd4d7f07947f0ed157b0e
mobile_scanner: af8f71879eaba2bbcb4d86c6a462c3c0e7f23036
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
native_device_orientation: e3580675687d5034770da198f6839ebf2122ef94
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
pasteboard: 49088aeb6119d51f976a421db60d8e1ab079b63c
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564

View File

@ -8,7 +8,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_translate/flutter_translate.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:native_device_orientation/native_device_orientation.dart';
import 'package:provider/provider.dart';
import 'package:veilid_support/veilid_support.dart';
@ -202,13 +201,7 @@ class VeilidChatApp extends StatelessWidget {
// Once init is done, we proceed with the app
final localizationDelegate = LocalizedApp.of(context).delegate;
if (isiOS || isAndroid) {
return NativeDeviceOrientationReader(
//useSensor: false,
builder: (context) => appBuilder(context, localizationDelegate));
} else {
return appBuilder(context, localizationDelegate);
}
return SafeArea(child: appBuilder(context, localizationDelegate));
});
@override

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_translate/flutter_translate.dart';
import '../../theme/models/scale_theme/scale_scheme.dart';
import '../../theme/views/views.dart';
class NoConversationWidget extends StatelessWidget {
const NoConversationWidget({super.key});
@ -17,27 +18,26 @@ class NoConversationWidget extends StatelessWidget {
final scale = scaleScheme.scale(ScaleKind.primary);
return DecoratedBox(
decoration: BoxDecoration(
color: scale.appBackground.withAlpha(scaleConfig.wallpaperAlpha),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.diversity_3,
color: scale.appText.withAlpha(127),
size: 48,
),
Text(
textAlign: TextAlign.center,
translate('chat.start_a_conversation'),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: scale.appText.withAlpha(127),
),
),
],
),
);
decoration: BoxDecoration(
color: scale.appBackground.withAlpha(scaleConfig.wallpaperAlpha),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.diversity_3,
color: scale.appText.withAlpha(127),
size: 48,
),
Text(
textAlign: TextAlign.center,
translate('chat.start_a_conversation'),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: scale.appText.withAlpha(127),
),
),
],
));
}
}

View File

@ -93,33 +93,32 @@ class _HomeAccountReadyState extends State<HomeAccountReady> {
});
});
Widget buildUserPanel() => Builder(builder: (context) {
final profile = context.select<AccountRecordCubit, proto.Profile>(
(c) => c.state.asData!.value.profile);
final theme = Theme.of(context);
final scale = theme.extension<ScaleScheme>()!;
final scaleConfig = theme.extension<ScaleConfig>()!;
return ColoredBox(
color: scaleConfig.preferBorders
? scale.primaryScale.subtleBackground
: scale.primaryScale.subtleBorder,
child: Column(children: <Widget>[
Row(children: [
buildMenuButton().paddingLTRB(0, 0, 8, 0),
ProfileWidget(
profile: profile,
showPronouns: false,
).expanded(),
buildContactsButton().paddingLTRB(8, 0, 0, 0),
]).paddingAll(8),
const ChatListWidget().expanded()
]));
});
Widget buildLeftPane(BuildContext context) => Builder(
builder: (context) =>
Material(color: Colors.transparent, child: buildUserPanel()));
builder: (context) => Material(
color: Colors.transparent,
child: Builder(builder: (context) {
final profile = context.select<AccountRecordCubit, proto.Profile>(
(c) => c.state.asData!.value.profile);
final theme = Theme.of(context);
final scale = theme.extension<ScaleScheme>()!;
final scaleConfig = theme.extension<ScaleConfig>()!;
return ColoredBox(
color: scaleConfig.preferBorders
? scale.primaryScale.subtleBackground
: scale.primaryScale.subtleBorder,
child: Column(children: <Widget>[
Row(children: [
buildMenuButton().paddingLTRB(0, 0, 8, 0),
ProfileWidget(
profile: profile,
showPronouns: false,
).expanded(),
buildContactsButton().paddingLTRB(8, 0, 0, 0),
]).paddingAll(8),
const ChatListWidget().expanded()
]));
})));
Widget buildRightPane(BuildContext context) {
final activeChatCubit = context.watch<ActiveChatCubit>();

View File

@ -13,7 +13,6 @@ import 'package:veilid_support/veilid_support.dart';
import '../../account_manager/account_manager.dart';
import '../../settings/settings.dart';
import '../../theme/theme.dart';
import '../../tools/native_safe_area.dart';
import 'drawer_menu/drawer_menu.dart';
import 'home_account_invalid.dart';
import 'home_account_locked.dart';
@ -209,7 +208,7 @@ class HomeScreenState extends State<HomeScreen>
.indexWhere((x) => x.superIdentity.recordKey == activeLocalAccount);
final canClose = activeIndex != -1;
Widget homeWidget = DefaultTextStyle(
return DefaultTextStyle(
style: theme.textTheme.bodySmall!,
child: ZoomDrawer(
controller: _zoomDrawerController,
@ -238,13 +237,6 @@ class HomeScreenState extends State<HomeScreen>
mainScreenScale: .25,
slideWidth: min(360, MediaQuery.of(context).size.width * 0.9),
));
if (isiOS || isAndroid) {
homeWidget = NativeSafeArea(
bottom: false, left: false, right: false, child: homeWidget);
}
return homeWidget;
}
////////////////////////////////////////////////////////////////////////////

View File

@ -1,111 +0,0 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:native_device_orientation/native_device_orientation.dart';
class NativeSafeArea extends StatelessWidget {
const NativeSafeArea({
required this.child,
this.left = true,
this.top = true,
this.right = true,
this.bottom = true,
this.minimum = EdgeInsets.zero,
this.maintainBottomViewPadding = false,
super.key,
});
/// Whether to avoid system intrusions on the left.
final bool left;
/// Whether to avoid system intrusions at the top of the screen, typically the
/// system status bar.
final bool top;
/// Whether to avoid system intrusions on the right.
final bool right;
/// Whether to avoid system intrusions on the bottom side of the screen.
final bool bottom;
/// This minimum padding to apply.
///
/// The greater of the minimum insets and the media padding will be applied.
final EdgeInsets minimum;
/// Specifies whether the [SafeArea] should maintain the bottom
/// [MediaQueryData.viewPadding] instead of the bottom
/// [MediaQueryData.padding], defaults to false.
///
/// For example, if there is an onscreen keyboard displayed above the
/// SafeArea, the padding can be maintained below the obstruction rather than
/// being consumed. This can be helpful in cases where your layout contains
/// flexible widgets, which could visibly move when opening a software
/// keyboard due to the change in the padding value. Setting this to true will
/// avoid the UI shift.
final bool maintainBottomViewPadding;
/// The widget below this widget in the tree.
///
/// The padding on the [MediaQuery] for the [child] will be suitably adjusted
/// to zero out any sides that were avoided by this widget.
///
/// {@macro flutter.widgets.ProxyWidget.child}
final Widget child;
@override
Widget build(BuildContext context) {
final nativeOrientation =
NativeDeviceOrientationReader.orientation(context);
late final bool realLeft;
late final bool realRight;
late final bool realTop;
late final bool realBottom;
switch (nativeOrientation) {
case NativeDeviceOrientation.unknown:
case NativeDeviceOrientation.portraitUp:
realLeft = left;
realRight = right;
realTop = top;
realBottom = bottom;
case NativeDeviceOrientation.portraitDown:
realLeft = right;
realRight = left;
realTop = bottom;
realBottom = top;
case NativeDeviceOrientation.landscapeRight:
realLeft = bottom;
realRight = top;
realTop = left;
realBottom = right;
case NativeDeviceOrientation.landscapeLeft:
realLeft = top;
realRight = bottom;
realTop = right;
realBottom = left;
}
return SafeArea(
left: realLeft,
right: realRight,
top: realTop,
bottom: realBottom,
minimum: minimum,
maintainBottomViewPadding: maintainBottomViewPadding,
child: child);
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty<bool>('left', left))
..add(DiagnosticsProperty<bool>('top', top))
..add(DiagnosticsProperty<bool>('right', right))
..add(DiagnosticsProperty<bool>('bottom', bottom))
..add(DiagnosticsProperty<EdgeInsets>('minimum', minimum))
..add(DiagnosticsProperty<bool>(
'maintainBottomViewPadding', maintainBottomViewPadding));
}
}

View File

@ -260,8 +260,7 @@ class _DeveloperPageState extends State<DeveloperPage> {
),
body: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: SafeArea(
child: Column(children: [
child: Column(children: [
Stack(alignment: AlignmentDirectional.center, children: [
Image.asset('assets/images/ellet.png'),
TerminalView(globalDebugTerminal,
@ -333,7 +332,7 @@ class _DeveloperPageState extends State<DeveloperPage> {
}
},
).paddingAll(4)
]))));
])));
}
////////////////////////////////////////////////////////////////////////////

View File

@ -937,14 +937,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.7"
native_device_orientation:
dependency: "direct main"
description:
name: native_device_orientation
sha256: "0c330c068575e4be72cce5968ca479a3f8d5d1e5dfce7d89d5c13a1e943b338c"
url: "https://pub.dev"
source: hosted
version: "2.0.3"
nested:
dependency: transitive
description:

View File

@ -63,7 +63,6 @@ dependencies:
loggy: ^2.0.3
meta: ^1.16.0
mobile_scanner: ^6.0.7
native_device_orientation: ^2.0.3
package_info_plus: ^8.3.0
pasteboard: ^0.3.0
path: ^1.9.1