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-02 10:33:46 +02:00
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
2022-08-09 03:30:12 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
2022-08-06 23:35:35 +02:00
|
|
|
import 'package:revanced_manager/constants.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-08-02 10:33:46 +02:00
|
|
|
|
|
|
|
class PatchSelectorCard extends StatelessWidget {
|
2022-08-18 16:33:33 +02:00
|
|
|
final Function() onPressed;
|
2022-08-11 22:17:10 +02:00
|
|
|
final Color? color;
|
|
|
|
|
2022-08-02 10:33:46 +02:00
|
|
|
const PatchSelectorCard({
|
|
|
|
Key? key,
|
2022-08-18 16:33:33 +02:00
|
|
|
required this.onPressed,
|
2022-08-11 22:17:10 +02:00
|
|
|
this.color = const Color(0xff1B222B),
|
2022-08-02 10:33:46 +02:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: onPressed,
|
|
|
|
child: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
2022-08-11 22:17:10 +02:00
|
|
|
color: color,
|
2022-08-02 10:33:46 +02:00
|
|
|
),
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2022-08-07 01:37:12 +02:00
|
|
|
I18nText(
|
2022-08-18 16:33:33 +02:00
|
|
|
locator<PatcherViewModel>().selectedPatches.isEmpty
|
2022-08-17 18:07:00 +02:00
|
|
|
? 'patchSelectorCard.widgetTitle'
|
|
|
|
: 'patchSelectorCard.widgetTitleSelected',
|
2022-08-07 01:37:12 +02:00
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: GoogleFonts.roboto(
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
2022-08-02 10:33:46 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
2022-08-18 16:33:33 +02:00
|
|
|
locator<PatcherViewModel>().selectedApp == null
|
2022-08-09 03:30:12 +02:00
|
|
|
? I18nText(
|
2022-08-15 04:31:36 +02:00
|
|
|
'patchSelectorCard.widgetSubtitle',
|
2022-08-09 03:30:12 +02:00
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: robotoTextStyle,
|
|
|
|
),
|
|
|
|
)
|
2022-08-18 16:33:33 +02:00
|
|
|
: locator<PatcherViewModel>().selectedPatches.isEmpty
|
2022-08-09 03:30:12 +02:00
|
|
|
? I18nText(
|
2022-08-15 04:31:36 +02:00
|
|
|
'patchSelectorCard.widgetEmptySubtitle',
|
2022-08-09 03:30:12 +02:00
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: robotoTextStyle,
|
|
|
|
),
|
|
|
|
)
|
2022-08-15 04:31:36 +02:00
|
|
|
: Text(
|
2022-08-15 11:55:17 +02:00
|
|
|
_getPatchesSelection(),
|
|
|
|
style: robotoTextStyle,
|
2022-08-09 03:30:12 +02:00
|
|
|
),
|
2022-08-02 10:33:46 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-08-15 11:55:17 +02:00
|
|
|
|
|
|
|
String _getPatchesSelection() {
|
|
|
|
String text = '';
|
2022-08-18 16:33:33 +02:00
|
|
|
for (Patch p in locator<PatcherViewModel>().selectedPatches) {
|
2022-08-15 11:55:17 +02:00
|
|
|
text += '${p.simpleName} (v${p.version})\n';
|
|
|
|
}
|
|
|
|
return text.substring(0, text.length - 1);
|
|
|
|
}
|
2022-08-02 10:33:46 +02:00
|
|
|
}
|