mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
2c3809d2bc
* feat: show selected patches count in patches selector view & patch selector card * fix: add Widget on row * fix: formatting * fix: same text style for count
67 lines
2.2 KiB
Dart
67 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
|
import 'package:revanced_manager/models/patch.dart';
|
|
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
|
|
|
class PatchSelectorCard extends StatelessWidget {
|
|
final Function() onPressed;
|
|
|
|
const PatchSelectorCard({
|
|
Key? key,
|
|
required this.onPressed,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomCard(
|
|
onTap: onPressed,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Row(
|
|
children: <Widget>[
|
|
I18nText(
|
|
locator<PatcherViewModel>().selectedPatches.isEmpty
|
|
? 'patchSelectorCard.widgetTitle'
|
|
: 'patchSelectorCard.widgetTitleSelected',
|
|
child: const Text(
|
|
'',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
locator<PatcherViewModel>().selectedPatches.isEmpty
|
|
? ''
|
|
: ' (${locator<PatcherViewModel>().selectedPatches.length})',
|
|
style: const TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 4),
|
|
locator<PatcherViewModel>().selectedApp == null
|
|
? I18nText('patchSelectorCard.widgetSubtitle')
|
|
: locator<PatcherViewModel>().selectedPatches.isEmpty
|
|
? I18nText('patchSelectorCard.widgetEmptySubtitle')
|
|
: Text(_getPatchesSelection()),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
String _getPatchesSelection() {
|
|
String text = '';
|
|
for (Patch p in locator<PatcherViewModel>().selectedPatches) {
|
|
text += '\u2022 ${p.getSimpleName()} (v${p.version})\n';
|
|
}
|
|
return text.substring(0, text.length - 1);
|
|
}
|
|
}
|