mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
34365239c1
Co-authored-by: aAbed <aabedhkhan@gmail.com>
147 lines
5.7 KiB
Dart
147 lines
5.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
|
import 'package:revanced_manager/gen/strings.g.dart';
|
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
|
|
|
class UpdateConfirmationSheet extends StatelessWidget {
|
|
const UpdateConfirmationSheet({
|
|
super.key,
|
|
required this.isPatches,
|
|
this.changelog = false,
|
|
});
|
|
|
|
final bool isPatches;
|
|
final bool changelog;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final HomeViewModel model = locator<HomeViewModel>();
|
|
|
|
return DraggableScrollableSheet(
|
|
expand: false,
|
|
snap: true,
|
|
snapSizes: const [0.5],
|
|
builder: (_, scrollController) => SingleChildScrollView(
|
|
controller: scrollController,
|
|
child: SafeArea(
|
|
child: FutureBuilder<Map<String, dynamic>?>(
|
|
future: !isPatches
|
|
? model.getLatestManagerRelease()
|
|
: model.getLatestPatchesRelease(),
|
|
builder: (_, snapshot) {
|
|
if (!snapshot.hasData) {
|
|
return const SizedBox(
|
|
height: 300,
|
|
child: Center(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
);
|
|
}
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (!changelog)
|
|
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: [
|
|
Text(
|
|
isPatches
|
|
? t.homeView.updatePatchesSheetTitle
|
|
: t.homeView.updateSheetTitle,
|
|
style: const TextStyle(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 4.0),
|
|
Row(
|
|
children: [
|
|
Icon(
|
|
Icons.new_releases_outlined,
|
|
color: Theme.of(context)
|
|
.colorScheme
|
|
.secondary,
|
|
),
|
|
const SizedBox(width: 8.0),
|
|
Text(
|
|
snapshot.data!['tag_name'] ?? 'Unknown',
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w500,
|
|
color: Theme.of(context)
|
|
.colorScheme
|
|
.secondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
FilledButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
isPatches
|
|
? model.updatePatches(context)
|
|
: model.updateManager(context);
|
|
},
|
|
child: Text(t.updateButton),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(
|
|
top: 12.0,
|
|
left: 24.0,
|
|
bottom: 12.0,
|
|
),
|
|
child: Text(
|
|
t.homeView.updateChangelogTitle,
|
|
style: TextStyle(
|
|
fontSize: changelog ? 24 : 20,
|
|
fontWeight: FontWeight.w500,
|
|
color:
|
|
Theme.of(context).colorScheme.onSecondaryContainer,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 24.0),
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.secondaryContainer,
|
|
borderRadius: BorderRadius.circular(12.0),
|
|
),
|
|
child: Markdown(
|
|
styleSheet: MarkdownStyleSheet(
|
|
a: TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
),
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
padding: const EdgeInsets.all(20.0),
|
|
data: snapshot.data!['body'] ?? '',
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|