From bc37a59b31f8f6fc37da2aba5bc0ad904fe1523a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr> Date: Thu, 26 Dec 2024 11:41:21 +0100 Subject: [PATCH] Scroll too long parameters page, improve layout --- CHANGELOG.md | 4 ++ lib/parameters/pages/parameters.dart | 71 ++++++++++++++++------------ pubspec.yaml | 2 +- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df15e16..8e14389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.4 + +- Allow scroll too long parameters page, improve layout + ## 0.8.3 - Improve topbar buttons diff --git a/lib/parameters/pages/parameters.dart b/lib/parameters/pages/parameters.dart index fe45ecf..5586e67 100644 --- a/lib/parameters/pages/parameters.dart +++ b/lib/parameters/pages/parameters.dart @@ -12,36 +12,49 @@ class PageParameters extends StatelessWidget { final ApplicationConfigDefinition appConfig; final bool canBeResumed; - final double separatorHeight = 8.0; + final double separatorHeight = 4.0; @override Widget build(BuildContext context) { - final List<Widget> lines = []; - // Activity settings (top) + final List<Widget> blockTop = []; for (ApplicationSettingsParameter parameter in appConfig.activitySettings) { if (parameter.displayedOnTop) { - for (var itemsLine in buildParametersLines( + for (List<Widget> itemsLine in buildParametersLines( parameter: parameter, isEnabled: !canBeResumed, )) { - lines.add(Row( + blockTop.add(Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: itemsLine, )); } - - lines.add(SizedBox(height: separatorHeight)); + blockTop.add(SizedBox(height: separatorHeight)); } } - lines.add(Expanded( - child: SizedBox(height: separatorHeight), - )); + // Activity settings (bottom) + final List<Widget> blockBottom = []; + for (ApplicationSettingsParameter parameter in appConfig.activitySettings) { + if (!parameter.displayedOnTop) { + for (List<Widget> itemsLine in buildParametersLines( + parameter: parameter, + isEnabled: !canBeResumed, + )) { + blockBottom.add(Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: itemsLine, + )); + } + blockBottom.add(SizedBox(height: separatorHeight)); + } + } + // Actions buttons (middle block) + final List<Widget> blockActions = []; if (canBeResumed) { // Resume activity - lines.add(AspectRatio( + blockActions.add(AspectRatio( aspectRatio: 3, child: ActivityButtonResumeSaved( onPressed: () { @@ -50,7 +63,7 @@ class PageParameters extends StatelessWidget { ), )); // Delete saved activity - lines.add(SizedBox.square( + blockActions.add(SizedBox.square( dimension: MediaQuery.of(context).size.width / 5, child: ActivityButtonDeleteSaved( onPressed: () { @@ -60,7 +73,7 @@ class PageParameters extends StatelessWidget { )); } else { // Start new activity - lines.add( + blockActions.add( AspectRatio( aspectRatio: 3, child: ActivityButtonStartNew( @@ -71,29 +84,25 @@ class PageParameters extends StatelessWidget { ), ); } + blockActions.add(SizedBox(height: separatorHeight)); - lines.add(SizedBox(height: separatorHeight)); + // Global blocks list + final List<Widget> blocks = [ + Expanded( + child: ListView( + children: blockTop, + ), + ), + SizedBox(height: separatorHeight), + ]; - // Activity settings (bottom) - for (ApplicationSettingsParameter parameter in appConfig.activitySettings) { - if (!parameter.displayedOnTop) { - for (var itemsLine in buildParametersLines( - parameter: parameter, - isEnabled: !canBeResumed, - )) { - lines.add(Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: itemsLine, - )); - } + blocks.addAll(blockActions); - lines.add(SizedBox(height: separatorHeight)); - } + if (blockBottom.isNotEmpty) { + blocks.addAll(blockBottom); } - return Column( - children: lines, - ); + return Column(children: blocks); } List<List<Widget>> buildParametersLines({ diff --git a/pubspec.yaml b/pubspec.yaml index 9c4e1c3..dd5a402 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: "Flutter custom toolbox for org.benoitharrault.* projects." publish_to: "none" -version: 0.8.3 +version: 0.8.4 homepage: https://git.harrault.fr/android/flutter-toolbox -- GitLab