2024-07-15 00:23:04 -04:00
|
|
|
import 'package:OpenContacts/client_holder.dart';
|
|
|
|
import 'package:OpenContacts/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: () {
|
2024-07-30 14:54:38 -04:00
|
|
|
launchUrl(Uri.parse("https://git.mrdab.vore.media/ThatOneJackalGuy/OpenContacts/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),
|
2024-07-15 02:08:17 -04:00
|
|
|
label: const Text("Get it on Forgejo"),
|
2023-05-06 16:12:18 -04:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
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
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|