56 lines
1.8 KiB
Dart
Raw Normal View History

2022-08-02 14:03:46 +05:30
import 'package:flutter/material.dart';
2022-08-07 00:37:12 +01:00
import 'package:flutter_i18n/flutter_i18n.dart';
2022-08-09 02:30:12 +01:00
import 'package:revanced_manager/app/app.locator.dart';
2022-08-15 10:55:17 +01:00
import 'package:revanced_manager/models/patch.dart';
2022-08-18 15:33:33 +01:00
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
2022-08-02 14:03:46 +05:30
class PatchSelectorCard extends StatelessWidget {
2022-08-18 15:33:33 +01:00
final Function() onPressed;
2022-08-12 01:47:10 +05:30
2022-08-02 14:03:46 +05:30
const PatchSelectorCard({
Key? key,
2022-08-18 15:33:33 +01:00
required this.onPressed,
2022-08-02 14:03:46 +05:30
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onPressed,
child: CustomCard(
2022-08-02 14:03:46 +05:30
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
2022-08-07 00:37:12 +01:00
I18nText(
2022-08-18 15:33:33 +01:00
locator<PatcherViewModel>().selectedPatches.isEmpty
2022-08-17 17:07:00 +01:00
? 'patchSelectorCard.widgetTitle'
: 'patchSelectorCard.widgetTitleSelected',
child: const Text(
2022-08-07 00:37:12 +01:00
'',
style: TextStyle(
2022-08-07 00:37:12 +01:00
fontSize: 18,
fontWeight: FontWeight.w500,
),
2022-08-02 14:03:46 +05:30
),
),
const SizedBox(height: 10),
2022-08-18 15:33:33 +01:00
locator<PatcherViewModel>().selectedApp == null
? I18nText('patchSelectorCard.widgetSubtitle')
2022-08-18 15:33:33 +01:00
: locator<PatcherViewModel>().selectedPatches.isEmpty
? I18nText('patchSelectorCard.widgetEmptySubtitle')
: Text(_getPatchesSelection()),
2022-08-02 14:03:46 +05:30
],
),
),
);
}
2022-08-15 10:55:17 +01:00
String _getPatchesSelection() {
String text = '';
2022-08-18 15:33:33 +01:00
for (Patch p in locator<PatcherViewModel>().selectedPatches) {
text += '${p.getSimpleName()} (v${p.version})\n';
2022-08-15 10:55:17 +01:00
}
return text.substring(0, text.length - 1);
}
2022-08-02 14:03:46 +05:30
}