2022-08-07 02:13:27 +02:00
|
|
|
import 'dart:typed_data';
|
2022-08-02 11:19:14 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2023-06-12 02:05:02 +02:00
|
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
2023-06-12 02:31:57 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
2022-08-02 11:19:14 +02:00
|
|
|
|
2022-08-02 12:26:37 +02:00
|
|
|
class InstalledAppItem extends StatefulWidget {
|
2022-08-07 02:13:27 +02:00
|
|
|
const InstalledAppItem({
|
2022-08-02 11:19:14 +02:00
|
|
|
Key? key,
|
|
|
|
required this.name,
|
|
|
|
required this.pkgName,
|
2022-08-07 02:13:27 +02:00
|
|
|
required this.icon,
|
2022-12-15 19:05:45 +01:00
|
|
|
required this.patchesCount,
|
2023-04-29 15:00:00 +02:00
|
|
|
required this.suggestedVersion,
|
2023-06-12 02:05:02 +02:00
|
|
|
required this.installedVersion,
|
2022-09-19 18:55:44 +02:00
|
|
|
this.onTap,
|
2022-08-02 11:19:14 +02:00
|
|
|
}) : super(key: key);
|
2023-01-30 13:35:06 +01:00
|
|
|
final String name;
|
|
|
|
final String pkgName;
|
|
|
|
final Uint8List icon;
|
|
|
|
final int patchesCount;
|
2023-04-29 15:00:00 +02:00
|
|
|
final String suggestedVersion;
|
2023-06-12 02:05:02 +02:00
|
|
|
final String installedVersion;
|
2023-01-30 13:35:06 +01:00
|
|
|
final Function()? onTap;
|
2022-08-02 11:19:14 +02:00
|
|
|
|
2022-08-02 12:26:37 +02:00
|
|
|
@override
|
|
|
|
State<InstalledAppItem> createState() => _InstalledAppItemState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _InstalledAppItemState extends State<InstalledAppItem> {
|
2022-08-02 11:19:14 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-09 01:01:06 +02:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
2022-09-05 04:32:36 +02:00
|
|
|
child: CustomCard(
|
2022-09-19 18:55:44 +02:00
|
|
|
onTap: widget.onTap,
|
2022-08-09 01:01:06 +02:00
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-09 01:01:06 +02:00
|
|
|
Container(
|
|
|
|
width: 48,
|
|
|
|
height: 48,
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: CircleAvatar(
|
2022-08-12 20:23:25 +02:00
|
|
|
backgroundColor: Colors.transparent,
|
2022-08-09 01:01:06 +02:00
|
|
|
child: Image.memory(widget.icon),
|
2022-08-07 02:13:27 +02:00
|
|
|
),
|
2022-08-09 01:01:06 +02:00
|
|
|
),
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2023-06-16 09:04:55 +02:00
|
|
|
Text(
|
|
|
|
widget.name,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.visible,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
2023-06-12 02:05:02 +02:00
|
|
|
),
|
|
|
|
Text(widget.pkgName),
|
2023-06-16 09:04:55 +02:00
|
|
|
I18nText(
|
|
|
|
FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'installed',
|
|
|
|
translationParams: {
|
2023-07-10 14:36:50 +02:00
|
|
|
'version': 'v${widget.installedVersion}'
|
2023-06-16 09:04:55 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2023-06-12 02:05:02 +02:00
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
I18nText(
|
2023-06-23 15:39:12 +02:00
|
|
|
'suggested',
|
|
|
|
translationParams: {
|
2023-07-10 14:36:50 +02:00
|
|
|
'version': widget.suggestedVersion.isEmpty
|
|
|
|
? FlutterI18n.translate(
|
2023-07-10 14:45:50 +02:00
|
|
|
context,
|
|
|
|
'appSelectorCard.allVersions',
|
|
|
|
)
|
2023-06-23 15:39:12 +02:00
|
|
|
: 'v${widget.suggestedVersion}',
|
|
|
|
},
|
2023-06-12 02:31:57 +02:00
|
|
|
),
|
2023-06-12 02:05:02 +02:00
|
|
|
const SizedBox(width: 4),
|
2023-07-12 20:29:47 +02:00
|
|
|
Flexible(
|
|
|
|
child: Text(
|
|
|
|
widget.patchesCount == 1
|
|
|
|
? '• ${widget.patchesCount} patch'
|
|
|
|
: '• ${widget.patchesCount} patches',
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
),
|
2022-12-15 19:05:45 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-08-09 01:01:06 +02:00
|
|
|
),
|
|
|
|
],
|
2022-08-02 12:26:37 +02:00
|
|
|
),
|
2022-08-09 01:01:06 +02:00
|
|
|
),
|
|
|
|
],
|
2022-08-02 11:19:14 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|