revanced-manager/lib/ui/widgets/patcherView/app_selector_card.dart

75 lines
2.4 KiB
Dart
Raw Normal View History

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';
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) {
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>[
I18nText(
locator<PatcherViewModel>().selectedApp == null
? 'appSelectorCard.widgetTitle'
: 'appSelectorCard.widgetTitleSelected',
child: const Text(
'',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
2022-08-02 10:33:46 +02:00
),
),
2022-09-19 18:55:44 +02:00
),
const SizedBox(height: 8),
2022-09-19 18:55:44 +02:00
locator<PatcherViewModel>().selectedApp == null
? I18nText('appSelectorCard.widgetSubtitle')
: Row(
children: <Widget>[
SizedBox(
height: 18.0,
child: ClipOval(
child: Image.memory(
locator<PatcherViewModel>().selectedApp == null
? Uint8List(0)
: locator<PatcherViewModel>().selectedApp!.icon,
fit: BoxFit.cover,
2022-08-17 18:07:00 +02:00
),
),
2022-09-19 18:55:44 +02:00
),
const SizedBox(width: 6),
Text(
locator<PatcherViewModel>()
.getAppSelectionString(),
style: const TextStyle(fontWeight: FontWeight.w600),
),
2022-09-19 18:55:44 +02:00
],
),
locator<PatcherViewModel>().selectedApp == null
? Container()
: Column(
children: [
const SizedBox(height: 4),
Text(
locator<PatcherViewModel>()
.getRecommendedVersionString(context),
2022-09-19 18:55:44 +02:00
),
],
),
],
2022-08-02 10:33:46 +02:00
),
);
}
}