From fe75b75ddc88b3e50dc8673b70eb77bc32611169 Mon Sep 17 00:00:00 2001 From: BrentBoyMeBob <72168352+BrentBoyMeBob@users.noreply.github.com> Date: Thu, 3 Aug 2023 14:38:38 -0700 Subject: [PATCH] feat: dpi responsive layout (#361) --- lib/ui/views/installer/installer_view.dart | 2 + .../patches_selector_view.dart | 31 +++--- .../appSelectorView/installed_app_item.dart | 20 ++-- .../not_installed_app_item.dart | 20 ++-- .../widgets/homeView/latest_commit_card.dart | 100 +++++++++--------- .../patcherView/app_selector_card.dart | 8 +- lib/ui/widgets/shared/application_item.dart | 93 +++++++++------- 7 files changed, 146 insertions(+), 128 deletions(-) diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index 7663a5bb..981d0f55 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -31,6 +31,8 @@ class InstallerView extends StatelessWidget { style: GoogleFonts.inter( color: Theme.of(context).textTheme.titleLarge!.color, ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ), onBackButtonPressed: () => model.onWillPop(context), actions: [ diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index 32e7802b..6359403a 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -62,19 +62,24 @@ class _PatchesSelectorViewState extends State { onPressed: () => Navigator.of(context).pop(), ), actions: [ - Container( - margin: const EdgeInsets.only(top: 12, bottom: 12), - padding: - const EdgeInsets.symmetric(horizontal: 6, vertical: 6), - decoration: BoxDecoration( - color: - Theme.of(context).colorScheme.tertiary.withOpacity(0.5), - borderRadius: BorderRadius.circular(6), - ), - child: Text( - model.patchesVersion!, - style: TextStyle( - color: Theme.of(context).textTheme.titleLarge!.color, + FittedBox( + fit: BoxFit.scaleDown, + child: Container( + margin: const EdgeInsets.only(top: 12, bottom: 12), + padding: + const EdgeInsets.symmetric(horizontal: 6, vertical: 6), + decoration: BoxDecoration( + color: Theme.of(context) + .colorScheme + .tertiary + .withOpacity(0.5), + borderRadius: BorderRadius.circular(6), + ), + child: Text( + model.patchesVersion!, + style: TextStyle( + color: Theme.of(context).textTheme.titleLarge!.color, + ), ), ), ), diff --git a/lib/ui/widgets/appSelectorView/installed_app_item.dart b/lib/ui/widgets/appSelectorView/installed_app_item.dart index 69b08371..7e96e655 100644 --- a/lib/ui/widgets/appSelectorView/installed_app_item.dart +++ b/lib/ui/widgets/appSelectorView/installed_app_item.dart @@ -70,7 +70,7 @@ class _InstalledAppItemState extends State { }, ), ), - Row( + Wrap( children: [ I18nText( 'suggested', @@ -84,16 +84,14 @@ class _InstalledAppItemState extends State { }, ), const SizedBox(width: 4), - Flexible( - child: Text( - widget.patchesCount == 1 - ? '• ${widget.patchesCount} patch' - : '• ${widget.patchesCount} patches', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), + Text( + widget.patchesCount == 1 + ? '• ${widget.patchesCount} patch' + : '• ${widget.patchesCount} patches', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, ), ), ], diff --git a/lib/ui/widgets/appSelectorView/not_installed_app_item.dart b/lib/ui/widgets/appSelectorView/not_installed_app_item.dart index ee40b8c1..c2f3f52e 100644 --- a/lib/ui/widgets/appSelectorView/not_installed_app_item.dart +++ b/lib/ui/widgets/appSelectorView/not_installed_app_item.dart @@ -64,7 +64,7 @@ class _NotInstalledAppItem extends State { ), ), ), - Row( + Wrap( children: [ I18nText( 'suggested', @@ -78,16 +78,14 @@ class _NotInstalledAppItem extends State { }, ), const SizedBox(width: 4), - Flexible( - child: Text( - widget.patchesCount == 1 - ? '• ${widget.patchesCount} patch' - : '• ${widget.patchesCount} patches', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), + Text( + widget.patchesCount == 1 + ? '• ${widget.patchesCount} patch' + : '• ${widget.patchesCount} patches', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, ), ), ], diff --git a/lib/ui/widgets/homeView/latest_commit_card.dart b/lib/ui/widgets/homeView/latest_commit_card.dart index 0f9870f7..2d62286f 100644 --- a/lib/ui/widgets/homeView/latest_commit_card.dart +++ b/lib/ui/widgets/homeView/latest_commit_card.dart @@ -30,30 +30,28 @@ class _LatestCommitCardState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Row( - children: [ - Text('ReVanced Manager'), - ], - ), - const SizedBox(height: 4), - Row( - children: [ - FutureBuilder( - future: model.getLatestManagerReleaseTime(), - builder: (context, snapshot) => - snapshot.hasData && snapshot.data!.isNotEmpty - ? I18nText( - 'latestCommitCard.timeagoLabel', - translationParams: {'time': snapshot.data!}, - ) - : I18nText('latestCommitCard.loadingLabel'), - ), - ], - ), - ], + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('ReVanced Manager'), + const SizedBox(height: 4), + Row( + children: [ + FutureBuilder( + future: model.getLatestManagerReleaseTime(), + builder: (context, snapshot) => snapshot.hasData && + snapshot.data!.isNotEmpty + ? I18nText( + 'latestCommitCard.timeagoLabel', + translationParams: {'time': snapshot.data!}, + ) + : I18nText('latestCommitCard.loadingLabel'), + ), + ], + ), + ], + ), ), FutureBuilder( future: model.hasManagerUpdates(), @@ -82,35 +80,33 @@ class _LatestCommitCardState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Row( - children: [ - Text('ReVanced Patches'), - ], - ), - const SizedBox(height: 4), - Row( - children: [ - FutureBuilder( - future: model.getLatestPatchesReleaseTime(), - builder: (context, snapshot) => Text( - snapshot.hasData && snapshot.data!.isNotEmpty - ? FlutterI18n.translate( - context, - 'latestCommitCard.timeagoLabel', - translationParams: {'time': snapshot.data!}, - ) - : FlutterI18n.translate( - context, - 'latestCommitCard.loadingLabel', - ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('ReVanced Patches'), + const SizedBox(height: 4), + Row( + children: [ + FutureBuilder( + future: model.getLatestPatchesReleaseTime(), + builder: (context, snapshot) => Text( + snapshot.hasData && snapshot.data!.isNotEmpty + ? FlutterI18n.translate( + context, + 'latestCommitCard.timeagoLabel', + translationParams: {'time': snapshot.data!}, + ) + : FlutterI18n.translate( + context, + 'latestCommitCard.loadingLabel', + ), + ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), FutureBuilder( future: locator().hasPatchesUpdates(), diff --git a/lib/ui/widgets/patcherView/app_selector_card.dart b/lib/ui/widgets/patcherView/app_selector_card.dart index ceeb64e9..e97a004d 100644 --- a/lib/ui/widgets/patcherView/app_selector_card.dart +++ b/lib/ui/widgets/patcherView/app_selector_card.dart @@ -49,9 +49,11 @@ class AppSelectorCard extends StatelessWidget { ), ), const SizedBox(width: 6), - Text( - locator().getAppSelectionString(), - style: const TextStyle(fontWeight: FontWeight.w600), + Flexible( + child: Text( + locator().getAppSelectionString(), + style: const TextStyle(fontWeight: FontWeight.w600), + ), ), ], ), diff --git a/lib/ui/widgets/shared/application_item.dart b/lib/ui/widgets/shared/application_item.dart index 24e84375..42eee351 100644 --- a/lib/ui/widgets/shared/application_item.dart +++ b/lib/ui/widgets/shared/application_item.dart @@ -70,49 +70,66 @@ class _ApplicationItemState extends State animationDuration: Duration(milliseconds: 450), ), header: Row( - children: [ - SizedBox( - width: 40, - child: Image.memory(widget.icon, height: 40, width: 40), - ), - const SizedBox(width: 4), - Padding( - padding: const EdgeInsets.only(left: 15.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.name.length > 12 - ? '${widget.name.substring(0, 12)}...' - : widget.name, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Row( + children: [ + SizedBox( + width: 40, + child: Image.memory(widget.icon, height: 40, width: 40), + ), + const SizedBox(width: 19), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + Text( + format(widget.patchDate), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ], ), ), - Text(format(widget.patchDate)), ], ), ), - const Spacer(), - RotationTransition( - turns: - Tween(begin: 0.0, end: 0.50).animate(_animationController), - child: const Padding( - padding: EdgeInsets.all(8.0), - child: Icon(Icons.arrow_drop_down), - ), - ), - const SizedBox(width: 8), - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - CustomMaterialButton( - label: widget.isUpdatableApp - ? I18nText('applicationItem.patchButton') - : I18nText('applicationItem.infoButton'), - onPressed: widget.onPressed, + Row( + children: [ + RotationTransition( + turns: Tween(begin: 0.0, end: 0.50) + .animate(_animationController), + child: const Padding( + padding: EdgeInsets.all(8.0), + child: Icon(Icons.arrow_drop_down), + ), + ), + const SizedBox(width: 8), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + CustomMaterialButton( + label: widget.isUpdatableApp + ? I18nText('applicationItem.patchButton') + : I18nText('applicationItem.infoButton'), + onPressed: widget.onPressed, + ), + ], ), ], ),