2022-11-29 16:45:44 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
2024-02-12 00:22:25 +01:00
|
|
|
import 'package:revanced_manager/gen/strings.g.dart';
|
2022-11-29 16:45:44 +01:00
|
|
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
|
|
|
|
2024-01-25 18:20:34 +01:00
|
|
|
class UpdateConfirmationSheet extends StatelessWidget {
|
2024-02-12 20:46:58 +01:00
|
|
|
const UpdateConfirmationSheet({
|
|
|
|
super.key,
|
|
|
|
required this.isPatches,
|
|
|
|
this.changelog = false,
|
|
|
|
});
|
2022-11-29 16:45:44 +01:00
|
|
|
|
2023-08-03 22:23:56 +02:00
|
|
|
final bool isPatches;
|
2024-01-25 18:20:34 +01:00
|
|
|
final bool changelog;
|
2022-11-29 16:45:44 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final HomeViewModel model = locator<HomeViewModel>();
|
|
|
|
|
|
|
|
return DraggableScrollableSheet(
|
|
|
|
expand: false,
|
|
|
|
snap: true,
|
|
|
|
snapSizes: const [0.5],
|
2023-04-18 16:15:29 +02:00
|
|
|
builder: (_, scrollController) => SingleChildScrollView(
|
2022-11-29 16:45:44 +01:00
|
|
|
controller: scrollController,
|
|
|
|
child: SafeArea(
|
|
|
|
child: FutureBuilder<Map<String, dynamic>?>(
|
2023-08-03 22:23:56 +02:00
|
|
|
future: !isPatches
|
|
|
|
? model.getLatestManagerRelease()
|
|
|
|
: model.getLatestPatchesRelease(),
|
2023-04-18 16:15:29 +02:00
|
|
|
builder: (_, snapshot) {
|
2022-11-29 16:45:44 +01:00
|
|
|
if (!snapshot.hasData) {
|
|
|
|
return const SizedBox(
|
|
|
|
height: 300,
|
|
|
|
child: Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2024-01-25 18:20:34 +01:00
|
|
|
if (!changelog)
|
2024-02-12 20:46:58 +01:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 40.0,
|
|
|
|
left: 24.0,
|
|
|
|
right: 24.0,
|
|
|
|
bottom: 20.0,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2024-02-12 00:22:25 +01:00
|
|
|
Text(
|
2024-02-12 20:46:58 +01:00
|
|
|
isPatches
|
2024-02-12 00:22:25 +01:00
|
|
|
? t.homeView.updatePatchesSheetTitle
|
|
|
|
: t.homeView.updateSheetTitle,
|
|
|
|
style: const TextStyle(
|
2024-02-12 20:46:58 +01:00
|
|
|
fontSize: 24,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2022-11-29 16:45:44 +01:00
|
|
|
),
|
2024-02-12 20:46:58 +01:00
|
|
|
const SizedBox(height: 4.0),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
Icons.new_releases_outlined,
|
2022-11-29 16:45:44 +01:00
|
|
|
color: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.secondary,
|
|
|
|
),
|
2024-02-12 20:46:58 +01:00
|
|
|
const SizedBox(width: 8.0),
|
|
|
|
Text(
|
|
|
|
snapshot.data!['tag_name'] ?? 'Unknown',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.secondary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-11-29 16:45:44 +01:00
|
|
|
),
|
2024-02-12 20:46:58 +01:00
|
|
|
FilledButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
isPatches
|
|
|
|
? model.updatePatches(context)
|
|
|
|
: model.updateManager(context);
|
|
|
|
},
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(t.updateButton),
|
2024-02-12 20:46:58 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-11-29 16:45:44 +01:00
|
|
|
),
|
|
|
|
Padding(
|
2024-02-12 20:46:58 +01:00
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 12.0,
|
|
|
|
left: 24.0,
|
|
|
|
bottom: 12.0,
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(
|
|
|
|
t.homeView.updateChangelogTitle,
|
|
|
|
style: TextStyle(
|
2024-02-12 20:46:58 +01:00
|
|
|
fontSize: changelog ? 24 : 20,
|
2024-02-12 00:22:25 +01:00
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color:
|
|
|
|
Theme.of(context).colorScheme.onSecondaryContainer,
|
2023-01-30 13:35:06 +01:00
|
|
|
),
|
2022-11-29 16:45:44 +01:00
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
Container(
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 24.0),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).colorScheme.secondaryContainer,
|
|
|
|
borderRadius: BorderRadius.circular(12.0),
|
|
|
|
),
|
|
|
|
child: Markdown(
|
2024-02-12 20:46:58 +01:00
|
|
|
styleSheet: MarkdownStyleSheet(
|
|
|
|
a: TextStyle(
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
shrinkWrap: true,
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
data: snapshot.data!['body'] ?? '',
|
|
|
|
),
|
2022-11-29 16:45:44 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|