mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 14:28:40 +00:00
improve layout for smaller devices
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
This commit is contained in:
parent
38ab86f5e8
commit
35a90ace0a
6 changed files with 33 additions and 20 deletions
|
|
@ -52,7 +52,7 @@
|
||||||
</Testables>
|
</Testables>
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
buildConfiguration = "Release"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
|
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ class HomeViewCameraPreview extends StatelessWidget {
|
||||||
}
|
}
|
||||||
return Positioned.fill(
|
return Positioned.fill(
|
||||||
child: MediaViewSizing(
|
child: MediaViewSizing(
|
||||||
requiredHeight: 80,
|
requiredHeight: 0,
|
||||||
|
additionalPadding: 59,
|
||||||
bottomNavigation: Container(),
|
bottomNavigation: Container(),
|
||||||
child: Screenshot(
|
child: Screenshot(
|
||||||
controller: screenshotController,
|
controller: screenshotController,
|
||||||
|
|
@ -60,8 +61,8 @@ class SendToCameraPreview extends StatelessWidget {
|
||||||
}
|
}
|
||||||
return Positioned.fill(
|
return Positioned.fill(
|
||||||
child: MediaViewSizing(
|
child: MediaViewSizing(
|
||||||
requiredHeight: 80,
|
requiredHeight: 0,
|
||||||
bottomNavigation: Container(),
|
additionalPadding: 59,
|
||||||
child: Screenshot(
|
child: Screenshot(
|
||||||
controller: screenshotController,
|
controller: screenshotController,
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
|
|
|
||||||
|
|
@ -598,7 +598,8 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
return MediaViewSizing(
|
return MediaViewSizing(
|
||||||
requiredHeight: 80,
|
requiredHeight: 0,
|
||||||
|
additionalPadding: 59,
|
||||||
bottomNavigation: Container(),
|
bottomNavigation: Container(),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onPanStart: (details) async {
|
onPanStart: (details) async {
|
||||||
|
|
|
||||||
|
|
@ -533,7 +533,7 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
child: MediaViewSizing(
|
child: MediaViewSizing(
|
||||||
requiredHeight: 80,
|
requiredHeight: 59,
|
||||||
bottomNavigation: ColoredBox(
|
bottomNavigation: ColoredBox(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|
|
||||||
|
|
@ -518,7 +518,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
},
|
},
|
||||||
child: MediaViewSizing(
|
child: MediaViewSizing(
|
||||||
bottomNavigation: bottomNavigation(),
|
bottomNavigation: bottomNavigation(),
|
||||||
requiredHeight: 80,
|
requiredHeight: 55,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (videoController != null)
|
if (videoController != null)
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@ class MediaViewSizing extends StatefulWidget {
|
||||||
super.key,
|
super.key,
|
||||||
this.requiredHeight,
|
this.requiredHeight,
|
||||||
this.bottomNavigation,
|
this.bottomNavigation,
|
||||||
|
this.additionalPadding,
|
||||||
});
|
});
|
||||||
|
|
||||||
final double? requiredHeight;
|
final double? requiredHeight;
|
||||||
|
final double? additionalPadding;
|
||||||
final Widget? bottomNavigation;
|
final Widget? bottomNavigation;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
|
|
@ -20,19 +22,22 @@ class _MediaViewSizingState extends State<MediaViewSizing> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var needToDownSizeImage = false;
|
var needToDownSizeImage = false;
|
||||||
|
var availableHeight = MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
|
// Get the screen size and safe area padding
|
||||||
|
final screenSize = MediaQuery.of(context).size;
|
||||||
|
final safeAreaPadding = MediaQuery.of(context).padding;
|
||||||
|
|
||||||
|
// Calculate the available width and height
|
||||||
|
final availableWidth = screenSize.width;
|
||||||
|
availableHeight = screenSize.height -
|
||||||
|
safeAreaPadding.top -
|
||||||
|
safeAreaPadding.bottom -
|
||||||
|
(widget.additionalPadding ?? 0);
|
||||||
|
|
||||||
|
final aspectRatioWidth = availableWidth;
|
||||||
|
final aspectRatioHeight = (aspectRatioWidth * 16) / 9;
|
||||||
if (widget.requiredHeight != null) {
|
if (widget.requiredHeight != null) {
|
||||||
// Get the screen size and safe area padding
|
|
||||||
final screenSize = MediaQuery.of(context).size;
|
|
||||||
final safeAreaPadding = MediaQuery.of(context).padding;
|
|
||||||
|
|
||||||
// Calculate the available width and height
|
|
||||||
final availableWidth = screenSize.width;
|
|
||||||
final availableHeight =
|
|
||||||
screenSize.height - safeAreaPadding.top - safeAreaPadding.bottom;
|
|
||||||
|
|
||||||
final aspectRatioWidth = availableWidth;
|
|
||||||
final aspectRatioHeight = (aspectRatioWidth * 16) / 9;
|
|
||||||
if (aspectRatioHeight < availableHeight) {
|
if (aspectRatioHeight < availableHeight) {
|
||||||
if ((screenSize.height - widget.requiredHeight!) < aspectRatioHeight) {
|
if ((screenSize.height - widget.requiredHeight!) < aspectRatioHeight) {
|
||||||
needToDownSizeImage = true;
|
needToDownSizeImage = true;
|
||||||
|
|
@ -43,6 +48,7 @@ class _MediaViewSizingState extends State<MediaViewSizing> {
|
||||||
Widget imageChild = Align(
|
Widget imageChild = Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
height: availableHeight,
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 9 / 16,
|
aspectRatio: 9 / 16,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
|
|
@ -68,8 +74,13 @@ class _MediaViewSizingState extends State<MediaViewSizing> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Column(
|
child: Container(
|
||||||
children: [imageChild, bottomNavigation],
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: availableHeight,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [imageChild, bottomNavigation],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue