From 530dd7875296cb3c04b817277effda61b5570cef Mon Sep 17 00:00:00 2001 From: Unknown <55922348+55nknown@users.noreply.github.com> Date: Mon, 19 Sep 2022 18:55:44 +0200 Subject: [PATCH] fix: make inkwells visible (#205) --- .../views/app_selector/app_selector_view.dart | 10 +- lib/ui/widgets/appInfoView/app_info_view.dart | 293 ++++++++++-------- .../appSelectorView/installed_app_item.dart | 3 + .../patcherView/app_selector_card.dart | 96 +++--- .../patcherView/patch_selector_card.dart | 44 ++- .../patchesSelectorView/patch_item.dart | 164 +++++----- lib/ui/widgets/shared/application_item.dart | 27 +- lib/ui/widgets/shared/custom_card.dart | 29 +- 8 files changed, 349 insertions(+), 317 deletions(-) diff --git a/lib/ui/views/app_selector/app_selector_view.dart b/lib/ui/views/app_selector/app_selector_view.dart index b6f9ce01..9ba76d42 100644 --- a/lib/ui/views/app_selector/app_selector_view.dart +++ b/lib/ui/views/app_selector/app_selector_view.dart @@ -88,16 +88,14 @@ class _AppSelectorViewState extends State { child: Column( children: model .getFilteredApps(_query) - .map((app) => InkWell( + .map((app) => InstalledAppItem( + name: app.appName, + pkgName: app.packageName, + icon: app.icon, onTap: () { model.selectApp(app); Navigator.of(context).pop(); }, - child: InstalledAppItem( - name: app.appName, - pkgName: app.packageName, - icon: app.icon, - ), )) .toList(), ), diff --git a/lib/ui/widgets/appInfoView/app_info_view.dart b/lib/ui/widgets/appInfoView/app_info_view.dart index d4af3667..578b9e8c 100644 --- a/lib/ui/widgets/appInfoView/app_info_view.dart +++ b/lib/ui/widgets/appInfoView/app_info_view.dart @@ -34,7 +34,7 @@ class AppInfoView extends StatelessWidget { ), ), SliverPadding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.symmetric(vertical: 20.0), sliver: SliverList( delegate: SliverChildListDelegate.fixed( [ @@ -61,135 +61,34 @@ class AppInfoView extends StatelessWidget { style: Theme.of(context).textTheme.subtitle1, ), const SizedBox(height: 20), - CustomCard( - child: IntrinsicHeight( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - !app.isRooted ? const Spacer() : Container(), - InkWell( - onTap: () => model.openApp(app), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.open_in_new_outlined, - color: - Theme.of(context).colorScheme.primary, - ), - const SizedBox(height: 10), - I18nText( - 'appInfoView.openButton', - child: Text( - '', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .primary, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ), - const Spacer(), - VerticalDivider( - color: Theme.of(context).canvasColor, - ), - const Spacer(), - InkWell( - onTap: () => model.showUninstallDialog( - context, - app, - false, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.delete_outline, - color: - Theme.of(context).colorScheme.primary, - ), - const SizedBox(height: 10), - I18nText( - 'appInfoView.uninstallButton', - child: Text( - '', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .primary, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ), - const Spacer(), - VerticalDivider( - color: Theme.of(context).canvasColor, - ), - const Spacer(), - InkWell( - onTap: () { - model.navigateToPatcher(app); - Navigator.of(context).pop(); - }, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.build_outlined, - color: - Theme.of(context).colorScheme.primary, - ), - const SizedBox(height: 10), - I18nText( - 'appInfoView.patchButton', - child: Text( - '', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .primary, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ), - app.isRooted ? const Spacer() : Container(), - app.isRooted - ? VerticalDivider( - color: Theme.of(context).canvasColor, - ) - : Container(), - app.isRooted ? const Spacer() : Container(), - app.isRooted - ? InkWell( - onTap: () => model.showUninstallDialog( - context, - app, - true, - ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + child: CustomCard( + padding: EdgeInsets.zero, + child: SizedBox( + height: 94.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(16.0), + onTap: () => model.openApp(app), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( - Icons - .settings_backup_restore_outlined, + Icons.open_in_new_outlined, color: Theme.of(context) .colorScheme .primary, ), const SizedBox(height: 10), I18nText( - 'appInfoView.unpatchButton', + 'appInfoView.openButton', child: Text( '', style: TextStyle( @@ -202,16 +101,153 @@ class AppInfoView extends StatelessWidget { ), ], ), - ) - : Container(), - !app.isRooted ? const Spacer() : Container(), - ], + ), + ), + ), + if (app.isRooted) + VerticalDivider( + color: Theme.of(context).canvasColor, + indent: 12.0, + endIndent: 12.0, + width: 1.0, + ), + if (app.isRooted) + Expanded( + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(16.0), + onTap: () => model.showUninstallDialog( + context, + app, + false, + ), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Icon( + Icons.delete_outline, + color: Theme.of(context) + .colorScheme + .primary, + ), + const SizedBox(height: 10), + I18nText( + 'appInfoView.uninstallButton', + child: Text( + '', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .primary, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ), + ), + VerticalDivider( + color: Theme.of(context).canvasColor, + indent: 12.0, + endIndent: 12.0, + width: 1.0, + ), + Expanded( + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(16.0), + onTap: () { + model.navigateToPatcher(app); + Navigator.of(context).pop(); + }, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Icon( + Icons.build_outlined, + color: Theme.of(context) + .colorScheme + .primary, + ), + const SizedBox(height: 10), + I18nText( + 'appInfoView.patchButton', + child: Text( + '', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .primary, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ), + ), + if (app.isRooted) + VerticalDivider( + color: Theme.of(context).canvasColor, + indent: 12.0, + endIndent: 12.0, + width: 1.0, + ), + if (app.isRooted) + Expanded( + child: Material( + type: MaterialType.transparency, + child: InkWell( + onTap: () => model.showUninstallDialog( + context, + app, + true, + ), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Icon( + Icons + .settings_backup_restore_outlined, + color: Theme.of(context) + .colorScheme + .primary, + ), + const SizedBox(height: 10), + I18nText( + 'appInfoView.unpatchButton', + child: Text( + '', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .primary, + fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + ), + ), + ), + ], + ), ), ), ), const SizedBox(height: 20), ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: + const EdgeInsets.symmetric(horizontal: 20.0), title: I18nText( 'appInfoView.packageNameLabel', child: const Text( @@ -226,7 +262,8 @@ class AppInfoView extends StatelessWidget { ), const SizedBox(height: 4), ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: + const EdgeInsets.symmetric(horizontal: 20.0), title: I18nText( 'appInfoView.installTypeLabel', child: const Text( @@ -243,7 +280,8 @@ class AppInfoView extends StatelessWidget { ), const SizedBox(height: 4), ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: + const EdgeInsets.symmetric(horizontal: 20.0), title: I18nText( 'appInfoView.patchedDateLabel', child: const Text( @@ -264,7 +302,8 @@ class AppInfoView extends StatelessWidget { ), const SizedBox(height: 4), ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: + const EdgeInsets.symmetric(horizontal: 20.0), title: I18nText( 'appInfoView.appliedPatchesLabel', child: const Text( diff --git a/lib/ui/widgets/appSelectorView/installed_app_item.dart b/lib/ui/widgets/appSelectorView/installed_app_item.dart index 8429834e..3ce7641d 100644 --- a/lib/ui/widgets/appSelectorView/installed_app_item.dart +++ b/lib/ui/widgets/appSelectorView/installed_app_item.dart @@ -6,12 +6,14 @@ class InstalledAppItem extends StatefulWidget { final String name; final String pkgName; final Uint8List icon; + final Function()? onTap; const InstalledAppItem({ Key? key, required this.name, required this.pkgName, required this.icon, + this.onTap, }) : super(key: key); @override @@ -24,6 +26,7 @@ class _InstalledAppItemState extends State { return Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), child: CustomCard( + onTap: widget.onTap, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/ui/widgets/patcherView/app_selector_card.dart b/lib/ui/widgets/patcherView/app_selector_card.dart index 318d6530..00b5ab4e 100644 --- a/lib/ui/widgets/patcherView/app_selector_card.dart +++ b/lib/ui/widgets/patcherView/app_selector_card.dart @@ -15,61 +15,59 @@ class AppSelectorCard extends StatelessWidget { @override Widget build(BuildContext context) { - return GestureDetector( + return CustomCard( onTap: onPressed, - child: CustomCard( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - I18nText( - locator().selectedApp == null - ? 'appSelectorCard.widgetTitle' - : 'appSelectorCard.widgetTitleSelected', - child: const Text( - '', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + I18nText( + locator().selectedApp == null + ? 'appSelectorCard.widgetTitle' + : 'appSelectorCard.widgetTitleSelected', + child: const Text( + '', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, ), ), - const SizedBox(height: 10), - locator().selectedApp == null - ? I18nText('appSelectorCard.widgetSubtitle') - : Row( - children: [ - SizedBox( - height: 18.0, - child: ClipOval( - child: Image.memory( - locator().selectedApp == null - ? Uint8List(0) - : locator().selectedApp!.icon, - fit: BoxFit.cover, - ), + ), + const SizedBox(height: 10), + locator().selectedApp == null + ? I18nText('appSelectorCard.widgetSubtitle') + : Row( + children: [ + SizedBox( + height: 18.0, + child: ClipOval( + child: Image.memory( + locator().selectedApp == null + ? Uint8List(0) + : locator().selectedApp!.icon, + fit: BoxFit.cover, ), ), - const SizedBox(width: 6), - Text(locator().getAppSelectionString()), - ], - ), - locator().selectedApp == null - ? Container() - : Column( - children: [ - const SizedBox(height: 10), - Padding( - padding: const EdgeInsets.only(left: 20), - child: Text( - locator() - .getRecommendedVersionString(context), - style: const TextStyle(fontStyle: FontStyle.italic), - ), + ), + const SizedBox(width: 6), + Text(locator().getAppSelectionString()), + ], + ), + locator().selectedApp == null + ? Container() + : Column( + children: [ + const SizedBox(height: 10), + Padding( + padding: const EdgeInsets.only(left: 20), + child: Text( + locator() + .getRecommendedVersionString(context), + style: const TextStyle(fontStyle: FontStyle.italic), ), - ], - ), - ], - ), + ), + ], + ), + ], ), ); } diff --git a/lib/ui/widgets/patcherView/patch_selector_card.dart b/lib/ui/widgets/patcherView/patch_selector_card.dart index 1c4a521e..9ece60c0 100644 --- a/lib/ui/widgets/patcherView/patch_selector_card.dart +++ b/lib/ui/widgets/patcherView/patch_selector_card.dart @@ -15,32 +15,30 @@ class PatchSelectorCard extends StatelessWidget { @override Widget build(BuildContext context) { - return GestureDetector( + return CustomCard( onTap: onPressed, - child: CustomCard( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - I18nText( - locator().selectedPatches.isEmpty - ? 'patchSelectorCard.widgetTitle' - : 'patchSelectorCard.widgetTitleSelected', - child: const Text( - '', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + I18nText( + locator().selectedPatches.isEmpty + ? 'patchSelectorCard.widgetTitle' + : 'patchSelectorCard.widgetTitleSelected', + child: const Text( + '', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, ), ), - const SizedBox(height: 10), - locator().selectedApp == null - ? I18nText('patchSelectorCard.widgetSubtitle') - : locator().selectedPatches.isEmpty - ? I18nText('patchSelectorCard.widgetEmptySubtitle') - : Text(_getPatchesSelection()), - ], - ), + ), + const SizedBox(height: 10), + locator().selectedApp == null + ? I18nText('patchSelectorCard.widgetSubtitle') + : locator().selectedPatches.isEmpty + ? I18nText('patchSelectorCard.widgetEmptySubtitle') + : Text(_getPatchesSelection()), + ], ), ); } diff --git a/lib/ui/widgets/patchesSelectorView/patch_item.dart b/lib/ui/widgets/patchesSelectorView/patch_item.dart index 183c3c04..84dd1b13 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_item.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_item.dart @@ -39,102 +39,98 @@ class _PatchItemState extends State { Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), - child: InkWell( - borderRadius: BorderRadius.circular(16), + child: CustomCard( onTap: () { setState(() => widget.isSelected = !widget.isSelected); widget.onChanged(widget.isSelected); }, - child: CustomCard( - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - widget.simpleName, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + widget.simpleName, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, ), - const SizedBox(width: 4), - Text(widget.version) - ], - ), - const SizedBox(height: 4), - Text( - widget.description, - softWrap: true, - maxLines: 3, - overflow: TextOverflow.visible, - style: const TextStyle(fontSize: 14), - ), - ], - ), - ), - Transform.scale( - scale: 1.2, - child: Checkbox( - value: widget.isSelected, - activeColor: Theme.of(context).colorScheme.primary, - checkColor: - Theme.of(context).colorScheme.secondaryContainer, - side: BorderSide( - width: 2.0, - color: Theme.of(context).colorScheme.primary, + ), + const SizedBox(width: 4), + Text(widget.version) + ], ), - onChanged: (newValue) { - setState(() => widget.isSelected = newValue!); - widget.onChanged(widget.isSelected); - }, + const SizedBox(height: 4), + Text( + widget.description, + softWrap: true, + maxLines: 3, + overflow: TextOverflow.visible, + style: const TextStyle(fontSize: 14), + ), + ], + ), + ), + Transform.scale( + scale: 1.2, + child: Checkbox( + value: widget.isSelected, + activeColor: Theme.of(context).colorScheme.primary, + checkColor: + Theme.of(context).colorScheme.secondaryContainer, + side: BorderSide( + width: 2.0, + color: Theme.of(context).colorScheme.primary, ), - ) - ], - ), - widget.isUnsupported - ? Row( - children: [ - Padding( - padding: const EdgeInsets.only(top: 8), - child: TextButton.icon( - label: - I18nText('patchItem.unsupportedWarningButton'), - icon: const Icon(Icons.warning), - onPressed: () => _showUnsupportedWarningDialog(), - style: ButtonStyle( - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - side: BorderSide( - width: 1, - color: - Theme.of(context).colorScheme.secondary, - ), + onChanged: (newValue) { + setState(() => widget.isSelected = newValue!); + widget.onChanged(widget.isSelected); + }, + ), + ) + ], + ), + widget.isUnsupported + ? Row( + children: [ + Padding( + padding: const EdgeInsets.only(top: 8), + child: TextButton.icon( + label: I18nText('patchItem.unsupportedWarningButton'), + icon: const Icon(Icons.warning), + onPressed: () => _showUnsupportedWarningDialog(), + style: ButtonStyle( + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + side: BorderSide( + width: 1, + color: + Theme.of(context).colorScheme.secondary, ), ), - backgroundColor: MaterialStateProperty.all( - Colors.transparent, - ), - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondary, - ), + ), + backgroundColor: MaterialStateProperty.all( + Colors.transparent, + ), + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary, ), ), ), - ], - ) - : Container(), - widget.child ?? const SizedBox(), - ], - ), + ), + ], + ) + : Container(), + widget.child ?? const SizedBox(), + ], ), ), ); diff --git a/lib/ui/widgets/shared/application_item.dart b/lib/ui/widgets/shared/application_item.dart index 178357c2..be0f4fb7 100644 --- a/lib/ui/widgets/shared/application_item.dart +++ b/lib/ui/widgets/shared/application_item.dart @@ -61,6 +61,12 @@ class _ApplicationItemState extends State animationDuration: Duration(milliseconds: 450), ), header: CustomCard( + onTap: () { + expController.toggle(); + _animationController.isCompleted + ? _animationController.reverse() + : _animationController.forward(); + }, child: Row( children: [ SizedBox( @@ -87,20 +93,11 @@ class _ApplicationItemState extends State ), ), const Spacer(), - Padding( - padding: const EdgeInsets.only(right: 5.0), - child: RotationTransition( - turns: - Tween(begin: 0.0, end: 0.50).animate(_animationController), - child: IconButton( - onPressed: () { - expController.toggle(); - _animationController.isCompleted - ? _animationController.reverse() - : _animationController.forward(); - }, - icon: const Icon(Icons.arrow_drop_down), - ), + 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), ), ), Column( @@ -118,7 +115,7 @@ class _ApplicationItemState extends State ], ), ), - collapsed: const Text(''), + collapsed: const SizedBox(), expanded: Padding( padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0), child: Column( diff --git a/lib/ui/widgets/shared/custom_card.dart b/lib/ui/widgets/shared/custom_card.dart index 84293ce9..5092458f 100644 --- a/lib/ui/widgets/shared/custom_card.dart +++ b/lib/ui/widgets/shared/custom_card.dart @@ -3,30 +3,33 @@ import 'package:flutter/material.dart'; class CustomCard extends StatelessWidget { final bool isFilled; final Widget child; + final Function()? onTap; + final EdgeInsetsGeometry? padding; const CustomCard({ Key? key, this.isFilled = true, required this.child, + this.onTap, + this.padding, }) : super(key: key); @override Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( + return Material( + type: isFilled ? MaterialType.card : MaterialType.transparency, + color: isFilled + ? Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4) + : Colors.transparent, + borderRadius: BorderRadius.circular(16), + child: InkWell( + onTap: onTap, borderRadius: BorderRadius.circular(16), - color: isFilled - ? Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.40) - : Colors.transparent, - border: isFilled - ? null - : Border.all( - width: 1, - color: Theme.of(context).colorScheme.secondary, - ), + child: Padding( + padding: padding ?? const EdgeInsets.all(20.0), + child: child, + ), ), - padding: const EdgeInsets.all(20), - child: child, ); } }