2022-08-16 15:06:56 +02:00
|
|
|
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';
|
2022-08-01 13:30:06 +02:00
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
2022-08-06 23:35:35 +02:00
|
|
|
import 'package:revanced_manager/constants.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:revanced_manager/theme.dart';
|
2022-08-21 12:47:44 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/patch_text_button.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
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 {
|
2022-08-16 15:06:56 +02:00
|
|
|
final Uint8List icon;
|
2022-08-01 13:30:06 +02:00
|
|
|
final String name;
|
2022-08-16 15:06:56 +02:00
|
|
|
final DateTime patchDate;
|
2022-08-29 16:01:51 +02:00
|
|
|
final List<String> changelog;
|
2022-08-16 15:06:56 +02:00
|
|
|
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,
|
2022-08-16 15:06:56 +02:00
|
|
|
required this.icon,
|
2022-08-01 13:30:06 +02:00
|
|
|
required this.name,
|
2022-08-16 15:06:56 +02:00
|
|
|
required this.patchDate,
|
2022-08-17 18:07:00 +02:00
|
|
|
required this.changelog,
|
2022-08-16 15:06:56 +02:00
|
|
|
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) {
|
2022-08-16 15:06:56 +02:00
|
|
|
return ExpandablePanel(
|
|
|
|
theme: const ExpandableThemeData(
|
|
|
|
hasIcon: false,
|
|
|
|
animationDuration: Duration(milliseconds: 450),
|
|
|
|
),
|
|
|
|
header: Container(
|
|
|
|
height: 60,
|
|
|
|
decoration: BoxDecoration(
|
2022-09-01 02:25:19 +02:00
|
|
|
borderRadius: BorderRadius.circular(12),
|
2022-08-16 15:06:56 +02:00
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 12.0),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
width: 60,
|
|
|
|
child: Image.memory(
|
|
|
|
icon,
|
|
|
|
height: 39,
|
|
|
|
width: 39,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
SizedBox(
|
|
|
|
width: MediaQuery.of(context).size.width - 250,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
name,
|
|
|
|
style: GoogleFonts.roboto(
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
2022-08-17 18:07:00 +02:00
|
|
|
format(patchDate, locale: 'en_short'),
|
2022-08-19 15:04:40 +02:00
|
|
|
style: kRobotoTextStyle.copyWith(
|
2022-08-16 15:06:56 +02:00
|
|
|
color: Theme.of(context).colorScheme.tertiary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-16 13:12:10 +02:00
|
|
|
),
|
2022-08-16 15:06:56 +02:00
|
|
|
const Spacer(),
|
2022-08-22 01:55:54 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
|
|
child: PatchTextButton(
|
|
|
|
text: isUpdatableApp
|
|
|
|
? 'applicationItem.patchButton'
|
|
|
|
: 'applicationItem.openButton',
|
|
|
|
onPressed: onPressed,
|
|
|
|
borderColor: isDark
|
|
|
|
? const Color(0xff4D5054)
|
|
|
|
: const Color.fromRGBO(119, 146, 168, 1),
|
|
|
|
),
|
|
|
|
),
|
2022-08-16 15:06:56 +02:00
|
|
|
],
|
2022-08-01 13:30:06 +02:00
|
|
|
),
|
|
|
|
),
|
2022-08-31 10:36:36 +02:00
|
|
|
collapsed: const Text(''),
|
2022-08-16 15:06:56 +02:00
|
|
|
expanded: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
I18nText(
|
|
|
|
'applicationItem.changelogLabel',
|
|
|
|
child: Text(
|
|
|
|
'',
|
2022-08-19 15:04:40 +02:00
|
|
|
style: kRobotoTextStyle.copyWith(fontWeight: FontWeight.w700),
|
2022-08-16 15:06:56 +02:00
|
|
|
),
|
|
|
|
),
|
2022-08-29 16:01:51 +02:00
|
|
|
const SizedBox(height: 4),
|
2022-08-16 15:06:56 +02:00
|
|
|
Text(
|
2022-08-30 03:07:28 +02:00
|
|
|
'\u2022 ${changelog.join('\n\u2022 ')}',
|
2022-08-19 15:04:40 +02:00
|
|
|
style: kRobotoTextStyle,
|
2022-08-16 15:06:56 +02:00
|
|
|
),
|
|
|
|
],
|
2022-08-07 01:37:12 +02:00
|
|
|
),
|
2022-08-01 13:30:06 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|