2023-10-03 13:00:59 -04:00
|
|
|
import 'package:recon/client_holder.dart';
|
|
|
|
import 'package:recon/models/sem_ver.dart';
|
2023-05-06 16:12:18 -04:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
class UpdateNotifier extends StatelessWidget {
|
2023-05-07 09:01:01 -04:00
|
|
|
const UpdateNotifier({required this.remoteVersion, required this.localVersion, super.key});
|
|
|
|
|
|
|
|
final SemVer remoteVersion;
|
|
|
|
final SemVer localVersion;
|
2023-05-06 16:12:18 -04:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AlertDialog(
|
|
|
|
title: Text("Update Available", style: Theme
|
|
|
|
.of(context)
|
|
|
|
.textTheme
|
|
|
|
.titleLarge),
|
|
|
|
content: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
const Text("There is a new version available for download!"),
|
2023-05-07 09:01:01 -04:00
|
|
|
const SizedBox(height: 8,),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text("Your version: ${localVersion.toString()}"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text("New version: ${remoteVersion.toString()}"),
|
|
|
|
],
|
|
|
|
),
|
2023-05-06 16:12:18 -04:00
|
|
|
const SizedBox(height: 24,),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
TextButton.icon(
|
|
|
|
onPressed: () {
|
2023-10-03 13:00:59 -04:00
|
|
|
launchUrl(Uri.parse("https://github.com/Nutcake/ReCon/releases/latest"),
|
2023-05-06 16:12:18 -04:00
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
style: TextButton.styleFrom(
|
2023-05-07 09:01:01 -04:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),
|
|
|
|
foregroundColor: Theme
|
|
|
|
.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.onSecondary,
|
|
|
|
backgroundColor: Theme
|
|
|
|
.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.secondary
|
2023-05-06 16:12:18 -04:00
|
|
|
),
|
|
|
|
icon: const Icon(Icons.download),
|
|
|
|
label: const Text("Get it on Github"),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
actions: [
|
2023-05-07 09:01:01 -04:00
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
final sClient = ClientHolder
|
|
|
|
.of(context)
|
|
|
|
.settingsClient;
|
|
|
|
sClient.changeSettings(sClient.currentSettings.copyWith(lastDismissedVersion: remoteVersion.toString()));
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: const Text("I'll do it later."),
|
|
|
|
),
|
2023-05-06 16:12:18 -04:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|