Skip to content

Commit 389e4d8

Browse files
committed
Merge branch 'working'
2 parents 23bad9a + e1e7878 commit 389e4d8

File tree

6 files changed

+195
-19
lines changed

6 files changed

+195
-19
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,22 @@ jobs:
3232
- name: Getting Dependencies
3333
run: flutter pub upgrade
3434

35+
- name: Extract version from pubspec.yaml
36+
id: version
37+
run: |
38+
VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}')
39+
VERSION_NAME=$(echo $VERSION | cut -d'+' -f1)
40+
VERSION_CODE=$(echo $VERSION | cut -d'+' -f2)
41+
echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT
42+
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT
43+
3544
- name: Building APK
3645
run: flutter build apk --release
3746

3847
- name: Upload APK
3948
uses: ncipollo/release-action@v1
4049
with:
4150
artifacts: "build/app/outputs/apk/release/app-release.apk"
42-
tag: v1.0.${{ github.run_number }}
51+
tag: ${{ steps.version.outputs.version_name }}+${{ steps.version.outputs.version_code }}
52+
name: Memno v${{ steps.version.outputs.version_name }}
4353
token: ${{ secrets.MEMNO_TOKEN }}

lib/components/settings_page.dart

Lines changed: 134 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
11
import 'package:flutter/material.dart';
2+
import 'package:memno/functionality/check_update.dart';
23
import 'package:memno/theme/app_colors.dart';
34
import 'package:provider/provider.dart';
5+
import 'package:url_launcher/url_launcher.dart';
6+
import 'package:package_info_plus/package_info_plus.dart';
47

58
class SettingsPage extends StatelessWidget {
69
const SettingsPage({super.key});
710

11+
void _showDialog(
12+
BuildContext context, String title, String content, AppColors colors) {
13+
showDialog(
14+
context: context,
15+
builder: (context) => AlertDialog(
16+
backgroundColor: colors.box,
17+
title: Text(title,
18+
style: TextStyle(
19+
fontFamily: 'Product', fontSize: 20, color: colors.textClr)),
20+
content: Text(content,
21+
style: TextStyle(
22+
fontFamily: 'Product', fontSize: 18, color: colors.textClr)),
23+
actions: [
24+
TextButton(
25+
onPressed: () {
26+
Navigator.of(context).pop();
27+
},
28+
child: Text(
29+
"OK",
30+
style: TextStyle(
31+
fontFamily: 'Product', fontSize: 16, color: colors.textClr),
32+
),
33+
),
34+
],
35+
),
36+
);
37+
}
38+
839
@override
940
Widget build(BuildContext context) {
1041
final colors = Provider.of<AppColors>(context);
@@ -18,22 +49,9 @@ class SettingsPage extends StatelessWidget {
1849
),
1950
body: ListView(
2051
children: [
21-
Padding(
22-
padding: const EdgeInsets.fromLTRB(32, 16, 0, 16),
23-
child: Text("Settings",
24-
style: TextStyle(
25-
fontFamily: 'Product',
26-
fontSize: 28,
27-
color: colors.textClr)),
28-
),
29-
Container(
30-
height: 100,
31-
padding: const EdgeInsets.all(16),
32-
margin: const EdgeInsets.fromLTRB(2, 4, 2, 4),
33-
alignment: Alignment.center,
34-
decoration: BoxDecoration(
35-
borderRadius: BorderRadius.circular(50), color: colors.box),
36-
child: SwitchListTile(
52+
settingsTitle("Settings", colors),
53+
settingsContainer(
54+
SwitchListTile(
3755
title: Text("Dark Mode",
3856
style: TextStyle(
3957
fontFamily: 'Product',
@@ -44,9 +62,109 @@ class SettingsPage extends StatelessWidget {
4462
await colors.toggleTheme();
4563
},
4664
),
65+
colors,
4766
),
67+
settingsTitle("About", colors),
68+
settingsContainer(
69+
ListTile(
70+
onTap: () async {
71+
final info = await PackageInfo.fromPlatform();
72+
final currVer = info.version;
73+
if (currVer.isEmpty) {
74+
_showDialog(
75+
context.mounted ? context : context,
76+
"Version Check Failed",
77+
"Could not retrieve current version.",
78+
colors);
79+
return;
80+
}
81+
// Get latest release data from GitHub
82+
final release = await getLatestGitHubRelease();
83+
if (release == null) {
84+
_showDialog(
85+
context.mounted ? context : context,
86+
"Update Check Failed",
87+
"Could not check for updates.",
88+
colors);
89+
return;
90+
}
91+
92+
final latestVer = release['tag_name']
93+
as String; // Obtain latest version on GitHub
94+
final browserUrl = release['assets'][0]
95+
['browser_download_url']
96+
as String; // Obtain download link for the latest version
97+
if (browserUrl.isEmpty || latestVer.isEmpty) {
98+
_showDialog(
99+
context.mounted ? context : context,
100+
"Update Check Failed",
101+
"Could not find download link for the latest version.",
102+
colors);
103+
return;
104+
}
105+
if (isNewerVersion(latestVer, currVer)) {
106+
_showDialog(
107+
context.mounted ? context : context,
108+
"Update Available",
109+
"A new version ($latestVer) is available. Please update to enjoy the latest features.",
110+
colors);
111+
} else {
112+
_showDialog(
113+
context.mounted ? context : context,
114+
"No Updates",
115+
"You are using the latest version ($currVer).",
116+
colors);
117+
}
118+
},
119+
trailing: Icon(Icons.file_download_outlined,
120+
color: colors.textClr),
121+
title: Text(
122+
"Check for updates",
123+
style: TextStyle(
124+
fontFamily: 'Product',
125+
fontSize: 18,
126+
color: colors.textClr),
127+
)),
128+
colors),
129+
settingsContainer(
130+
ListTile(
131+
onTap: () {
132+
launchUrl(
133+
Uri.parse("https://github.com/jydv402/memno"));
134+
},
135+
trailing: Icon(Icons.arrow_outward_rounded,
136+
color: colors.textClr),
137+
title: Text(
138+
"Find us on GitHub",
139+
style: TextStyle(
140+
fontFamily: 'Product',
141+
fontSize: 18,
142+
color: colors.textClr),
143+
)),
144+
colors),
48145
],
49146
)),
50147
);
51148
}
149+
150+
Padding settingsTitle(String title, AppColors colors) {
151+
return Padding(
152+
padding: const EdgeInsets.fromLTRB(32, 16, 0, 16),
153+
child: Text(title,
154+
style: TextStyle(
155+
fontFamily: 'Product', fontSize: 28, color: colors.textClr)),
156+
);
157+
}
158+
159+
Container settingsContainer(Widget child, AppColors colors) {
160+
return Container(
161+
height: 100,
162+
padding: const EdgeInsets.all(16),
163+
margin: const EdgeInsets.fromLTRB(2, 4, 2, 4),
164+
alignment: Alignment.center,
165+
decoration: BoxDecoration(
166+
borderRadius: BorderRadius.circular(50), color: colors.box),
167+
child: child,
168+
);
169+
}
52170
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'dart:convert';
2+
import 'package:http/http.dart' as http;
3+
4+
Future<Map<String, dynamic>?> getLatestGitHubRelease() async {
5+
final response = await http.get(Uri.parse(
6+
"https://api.github.com/repos/jydv402/memno/releases/latest",
7+
));
8+
9+
if (response.statusCode == 200) {
10+
return jsonDecode(response.body);
11+
} else {
12+
return null;
13+
}
14+
}
15+
16+
bool isNewerVersion(String latest, String current) {
17+
print("Comparing versions: Latest: $latest, Current: $current");
18+
final latestParts = latest.split('.').map(int.parse).toList();
19+
return false;
20+
}

macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import FlutterMacOS
66
import Foundation
77

8+
import package_info_plus
89
import path_provider_foundation
910
import shared_preferences_foundation
1011
import url_launcher_macos
1112

1213
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
14+
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
1315
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
1416
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
1517
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))

pubspec.lock

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ packages:
422422
source: hosted
423423
version: "0.15.6"
424424
http:
425-
dependency: transitive
425+
dependency: "direct main"
426426
description:
427427
name: http
428428
sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
@@ -597,6 +597,22 @@ packages:
597597
url: "https://pub.dev"
598598
source: hosted
599599
version: "2.2.0"
600+
package_info_plus:
601+
dependency: "direct main"
602+
description:
603+
name: package_info_plus
604+
sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191"
605+
url: "https://pub.dev"
606+
source: hosted
607+
version: "8.3.0"
608+
package_info_plus_platform_interface:
609+
dependency: transitive
610+
description:
611+
name: package_info_plus_platform_interface
612+
sha256: "6c935fb612dff8e3cc9632c2b301720c77450a126114126ffaafe28d2e87956c"
613+
url: "https://pub.dev"
614+
source: hosted
615+
version: "3.2.0"
600616
path:
601617
dependency: transitive
602618
description:
@@ -1042,6 +1058,14 @@ packages:
10421058
url: "https://pub.dev"
10431059
source: hosted
10441060
version: "3.0.3"
1061+
win32:
1062+
dependency: transitive
1063+
description:
1064+
name: win32
1065+
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
1066+
url: "https://pub.dev"
1067+
source: hosted
1068+
version: "5.14.0"
10451069
xdg_directories:
10461070
dependency: transitive
10471071
description:

pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1616
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1717
# In Windows, build-name is used as the major, minor, and patch parts
1818
# of the product and file versions while build-number is used as the build suffix.
19-
version: 1.0.0
19+
version: 1.0.0+1
2020

2121
environment:
2222
sdk: '>=3.4.4 <4.0.0'
@@ -47,6 +47,8 @@ dependencies:
4747
lottie: ^3.1.2
4848
delightful_toast: ^1.1.0
4949
linkfy_text: ^1.1.6
50+
package_info_plus: ^8.3.0
51+
http: ^1.4.0
5052

5153

5254

0 commit comments

Comments
 (0)