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-09-05 04:32:36 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.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-09-15 21:19:11 +02:00
|
|
|
class ApplicationItem extends StatefulWidget {
|
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);
|
|
|
|
|
2022-09-15 21:19:11 +02:00
|
|
|
@override
|
|
|
|
State<ApplicationItem> createState() => _ApplicationItemState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ApplicationItemState extends State<ApplicationItem>
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
late AnimationController _animationController;
|
|
|
|
|
|
|
|
@override
|
|
|
|
initState() {
|
|
|
|
super.initState();
|
|
|
|
_animationController = AnimationController(
|
|
|
|
vsync: this,
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_animationController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2022-08-01 13:30:06 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-15 21:19:11 +02:00
|
|
|
ExpandableController expController = ExpandableController();
|
2022-08-16 15:06:56 +02:00
|
|
|
return ExpandablePanel(
|
2022-09-15 21:19:11 +02:00
|
|
|
controller: expController,
|
2022-08-16 15:06:56 +02:00
|
|
|
theme: const ExpandableThemeData(
|
2022-09-15 21:19:11 +02:00
|
|
|
inkWellBorderRadius: BorderRadius.all(Radius.circular(16)),
|
|
|
|
tapBodyToCollapse: false,
|
|
|
|
tapBodyToExpand: false,
|
|
|
|
tapHeaderToExpand: false,
|
2022-08-16 15:06:56 +02:00
|
|
|
hasIcon: false,
|
|
|
|
animationDuration: Duration(milliseconds: 450),
|
|
|
|
),
|
2022-09-05 04:32:36 +02:00
|
|
|
header: CustomCard(
|
2022-08-16 15:06:56 +02:00
|
|
|
child: Row(
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-16 15:06:56 +02:00
|
|
|
SizedBox(
|
2022-09-17 10:02:49 +02:00
|
|
|
width: 40,
|
|
|
|
child: Image.memory(widget.icon, height: 40, width: 40),
|
2022-08-16 15:06:56 +02:00
|
|
|
),
|
|
|
|
const SizedBox(width: 4),
|
2022-09-17 10:02:49 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 15.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
widget.name,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(format(widget.patchDate)),
|
|
|
|
],
|
2022-09-05 04:32:36 +02:00
|
|
|
),
|
2022-08-16 13:12:10 +02:00
|
|
|
),
|
2022-08-16 15:06:56 +02:00
|
|
|
const Spacer(),
|
2022-09-17 10:02:49 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 5.0),
|
|
|
|
child: RotationTransition(
|
|
|
|
turns: Tween(begin: 0.0, end: 0.50).animate(_animationController),
|
|
|
|
child: IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
expController.toggle();
|
|
|
|
_animationController.isCompleted
|
|
|
|
? _animationController.reverse()
|
|
|
|
: _animationController.forward();
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.arrow_drop_down),
|
|
|
|
),
|
2022-09-15 21:19:11 +02:00
|
|
|
),
|
|
|
|
),
|
2022-09-05 14:43:13 +02:00
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: <Widget>[
|
|
|
|
CustomMaterialButton(
|
2022-09-15 21:19:11 +02:00
|
|
|
label: widget.isUpdatableApp
|
2022-09-05 14:43:13 +02:00
|
|
|
? I18nText('applicationItem.patchButton')
|
|
|
|
: I18nText('applicationItem.infoButton'),
|
2022-09-15 21:19:11 +02:00
|
|
|
onPressed: widget.onPressed,
|
2022-09-05 14:43:13 +02:00
|
|
|
),
|
|
|
|
],
|
2022-08-22 01:55:54 +02:00
|
|
|
),
|
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(
|
2022-09-17 10:02:49 +02:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
|
2022-08-16 15:06:56 +02:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-16 15:06:56 +02:00
|
|
|
I18nText(
|
|
|
|
'applicationItem.changelogLabel',
|
2022-09-05 04:32:36 +02:00
|
|
|
child: const Text(
|
2022-08-16 15:06:56 +02:00
|
|
|
'',
|
2022-09-05 04:32:36 +02:00
|
|
|
style: TextStyle(fontWeight: FontWeight.w700),
|
2022-08-16 15:06:56 +02:00
|
|
|
),
|
|
|
|
),
|
2022-08-29 16:01:51 +02:00
|
|
|
const SizedBox(height: 4),
|
2022-09-15 21:19:11 +02:00
|
|
|
Text('\u2022 ${widget.changelog.join('\n\u2022 ')}'),
|
2022-08-16 15:06:56 +02:00
|
|
|
],
|
2022-08-07 01:37:12 +02:00
|
|
|
),
|
2022-08-01 13:30:06 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|