From 8300cc4071547f1c8c5e58a7285e3f5569e05f3f Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Fri, 16 Sep 2022 00:49:11 +0530 Subject: [PATCH] feat: dropdown for changelogs. --- assets/i18n/en.json | 3 +- .../patches_selector_view.dart | 13 ++++- lib/ui/widgets/shared/application_item.dart | 55 ++++++++++++++++--- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 8b15f38e..b001952e 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -69,7 +69,8 @@ }, "patchesSelectorView": { "searchBarHint": "Search patches", - "doneButton": "Done" + "doneButton": "Done", + "noPatchesFound": "No patches found for the selected app." }, "patchItem": { "unsupportedWarningButton": "Unsupported version", diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index 642442d2..95b8e10e 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -55,9 +55,16 @@ class _PatchesSelectorViewState extends State { const SizedBox(height: 12), Expanded( child: model.patches.isEmpty - ? Center( - child: CircularProgressIndicator( - color: Theme.of(context).colorScheme.primary, + ? Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: I18nText( + 'patchesSelectorView.noPatchesFound', + child: Text( + '', + style: Theme.of(context).textTheme.bodyMedium, + ), + ), ), ) : ListView( diff --git a/lib/ui/widgets/shared/application_item.dart b/lib/ui/widgets/shared/application_item.dart index 9250a7cf..32fdd245 100644 --- a/lib/ui/widgets/shared/application_item.dart +++ b/lib/ui/widgets/shared/application_item.dart @@ -6,7 +6,7 @@ import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:expandable/expandable.dart'; import 'package:timeago/timeago.dart'; -class ApplicationItem extends StatelessWidget { +class ApplicationItem extends StatefulWidget { final Uint8List icon; final String name; final DateTime patchDate; @@ -24,10 +24,39 @@ class ApplicationItem extends StatelessWidget { required this.onPressed, }) : super(key: key); + @override + State createState() => _ApplicationItemState(); +} + +class _ApplicationItemState extends State + with TickerProviderStateMixin { + late AnimationController _animationController; + + @override + initState() { + super.initState(); + _animationController = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 300), + ); + } + + @override + void dispose() { + _animationController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { + ExpandableController expController = ExpandableController(); return ExpandablePanel( + controller: expController, theme: const ExpandableThemeData( + inkWellBorderRadius: BorderRadius.all(Radius.circular(16)), + tapBodyToCollapse: false, + tapBodyToExpand: false, + tapHeaderToExpand: false, hasIcon: false, animationDuration: Duration(milliseconds: 450), ), @@ -36,32 +65,44 @@ class ApplicationItem extends StatelessWidget { children: [ SizedBox( width: 60, - child: Image.memory(icon, height: 39, width: 39), + child: Image.memory(widget.icon, height: 39, width: 39), ), const SizedBox(width: 4), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - name, + widget.name, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w500, ), ), - Text(format(patchDate)), + Text(format(widget.patchDate)), ], ), const Spacer(), + 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), + ), + ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.end, children: [ CustomMaterialButton( - label: isUpdatableApp + label: widget.isUpdatableApp ? I18nText('applicationItem.patchButton') : I18nText('applicationItem.infoButton'), - onPressed: onPressed, + onPressed: widget.onPressed, ), ], ), @@ -82,7 +123,7 @@ class ApplicationItem extends StatelessWidget { ), ), const SizedBox(height: 4), - Text('\u2022 ${changelog.join('\n\u2022 ')}'), + Text('\u2022 ${widget.changelog.join('\n\u2022 ')}'), ], ), ),