revanced-manager/lib/ui/widgets/appSelectorView/installed_app_item.dart

146 lines
5.3 KiB
Dart
Raw Normal View History

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';
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({
2023-11-11 13:07:32 +01:00
super.key,
2022-08-02 11:19:14 +02:00
required this.name,
required this.pkgName,
2022-08-07 02:13:27 +02:00
required this.icon,
required this.patchesCount,
required this.suggestedVersion,
required this.installedVersion,
2022-09-19 18:55:44 +02:00
this.onTap,
this.onLinkTap,
2023-11-11 13:07:32 +01:00
});
final String name;
final String pkgName;
final Uint8List icon;
final int patchesCount;
final String suggestedVersion;
final String installedVersion;
final Function()? onTap;
final Function()? onLinkTap;
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),
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,
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(
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,
children: <Widget>[
Text(
widget.name,
maxLines: 2,
overflow: TextOverflow.visible,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
Text(widget.pkgName),
I18nText(
FlutterI18n.translate(
context,
'installed',
translationParams: {
'version': 'v${widget.installedVersion}',
},
),
),
2023-08-03 23:38:38 +02:00
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Material(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius:
const BorderRadius.all(Radius.circular(8)),
child: InkWell(
onTap: widget.onLinkTap,
borderRadius:
const BorderRadius.all(Radius.circular(8)),
child: Container(
padding: const EdgeInsets.all(4),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
I18nText(
'suggested',
translationParams: {
'version': widget.suggestedVersion.isEmpty
? FlutterI18n.translate(
context,
'appSelectorCard.allVersions',
)
: 'v${widget.suggestedVersion}',
},
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSecondaryContainer,
),
),
),
const SizedBox(width: 4),
Icon(
Icons.search,
size: 16,
color: Theme.of(context)
.colorScheme
.onSecondaryContainer,
),
],
),
),
),
2023-06-12 02:31:57 +02:00
),
const SizedBox(width: 4),
2023-08-03 23:38:38 +02:00
Text(
widget.patchesCount == 1
? '${widget.patchesCount} patch'
: '${widget.patchesCount} patches',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
],
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
),
),
);
}
}