2022-08-17 18:07:00 +02:00
|
|
|
import 'dart:typed_data';
|
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 01:01:06 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.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 AppSelectorCard extends StatelessWidget {
|
2022-08-18 16:33:33 +02:00
|
|
|
final Function() onPressed;
|
2022-08-11 22:17:10 +02:00
|
|
|
|
2022-08-18 16:33:33 +02:00
|
|
|
const AppSelectorCard({
|
2022-08-02 10:33:46 +02:00
|
|
|
Key? key,
|
2022-08-18 16:33:33 +02:00
|
|
|
required this.onPressed,
|
2022-08-02 10:33:46 +02:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: onPressed,
|
2022-09-05 04:32:36 +02:00
|
|
|
child: CustomCard(
|
2022-08-02 10:33:46 +02:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-07 01:37:12 +02:00
|
|
|
I18nText(
|
2022-08-18 16:33:33 +02:00
|
|
|
locator<PatcherViewModel>().selectedApp == null
|
2022-08-17 18:07:00 +02:00
|
|
|
? 'appSelectorCard.widgetTitle'
|
|
|
|
: 'appSelectorCard.widgetTitleSelected',
|
2022-09-05 04:32:36 +02:00
|
|
|
child: const Text(
|
2022-08-07 01:37:12 +02:00
|
|
|
'',
|
2022-09-05 04:32:36 +02:00
|
|
|
style: TextStyle(
|
2022-08-07 01:37:12 +02:00
|
|
|
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-09-05 04:32:36 +02:00
|
|
|
? I18nText('appSelectorCard.widgetSubtitle')
|
2022-08-17 18:07:00 +02:00
|
|
|
: Row(
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-17 18:07:00 +02:00
|
|
|
SizedBox(
|
|
|
|
height: 16.0,
|
|
|
|
child: ClipOval(
|
|
|
|
child: Image.memory(
|
2022-08-18 16:33:33 +02:00
|
|
|
locator<PatcherViewModel>().selectedApp == null
|
2022-08-17 18:07:00 +02:00
|
|
|
? Uint8List(0)
|
2022-08-18 16:33:33 +02:00
|
|
|
: locator<PatcherViewModel>().selectedApp!.icon,
|
2022-08-17 18:07:00 +02:00
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: 4),
|
2022-09-05 04:32:36 +02:00
|
|
|
Text(_getAppSelection()),
|
2022-08-17 18:07:00 +02:00
|
|
|
],
|
2022-08-09 01:01:06 +02:00
|
|
|
),
|
2022-08-02 10:33:46 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-08-15 11:55:17 +02:00
|
|
|
|
|
|
|
String _getAppSelection() {
|
2022-08-18 16:33:33 +02:00
|
|
|
String name = locator<PatcherViewModel>().selectedApp!.name;
|
|
|
|
String version = locator<PatcherViewModel>().selectedApp!.version;
|
2022-08-15 11:55:17 +02:00
|
|
|
return '$name (v$version)';
|
|
|
|
}
|
2022-08-02 10:33:46 +02:00
|
|
|
}
|