import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; class AppSelectorCard extends StatelessWidget { const AppSelectorCard({ super.key, required this.onPressed, }); final Function() onPressed; @override Widget build(BuildContext context) { return CustomCard( onTap: onPressed, 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: 8), if (locator().selectedApp == null) I18nText('appSelectorCard.widgetSubtitle') else 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), Flexible( child: Text( locator().getAppSelectionString(), style: const TextStyle(fontWeight: FontWeight.w600), ), ), ], ), if (locator().selectedApp == null) Container() else Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const SizedBox(height: 4), Text( locator().getCurrentVersionString(context), ), Row( children: [ Material( color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: const BorderRadius.all(Radius.circular(8)), child: InkWell( onTap: () { locator() .searchSuggestedVersionOnWeb(); }, borderRadius: const BorderRadius.all(Radius.circular(8)), child: Container( padding: const EdgeInsets.all(4), child: Row( mainAxisSize: MainAxisSize.min, children: [ Text( locator() .getSuggestedVersionString(context), style: TextStyle( color: Theme.of(context) .colorScheme .onSecondaryContainer, ), ), const SizedBox(width: 4), Icon( Icons.search, size: 16, color: Theme.of(context) .colorScheme .onSecondaryContainer, ), ], ), ), ), ), ], ), ], ), ], ), ); } }