2022-08-02 10:33:46 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-07 01:37:12 +02:00
|
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
2022-08-09 03:30:12 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
2022-08-15 11:55:17 +02:00
|
|
|
import 'package:revanced_manager/models/patch.dart';
|
2022-08-18 16:33:33 +02:00
|
|
|
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
2022-09-05 04:32:36 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
2022-08-02 10:33:46 +02:00
|
|
|
|
|
|
|
class PatchSelectorCard extends StatelessWidget {
|
|
|
|
const PatchSelectorCard({
|
2023-11-11 13:07:32 +01:00
|
|
|
super.key,
|
2022-08-18 16:33:33 +02:00
|
|
|
required this.onPressed,
|
2023-11-11 13:07:32 +01:00
|
|
|
});
|
2023-01-30 13:35:06 +01:00
|
|
|
final Function() onPressed;
|
2022-08-02 10:33:46 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-19 18:55:44 +02:00
|
|
|
return CustomCard(
|
2022-08-02 10:33:46 +02:00
|
|
|
onTap: onPressed,
|
2022-09-19 18:55:44 +02:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2022-11-09 08:32:39 +01:00
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
|
|
|
I18nText(
|
|
|
|
locator<PatcherViewModel>().selectedPatches.isEmpty
|
|
|
|
? 'patchSelectorCard.widgetTitle'
|
|
|
|
: 'patchSelectorCard.widgetTitleSelected',
|
|
|
|
child: const Text(
|
|
|
|
'',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
2022-08-02 10:33:46 +02:00
|
|
|
),
|
2022-11-09 08:32:39 +01:00
|
|
|
Text(
|
|
|
|
locator<PatcherViewModel>().selectedPatches.isEmpty
|
|
|
|
? ''
|
|
|
|
: ' (${locator<PatcherViewModel>().selectedPatches.length})',
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-09-19 18:55:44 +02:00
|
|
|
),
|
2022-09-25 14:43:37 +02:00
|
|
|
const SizedBox(height: 4),
|
2023-01-30 13:35:06 +01:00
|
|
|
if (locator<PatcherViewModel>().selectedApp == null)
|
|
|
|
I18nText('patchSelectorCard.widgetSubtitle')
|
|
|
|
else
|
|
|
|
locator<PatcherViewModel>().selectedPatches.isEmpty
|
|
|
|
? I18nText('patchSelectorCard.widgetEmptySubtitle')
|
|
|
|
: Text(_getPatchesSelection()),
|
2022-09-19 18:55:44 +02:00
|
|
|
],
|
2022-08-02 10:33:46 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-08-15 11:55:17 +02:00
|
|
|
|
|
|
|
String _getPatchesSelection() {
|
|
|
|
String text = '';
|
2023-10-10 13:54:42 +02:00
|
|
|
final List<Patch> selectedPatches = locator<PatcherViewModel>().selectedPatches;
|
|
|
|
selectedPatches.sort((a, b) => a.name.compareTo(b.name));
|
|
|
|
for (final Patch p in selectedPatches) {
|
2023-10-12 02:00:39 +02:00
|
|
|
text += '• ${p.getSimpleName()}\n';
|
2022-08-15 11:55:17 +02:00
|
|
|
}
|
|
|
|
return text.substring(0, text.length - 1);
|
|
|
|
}
|
2022-08-02 10:33:46 +02:00
|
|
|
}
|