revanced-manager/lib/ui/widgets/shared/application_item.dart

92 lines
2.7 KiB
Dart
Raw Normal View History

import 'dart:typed_data';
2022-08-01 13:30:06 +02:00
import 'package:flutter/material.dart';
2022-08-07 01:37:12 +02:00
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
import 'package:expandable/expandable.dart';
import 'package:timeago/timeago.dart';
2022-08-01 13:30:06 +02:00
2022-08-01 20:15:55 +02:00
class ApplicationItem extends StatelessWidget {
final Uint8List icon;
2022-08-01 13:30:06 +02:00
final String name;
final DateTime patchDate;
final List<String> changelog;
final bool isUpdatableApp;
2022-08-18 16:33:33 +02:00
final Function() onPressed;
2022-08-01 13:30:06 +02:00
2022-08-01 20:15:55 +02:00
const ApplicationItem({
2022-08-01 13:30:06 +02:00
Key? key,
required this.icon,
2022-08-01 13:30:06 +02:00
required this.name,
required this.patchDate,
2022-08-17 18:07:00 +02:00
required this.changelog,
required this.isUpdatableApp,
2022-08-01 14:24:05 +02:00
required this.onPressed,
2022-08-01 13:30:06 +02:00
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ExpandablePanel(
theme: const ExpandableThemeData(
hasIcon: false,
animationDuration: Duration(milliseconds: 450),
),
header: CustomCard(
child: Row(
children: <Widget>[
SizedBox(
width: 60,
child: Image.memory(icon, height: 39, width: 39),
),
const SizedBox(width: 4),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
Text(format(patchDate, locale: 'en_short')),
],
),
const Spacer(),
2022-09-05 14:43:13 +02:00
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
CustomMaterialButton(
label: isUpdatableApp
? I18nText('applicationItem.patchButton')
: I18nText('applicationItem.infoButton'),
onPressed: onPressed,
),
],
),
],
2022-08-01 13:30:06 +02:00
),
),
collapsed: const Text(''),
expanded: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
I18nText(
'applicationItem.changelogLabel',
child: const Text(
'',
style: TextStyle(fontWeight: FontWeight.w700),
),
),
const SizedBox(height: 4),
Text('\u2022 ${changelog.join('\n\u2022 ')}'),
],
2022-08-07 01:37:12 +02:00
),
2022-08-01 13:30:06 +02:00
),
);
}
}