Compare commits

...

127 Commits

Author SHA1 Message Date
Márton Kiss
f4d840462e Merge branch 'dev' into master 2025-01-03 15:26:35 +01:00
Marton Kiss
b08b127895 yes 2025-01-03 15:22:29 +01:00
Marton Kiss
d41872e6e2 updated sdk requirement 2025-01-03 15:22:01 +01:00
Marton Kiss
0602c2ea3f optimized and updated things 2025-01-03 15:21:28 +01:00
Kima
afcff10862 some progress in cloud sync and paypal support almost done 2024-12-02 23:13:26 +01:00
Kima
9e187fc04c Merge branch 'dev' of github.com:refilc/naplo into dev 2024-11-16 22:21:26 +01:00
Kima
7d5b97fe00 started working on cloud sync (testing) 2024-11-16 22:21:22 +01:00
Márton Kiss
fd3b21b8e6 Merge pull request #142 from balint1414/dev
gradestreak probléma javítás: nem ignorálja a szöveges értékelést
2024-11-16 19:55:53 +01:00
balint1414
071f682f77 gradestreak: javítás (2) 2024-11-16 15:41:41 +01:00
balint1414
8723f75889 gradestreak probléma javítás: nem ignorálja a szöveges értékelést 2024-11-16 12:25:27 +01:00
Kima
c9666f5333 Merge branch 'dev' of github.com:refilc/naplo into dev 2024-11-15 23:55:05 +01:00
Kima
a218b62742 removed unused dependencies 2024-11-15 23:53:39 +01:00
Kima
41b1d899d0 removed unused dependencies 2024-11-15 23:52:40 +01:00
Márton Kiss
ad18efd340 Merge pull request #131 from balint1414/dev
Fektetett órarend hibás kiírás javítása
2024-11-15 21:00:46 +01:00
balint1414
cf0dc50df5 Fektetett órarend: 0. óra és utolsó óra megjelenítése 2024-11-15 20:43:18 +01:00
Márton Kiss
994d3085bb Merge pull request #141 from refilc/dev
dev to master
2024-11-14 21:14:46 +01:00
Kima
6292708ba0 changed build number 2024-11-14 21:14:13 +01:00
Kima
a26ca67892 Merge branch 'dev' of github.com:refilc/naplo into dev 2024-11-14 21:13:11 +01:00
Kima
f2d6b6079e fixed qr scanner size on smaller phones 2024-11-14 21:13:06 +01:00
Márton Kiss
4faee05823 Merge pull request #140 from refilc/master
everything back to dev
2024-11-14 17:14:34 +01:00
Márton Kiss
864701fd1e Merge pull request #139 from refilc/dev
dev to master
2024-11-14 17:13:45 +01:00
Kima
80d50cd82b Merge branch 'dev' of github.com:refilc/naplo into dev 2024-11-14 17:12:41 +01:00
Kima
521f609707 forgot to push lol 2024-11-14 17:12:38 +01:00
Tihanyi Marcell
96ff70d7d5 Merge pull request #138 from refilc/dev
Bitcode removal, Crash fixed caused by Live Activity
2024-11-14 15:10:46 +01:00
Tihanyi Marcell
658bfe38a3 Bitcode removal, Crash fixed caused by Live Activity 2024-11-14 15:06:38 +01:00
Márton Kiss
a74b2cd3d7 Merge pull request #137 from refilc/dev
dev to master
2024-11-13 21:08:13 +01:00
Kima
414755c777 okay that's it bye 2024-11-13 20:51:24 +01:00
Kima
3708b917c4 finished qr scanner (test) 2024-11-13 20:25:13 +01:00
Kima
986b13de68 changed version number 2024-11-13 19:12:09 +01:00
Kima
d391448870 remove prints 2024-11-13 19:11:08 +01:00
Kima
38d9b5f3b2 fixed login finally 2024-11-13 19:10:48 +01:00
Kima
2dafe5ed02 updated packages, did things and maybe finally fixed login issue 2024-11-12 23:27:14 +01:00
Kima
939761695f working error handling for theme sharing 2024-10-10 20:48:21 +02:00
Kima
f1ba5230fc added theme share error handling for ratelimit response 2024-10-10 18:11:41 +02:00
Kima
a50f449f7c added extra fields in news objects 2024-10-07 22:33:52 +02:00
Kima
fe3ed31830 added new analytics option to db 2024-10-06 23:56:56 +02:00
Kima
0ec33f8631 changed subscription document acceptance 2024-10-06 23:53:24 +02:00
Kima
6634010b97 made re-activation easier 2024-10-02 21:17:03 +02:00
Kima
816ddf58a2 changed how analytics work 2024-10-02 21:06:01 +02:00
Kima
d7741ca1c4 tried testing sync bug and fixed ads even more 2024-09-28 17:33:57 +02:00
Kima
a2cbe5d90b changed version number 2024-09-28 17:04:28 +02:00
Kima
7919d0e284 added grade delay to details and other small shit 2024-09-27 23:07:18 +02:00
Kima
92fe3b7dcd fixed yellow lines at profile image grade streak indicator 2024-09-27 22:02:31 +02:00
Kima
63fd37c31f the ads got more acceptable 2024-09-27 21:37:06 +02:00
Kima
aa10f0672e show ads only in even hours 2024-09-27 21:30:32 +02:00
Kima
a3694b59ec doing something with ads 2024-09-27 21:28:07 +02:00
Kima
9ecee0bb01 hide "ads" if user has plus 2024-09-27 20:51:01 +02:00
balint1414
b9e9bef182 Fektetett órarend hibás kiírás javítása 2024-09-03 18:49:55 +02:00
zypherift
51297ddc09 Merge branch 'dev' of github.com:refilc/naplo into dev 2024-08-22 22:46:13 +02:00
zypherift
4d64705e59 fix for padding 2024-08-22 22:46:11 +02:00
Márton Kiss
d642f19834 Merge pull request #130 from refilc/dev
dev to master
2024-08-22 22:08:37 +02:00
Kima
51b25395c1 version change 2024-08-22 22:08:11 +02:00
Kima
4474562538 login fix 2024-08-22 22:04:05 +02:00
zypherift
d93dce7857 maybe fix 2024-08-22 21:57:42 +02:00
zypherift
d6fe2812c7 fine tune anim speed 2024-08-22 21:27:22 +02:00
zypherift
ed0f69d155 add animation to fade in (pain) 2024-08-22 21:23:20 +02:00
zypherift
c4a17633f8 fix that, and add new progress indicator 2024-08-22 20:58:12 +02:00
zypherift
d426d4866a fix this 2024-08-22 20:57:56 +02:00
zypherift
89adf5a26f change trans from E-kreta to e-KRETA 2024-08-22 20:47:07 +02:00
zypherift
117ee63b18 Merge branch 'dev' of github.com:refilc/naplo into dev 2024-08-22 20:45:16 +02:00
zypherift
d27b5f8a51 re-revert new login 2024-08-22 20:45:14 +02:00
Kima
9671c250b9 Revert "change kretenlogin to widget"
This reverts commit 2d5c270641.
2024-08-21 23:33:15 +02:00
zypherift
2d5c270641 change kretenlogin to widget 2024-08-21 23:22:27 +02:00
zypherift
eda093a9b5 change trans 2024-08-21 21:54:49 +02:00
Kima
544e9c214a some modifications in login refresh 2024-08-18 13:27:52 +02:00
Kima
5c3dbcbd52 fixed privacy button and back button on new login screen 2024-08-18 13:00:40 +02:00
Kima
cd5f86db00 Merge branch 'dev' of github.com:refilc/naplo into dev 2024-08-17 23:34:43 +02:00
Kima
9adfe636d6 maybe finally fixed ios login problem (i hope so) 2024-08-17 23:34:39 +02:00
zypherift
210e8ce0d4 change gradient start 2024-08-16 18:14:14 +02:00
zypherift
b1a7deca4a change height again, and make text proportional 2024-08-16 17:49:44 +02:00
zypherift
fa96770c9c fix padding :3 2024-08-16 17:46:14 +02:00
zypherift
5be67693c2 recolor navbar, and change padding on login btn part 2024-08-16 17:38:26 +02:00
zypherift
9ee5e8a35e image again 2024-08-16 16:58:53 +02:00
zypherift
3372c1ffde Merge branch 'dev' of github.com:refilc/naplo into dev 2024-08-16 16:42:13 +02:00
zypherift
94989687fa add higher kualiti images 2024-08-16 16:40:03 +02:00
Kima
52b9b4f5db maybe fixed ios login 2024-08-16 14:40:48 +02:00
Kima
75a2fa3726 changed location of privacy button 2024-08-16 11:48:41 +02:00
Márton Kiss
2c1bde9398 Merge pull request #128 from refilc/dev
dev to master
2024-08-16 01:06:26 +02:00
Kima
fd9794f3bf changed build number 2024-08-16 00:49:00 +02:00
Kima
a673d3f1b3 finally the new login is completely working with refresh token as well 2024-08-16 00:25:46 +02:00
Kima
f2c8e869b5 moved news 2024-08-14 23:42:26 +02:00
Kima
b4f2d38e99 changed launch mode to in-app 2024-08-14 23:28:57 +02:00
Kima
d842b2d588 sticker map shit 2024-08-14 23:27:30 +02:00
zypherift
f4fd9a3c2f forgot this icon 2024-08-14 23:20:25 +02:00
zypherift
a215bd7313 create trans(lation), and finish url opening 2024-08-14 23:17:30 +02:00
zypherift
3211279a53 added trans, changed icon 2024-08-14 23:05:22 +02:00
zypherift
2d4e281682 rename classes, and create new file for other 2024-08-14 23:01:15 +02:00
zypherift
148f945f3b replace images with new ones 2024-08-14 21:11:12 +02:00
Kima
aaa783ac45 updated build number 2024-08-14 13:22:51 +02:00
Kima
d70f92d4e5 changed login button 2024-08-14 12:32:32 +02:00
Kima
0f08400d63 shit 2024-08-14 11:32:38 +02:00
Kima
140a8f8e78 revert shit in rfplus 2024-08-14 11:30:59 +02:00
zypherift
17c9d1c447 what 2024-08-14 02:54:03 +02:00
zypherift
d8e23d8fa9 asd 2024-08-14 02:44:29 +02:00
zypherift
c4491eb0c6 merged new login screen with web login 2024-08-14 02:44:05 +02:00
zypherift
4945468e02 yes 2024-08-14 02:09:14 +02:00
Kima
9845ae9539 changed version number 2024-08-14 00:55:24 +02:00
Kima
3a2fc67cb2 new login system complete, that's it for today :3 2024-08-14 00:53:12 +02:00
Kima
148a43663c made kreten web login work hah 2024-08-13 01:08:05 +02:00
Márton Kiss
4a45131359 Merge pull request #126 from refilc/dev
dev to master (v5.0.3)
2024-06-21 22:54:49 +02:00
Kima
4128018a59 blah blah blah 2024-06-21 22:39:53 +02:00
Kima
0d509c90b1 finished everything shake 2024-06-21 22:30:17 +02:00
Kima
3ef58974c9 added shake to current error report screen as well 2024-06-21 21:47:15 +02:00
Kima
df75fadfea added shake 2024-06-21 21:16:24 +02:00
Kima
4254a7998a build number change 2024-06-20 14:17:31 +02:00
Kima
17faa545e5 changed some repos to custom forks because android sucks 2024-06-20 14:09:26 +02:00
Kima
506fb82dd0 changed lots of thing bc pub upgrade 2024-06-20 13:53:10 +02:00
Kima
bc8eb1910e upgraded pub things 2024-06-20 12:06:50 +02:00
Kima
fd1b15df77 just don't touch fl_chart 2024-06-19 23:34:45 +02:00
Kima
dd86c7436a fix in package versioning 2024-06-19 23:24:37 +02:00
Kima
8860a0269c fixed warnings after update 2024-06-19 22:34:56 +02:00
Kima
ce02dda46c updated flutter and pub packages 2024-06-19 22:23:16 +02:00
Kima
f16a52d0fb changed required sdk version and app version 2024-06-19 22:17:12 +02:00
Kima
cc8ce40222 fixed warnings 2024-06-19 22:10:28 +02:00
Kima
b6a933fe85 removed total average calculatro from refilcplus and added grade export viewing 2024-06-19 22:09:00 +02:00
Kima
767eba3776 well idgaf anymore, it should be good like this (subject average thing) 2024-06-19 22:02:12 +02:00
Kima
320499a466 prevent double taps on new weird exam popup 2024-06-19 21:35:49 +02:00
Kima
52c2f3090d fixed grade provider translation issues 2024-06-19 21:28:04 +02:00
Kima
d4df0170a3 fixed final grades ugly ui 2024-06-19 21:23:19 +02:00
Kima
796b35e27c made lesson countdown rotatable 2024-06-19 21:15:47 +02:00
Kima
051cdc895e fixed issues 2024-06-19 20:28:47 +02:00
Kima
e23bdac995 fixed sort issue 2024-06-19 16:43:56 +02:00
Kima
de0e8e1317 fixed good student mode percentage bug 2024-06-18 21:26:43 +02:00
Kima
b5b0046ef5 things™️ 2024-06-18 14:44:53 +02:00
Kima
92f16e054d finished new badge thingie 2024-06-17 22:47:30 +02:00
Kima
9470c848bf added new feature badge and unseen new feature list to settings 2024-06-17 22:19:43 +02:00
Kima
c40026e594 removed no import warning from grade exporting 2024-06-17 17:58:18 +02:00
117 changed files with 3802 additions and 1608 deletions

2
refilc/.gitignore vendored
View File

@@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/
# IntelliJ related

View File

@@ -58,7 +58,7 @@ android {
defaultConfig {
applicationId "hu.refilc.naplo"
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 KiB

After

Width:  |  Height:  |  Size: 696 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 KiB

After

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 KiB

After

Width:  |  Height:  |  Size: 1009 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 KiB

After

Width:  |  Height:  |  Size: 549 KiB

View File

@@ -43,4 +43,21 @@ post_install do |installer|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
bitcode_strip_path = `xcrun --find bitcode_strip`.chop!
def strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
framework_path = File.join(Dir.pwd, framework_relative_path)
command = "#{bitcode_strip_path} #{framework_path} -r -o #{framework_path}"
puts "Stripping bitcode: #{command}"
system(command)
end
framework_paths = [
"Pods/Shake/Sources/Shake.xcframework/ios-arm64/Shake.framework/Shake",
"Pods/Shake/Sources/Shake.xcframework/ios-arm64_x86_64-simulator/Shake.framework/Shake"
]
framework_paths.each do |framework_relative_path|
strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
end
end

View File

@@ -517,8 +517,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 257;
DEVELOPMENT_TEAM = 4DKAF249F3;
CURRENT_PROJECT_VERSION = 280;
DEVELOPMENT_TEAM = 4J97JVC2FG;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = reFilc;
@@ -527,8 +527,8 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.refilc2.naplo;
MARKETING_VERSION = 5.1.0;
PRODUCT_BUNDLE_IDENTIFIER = hu.qwit.refilc;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
@@ -549,8 +549,8 @@
CODE_SIGN_ENTITLEMENTS = livecard/livecard.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 257;
DEVELOPMENT_TEAM = 4DKAF249F3;
CURRENT_PROJECT_VERSION = 276;
DEVELOPMENT_TEAM = 4J97JVC2FG;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = livecard/Info.plist;
@@ -563,10 +563,10 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.5;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.refilc2.naplo.livecardpro;
PRODUCT_BUNDLE_IDENTIFIER = hu.qwit.refilc.livecard;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
@@ -591,8 +591,8 @@
CODE_SIGN_ENTITLEMENTS = livecard/livecard.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 257;
DEVELOPMENT_TEAM = 4DKAF249F3;
CURRENT_PROJECT_VERSION = 276;
DEVELOPMENT_TEAM = 4J97JVC2FG;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = livecard/Info.plist;
@@ -605,9 +605,9 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.5;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.refilc2.naplo.livecardpro;
PRODUCT_BUNDLE_IDENTIFIER = hu.qwit.refilc.livecard;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
@@ -631,8 +631,8 @@
CODE_SIGN_ENTITLEMENTS = livecard/livecard.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 257;
DEVELOPMENT_TEAM = 4DKAF249F3;
CURRENT_PROJECT_VERSION = 276;
DEVELOPMENT_TEAM = 4J97JVC2FG;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = livecard/Info.plist;
@@ -645,9 +645,9 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.5;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.refilc2.naplo.livecardpro;
PRODUCT_BUNDLE_IDENTIFIER = hu.qwit.refilc.livecard;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
@@ -775,8 +775,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 257;
DEVELOPMENT_TEAM = 4DKAF249F3;
CURRENT_PROJECT_VERSION = 280;
DEVELOPMENT_TEAM = 4J97JVC2FG;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = reFilc;
@@ -785,8 +785,8 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.refilc2.naplo;
MARKETING_VERSION = 5.1.0;
PRODUCT_BUNDLE_IDENTIFIER = hu.qwit.refilc;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -803,8 +803,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 257;
DEVELOPMENT_TEAM = 4DKAF249F3;
CURRENT_PROJECT_VERSION = 280;
DEVELOPMENT_TEAM = 4J97JVC2FG;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = reFilc;
@@ -813,8 +813,8 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.refilc2.naplo;
MARKETING_VERSION = 5.1.0;
PRODUCT_BUNDLE_IDENTIFIER = hu.qwit.refilc;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;

View File

@@ -12,7 +12,7 @@
<key>livecard.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>83</integer>
<integer>86</integer>
</dict>
</dict>
</dict>

View File

@@ -3,7 +3,7 @@ import background_fetch
import ActivityKit
import Flutter
@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
private var methodChannel: FlutterMethodChannel?

View File

@@ -1,40 +1,44 @@
import Foundation
import ActivityKit
public struct LessonData {
var color: String
var icon: String
var index: String
var title: String
var subtitle: String
var description: String
var startDate: Date
var endDate: Date
var date: ClosedRange<Date>
var nextSubject: String
var nextRoom: String
var color: String
var icon: String
var index: String
var title: String
var subtitle: String
var description: String
var startDate: Date
var endDate: Date
var date: ClosedRange<Date>
var nextSubject: String
var nextRoom: String
init(from dictionary: [String: Any]) {
self.color = dictionary["color"] as? String ?? ""
self.icon = dictionary["icon"] as? String ?? ""
self.index = dictionary["index"] as? String ?? ""
self.title = dictionary["title"] as? String ?? ""
self.subtitle = dictionary["subtitle"] as? String ?? ""
self.description = dictionary["description"] as? String ?? ""
self.nextSubject = dictionary["nextSubject"] as? String ?? ""
self.nextRoom = dictionary["nextRoom"] as? String ?? ""
init(from dictionary: [String: Any]) {
self.color = dictionary["color"] as? String ?? ""
self.icon = dictionary["icon"] as? String ?? ""
self.index = dictionary["index"] as? String ?? ""
self.title = dictionary["title"] as? String ?? ""
self.subtitle = dictionary["subtitle"] as? String ?? ""
self.description = dictionary["description"] as? String ?? ""
self.nextSubject = dictionary["nextSubject"] as? String ?? ""
self.nextRoom = dictionary["nextRoom"] as? String ?? ""
if let startDateStr = dictionary["startDate"] as? String, let startDateInt = Int(startDateStr) {
self.startDate = Date(timeIntervalSince1970: TimeInterval(startDateInt) / 1000)
} else {
self.startDate = Date()
}
if let endDateStr = dictionary["endDate"] as? String, let endDateInt = Int(endDateStr) {
self.endDate = Date(timeIntervalSince1970: TimeInterval(endDateInt) / 1000)
} else {
self.endDate = Date()
}
date = self.startDate...self.endDate
if let startDateStr = dictionary["startDate"] as? String, let startDateInt = Int(startDateStr) {
self.startDate = Date(timeIntervalSince1970: TimeInterval(startDateInt) / 1000)
} else {
self.startDate = Date()
}
if let endDateStr = dictionary["endDate"] as? String, let endDateInt = Int(endDateStr) {
self.endDate = Date(timeIntervalSince1970: TimeInterval(endDateInt) / 1000)
} else {
self.endDate = self.startDate
}
if self.startDate <= self.endDate {
self.date = self.startDate...self.endDate
} else {
self.date = self.endDate...self.endDate
}
}
}

View File

@@ -64,19 +64,11 @@ struct LockScreenLiveActivityView: View {
.padding(.trailing, 90)
} else {
MultilineTextView(text: "\(context.state.index) \(context.state.title)", limit: 25)
MultilineTextView(text: "\(context.state.index) \(context.state.title) - \(context.state.subtitle)", limit: 25)
.font(.body)
.bold()
.multilineTextAlignment(.center)
}
//Terem
if (!context.state.subtitle.isEmpty) {
Text(context.state.subtitle)
.italic()
.bold()
.font(.system(size: 13))
}
}
// Leírás
@@ -92,10 +84,8 @@ struct LockScreenLiveActivityView: View {
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: CGFloat(8), height: CGFloat(8))
Text(context.state.nextSubject)
Text("\(context.state.nextSubject) - \(context.state.nextRoom)")
.font(.caption)
Text(context.state.nextRoom)
.font(.caption2)
}
.multilineTextAlignment(.center)
} else {
@@ -197,33 +187,23 @@ struct LiveCardWidget: Widget {
} else {
// Amikor óra van, expanded DynamicIsland
MultilineTextView(text: "\(context.state.index) \(context.state.title)", limit: 25)
MultilineTextView(text: "\(context.state.index) \(context.state.title) - \(context.state.subtitle)", limit: 25)
.lineLimit(1)
.font(.body)
.bold()
.padding(.trailing, -35)
Text(context.state.subtitle)
.lineLimit(1)
.italic()
.bold()
.font(.system(size: 13))
.padding(.trailing, -50)
Spacer(minLength: 5)
Spacer(minLength: 2)
if(context.state.nextRoom != "" && context.state.nextSubject != "") {
Text("Következő óra és terem:")
.font(.system(size: 14))
.padding(.trailing, -35)
.padding(.trailing, -45)
Spacer(minLength: 2)
Text(context.state.nextSubject)
.modifier(DynamicFontSizeModifier(text: context.state.nextSubject))
.padding(.trailing, -35)
Text(context.state.nextRoom)
// ignore: based on nextSubject characters, I check that the font size of the room is the same as the next subject.
.modifier(DynamicFontSizeModifier(text: context.state.nextSubject))
.padding(.trailing, -35)
Text("\(context.state.nextSubject) - \(context.state.nextRoom)")
.modifier(DynamicFontSizeModifier(text: "\(context.state.nextSubject) - \(context.state.nextRoom)"))
.padding(.trailing, 35)
} else {
Text("Ez az utolsó óra! Kitartást!")
.font(.system(size: 14))
@@ -327,3 +307,66 @@ struct DynamicFontSizeModifier: ViewModifier {
}
}
}
struct LiveCardWidget_Previews: PreviewProvider {
static let attributes = LiveActivitiesAppAttributes()
static let duringLessonExmaple = LiveActivitiesAppAttributes.ContentState(
color: "#FF5733",
icon: "bell",
index: "1.",
title: "Math Class",
subtitle: "101",
description: "Algebra lesson",
startDate: Date(),
endDate: Date().addingTimeInterval(3000),
date: Date()...Date().addingTimeInterval(3000), // 50 minutes later
nextSubject: "Physics",
nextRoom: "102"
)
static let inBreak = LiveActivitiesAppAttributes.ContentState(
color: "#FF5733",
icon: "house",
index: "",
title: "Szünet",
subtitle: "Menj a(z) 122 terembe.",
description: "",
startDate: Date(),
endDate: Date().addingTimeInterval(3000),
date: Date()...Date().addingTimeInterval(3000), // 50 minutes later
nextSubject: "Physics",
nextRoom: "122"
)
static let lastLesson = LiveActivitiesAppAttributes.ContentState(
color: "#00ff00",
icon: "bell",
index: "6.",
title: "Math Class",
subtitle: "",
description: "Lorem Ipsum",
startDate: Date(),
endDate: Date().addingTimeInterval(3000),
date: Date()...Date().addingTimeInterval(3000), // 50 minutes later
nextSubject: "",
nextRoom: ""
)
static var previews: some View {
// Dynamic Island Compact
Group {
attributes
.previewContext(duringLessonExmaple, viewKind: .dynamicIsland(.compact))
.previewDisplayName("During Lesson")
attributes
.previewContext(inBreak, viewKind: .dynamicIsland(.compact))
.previewDisplayName("In Break")
attributes
.previewContext(lastLesson, viewKind: .dynamicIsland(.compact))
.previewDisplayName("During Last Lesson")
}
}
}

View File

@@ -18,11 +18,11 @@ import 'package:connectivity_plus/connectivity_plus.dart';
class FilcAPI {
// API base
static const baseUrl = "https://api.refilc.hu";
static const baseUrl = "https://api.refilcapp.hu";
// Public API
static const schoolList = "$baseUrl/v3/public/school-list";
static const news = "$baseUrl/v3/public/news";
static const news = "$baseUrl/v4/public/news";
static const supporters = "$baseUrl/v3/public/supporters";
// Private API
@@ -51,11 +51,14 @@ class FilcAPI {
static const gradeColorsByID = "$gradeColorsGet/";
// Payment API
static const payment = "$baseUrl/v3/payment";
static const payment = "$baseUrl/v4/payment";
static const stripeSheet = "$payment/stripe-sheet";
// Cloud Sync
static const cloudSyncApi = "$baseUrl/v4/me/cloud-sync";
static Future<bool> checkConnectivity() async =>
(await Connectivity().checkConnectivity()) != ConnectivityResult.none;
(await Connectivity().checkConnectivity())[0] != ConnectivityResult.none;
static Future<List<School>?> getSchools() async {
try {
@@ -93,10 +96,14 @@ class FilcAPI {
"x-filc-id": settings.xFilcId,
"user-agent": userAgent,
// platform things
"rf-platform": Platform.operatingSystem,
"rf-platform-version": Platform.operatingSystemVersion,
"rf-app-version":
const String.fromEnvironment("APPVER", defaultValue: "?"),
"rf-platform":
settings.analyticsEnabled ? Platform.operatingSystem : "unknown",
"rf-platform-version": settings.analyticsEnabled
? Platform.operatingSystemVersion
: "unknown",
"rf-app-version": settings.analyticsEnabled
? const String.fromEnvironment("APPVER", defaultValue: "?")
: "unknown",
"rf-uinid": settings.xFilcId,
};
@@ -231,7 +238,7 @@ class FilcAPI {
}
// sharing
static Future<void> addSharedTheme(SharedTheme theme) async {
static Future<int> addSharedTheme(SharedTheme theme) async {
try {
theme.json.remove('json');
theme.json['is_public'] = theme.isPublic.toString();
@@ -263,13 +270,19 @@ class FilcAPI {
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
);
if (res.statusCode != 201) {
throw "HTTP ${res.statusCode}: ${res.body}";
// if (res.statusCode != 201) {
// throw "HTTP ${res.statusCode}: ${res.body}";
// }
if (res.statusCode == 201) {
log('Shared theme successfully with ID: ${theme.id}');
}
log('Shared theme successfully with ID: ${theme.id}');
return res.statusCode;
} on Exception catch (error, stacktrace) {
log("ERROR: FilcAPI.addSharedTheme: $error $stacktrace");
return 696;
}
}
@@ -303,8 +316,7 @@ class FilcAPI {
return null;
}
static Future<void> addSharedGradeColors(
SharedGradeColors gradeColors) async {
static Future<int> addSharedGradeColors(SharedGradeColors gradeColors) async {
try {
gradeColors.json.remove('json');
gradeColors.json['is_public'] = gradeColors.isPublic.toString();
@@ -320,13 +332,19 @@ class FilcAPI {
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
);
if (res.statusCode != 201) {
throw "HTTP ${res.statusCode}: ${res.body}";
// if (res.statusCode != 201) {
// throw "HTTP ${res.statusCode}: ${res.body}";
// }
if (res.statusCode == 201) {
log('Shared grade colors successfully with ID: ${gradeColors.id}');
}
log('Shared grade colors successfully with ID: ${gradeColors.id}');
return res.statusCode;
} on Exception catch (error, stacktrace) {
log("ERROR: FilcAPI.addSharedGradeColors: $error $stacktrace");
return 696;
}
}
@@ -375,6 +393,32 @@ class FilcAPI {
return null;
}
// cloud sync
static Future<Map?> cloudSync(Map<String, String> data, String token) async {
try {
var client = http.Client();
http.Response res = await client.post(
Uri.parse(cloudSyncApi),
body: data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer $token',
},
);
if (res.statusCode != 200) {
throw "HTTP ${res.statusCode}: ${res.body}";
}
return jsonDecode(res.body);
} on Exception catch (error, stacktrace) {
log("ERROR: FilcAPI.cloudSync: $error $stacktrace");
}
return null;
}
}
class ErrorReport {

View File

@@ -1,5 +1,6 @@
// ignore_for_file: avoid_print, use_build_context_synchronously
import 'package:flutter/foundation.dart';
import 'package:refilc/utils/jwt.dart';
import 'package:refilc_kreta_api/models/school.dart';
import 'package:refilc_kreta_api/providers/absence_provider.dart';
@@ -64,8 +65,12 @@ Future loginAPI({
parents: ['Teszt András', 'Teszt Linda'],
json: {"a": "b"},
address: '1117 Budapest, Gábor Dénes utca 4.',
gradeDelay: 0,
),
role: Role.parent,
accessToken: '',
accessTokenExpire: DateTime.now(),
refreshToken: '',
);
if (onLogin != null) onLogin(user);
@@ -107,7 +112,9 @@ Future loginAPI({
default:
// normal login from here
Provider.of<KretaClient>(context, listen: false).userAgent =
Provider.of<SettingsProvider>(context, listen: false).config.userAgent;
Provider.of<SettingsProvider>(context, listen: false)
.config
.userAgent;
Map<String, String> headers = {
"content-type": "application/x-www-form-urlencoded",
@@ -127,6 +134,7 @@ Future loginAPI({
password: password,
instituteCode: instituteCode,
));
if (res != null) {
if (res.containsKey("error")) {
if (res["error"] == "invalid_grant") {
@@ -148,6 +156,9 @@ Future loginAPI({
name: student.name,
student: student,
role: JwtUtils.getRoleFromJWT(res["access_token"])!,
accessToken: res["access_token"],
accessTokenExpire: DateTime.now(),
refreshToken: '',
);
if (onLogin != null) onLogin(user);
@@ -157,7 +168,8 @@ Future loginAPI({
.store
.storeUser(user);
Provider.of<UserProvider>(context, listen: false).addUser(user);
Provider.of<UserProvider>(context, listen: false).setUser(user.id);
Provider.of<UserProvider>(context, listen: false)
.setUser(user.id);
// Get user data
try {
@@ -167,7 +179,8 @@ Future loginAPI({
.fetch(week: Week.current()),
Provider.of<ExamProvider>(context, listen: false).fetch(),
Provider.of<HomeworkProvider>(context, listen: false).fetch(),
Provider.of<MessageProvider>(context, listen: false).fetchAll(),
Provider.of<MessageProvider>(context, listen: false)
.fetchAll(),
Provider.of<MessageProvider>(context, listen: false)
.fetchAllRecipients(),
Provider.of<NoteProvider>(context, listen: false).fetch(),
@@ -195,3 +208,124 @@ Future loginAPI({
return LoginState.failed;
}
// new login api
Future newLoginAPI({
required String code,
required BuildContext context,
void Function(User)? onLogin,
void Function()? onSuccess,
}) async {
// actual login (token grant) logic
Provider.of<KretaClient>(context, listen: false).userAgent =
Provider.of<SettingsProvider>(context, listen: false).config.userAgent;
Map<String, String> headers = {
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"accept": "*/*",
"user-agent": "eKretaStudent/264745 CFNetwork/1494.0.7 Darwin/23.4.0",
};
Map? res = await Provider.of<KretaClient>(context, listen: false)
.postAPI(KretaAPI.login, headers: headers, body: {
"code": code,
"code_verifier": "DSpuqj_HhDX4wzQIbtn8lr8NLE5wEi1iVLMtMK0jY6c",
"redirect_uri":
"https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect",
"client_id": KretaAPI.clientId,
"grant_type": "authorization_code",
});
if (res != null) {
if (kDebugMode) {
print(res);
// const splitSize = 1000;
// RegExp exp = RegExp(r"\w{" "$splitSize" "}");
// // String str = "0102031522";
// Iterable<Match> matches = exp.allMatches(res.toString());
// var list = matches.map((m) => m.group(0));
// list.forEach((e) {
// print(e);
// });
}
if (res.containsKey("error")) {
if (res["error"] == "invalid_grant") {
print("ERROR: invalid_grant");
return;
}
} else {
if (res.containsKey("access_token")) {
try {
Provider.of<KretaClient>(context, listen: false).accessToken =
res["access_token"];
Provider.of<KretaClient>(context, listen: false).refreshToken =
res["refresh_token"];
String instituteCode =
JwtUtils.getInstituteFromJWT(res["access_token"])!;
String username = JwtUtils.getUsernameFromJWT(res["access_token"])!;
Role role = JwtUtils.getRoleFromJWT(res["access_token"])!;
Map? studentJson =
await Provider.of<KretaClient>(context, listen: false)
.getAPI(KretaAPI.student(instituteCode));
Student student = Student.fromJson(studentJson!);
var user = User(
username: username,
password: '',
instituteCode: instituteCode,
name: student.name,
student: student,
role: role,
accessToken: res["access_token"],
accessTokenExpire:
DateTime.now().add(Duration(seconds: (res["expires_in"] - 30))),
refreshToken: res["refresh_token"],
);
if (onLogin != null) onLogin(user);
// Store User in the database
await Provider.of<DatabaseProvider>(context, listen: false)
.store
.storeUser(user);
Provider.of<UserProvider>(context, listen: false).addUser(user);
Provider.of<UserProvider>(context, listen: false).setUser(user.id);
// Get user data
try {
await Future.wait([
Provider.of<GradeProvider>(context, listen: false).fetch(),
Provider.of<TimetableProvider>(context, listen: false)
.fetch(week: Week.current()),
Provider.of<ExamProvider>(context, listen: false).fetch(),
Provider.of<HomeworkProvider>(context, listen: false).fetch(),
Provider.of<MessageProvider>(context, listen: false).fetchAll(),
Provider.of<MessageProvider>(context, listen: false)
.fetchAllRecipients(),
Provider.of<NoteProvider>(context, listen: false).fetch(),
Provider.of<EventProvider>(context, listen: false).fetch(),
Provider.of<AbsenceProvider>(context, listen: false).fetch(),
]);
} catch (error) {
print("WARNING: failed to fetch user data: $error");
}
if (onSuccess != null) onSuccess();
return LoginState.success;
} catch (error) {
print("ERROR: loginAPI: $error");
// maybe check debug mode
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("ERROR: $error")));
return LoginState.failed;
}
}
}
}
return LoginState.failed;
}

View File

@@ -15,7 +15,7 @@ class StatusProvider extends ChangeNotifier {
StatusProvider() {
_handleNetworkChanges();
_handleDNSFailure();
Connectivity().checkConnectivity().then((value) => _networkType = value);
Connectivity().checkConnectivity().then((value) => _networkType = value[0]);
}
Status? getStatus() => _stack.isNotEmpty ? _stack[0] : null;
@@ -24,8 +24,8 @@ class StatusProvider extends ChangeNotifier {
void _handleNetworkChanges() {
Connectivity().onConnectivityChanged.listen((event) {
_networkType = event;
if (event == ConnectivityResult.none) {
_networkType = event[0];
if (event[0] == ConnectivityResult.none) {
if (!_stack.contains(Status.network)) {
_stack.remove(Status.apiError);
_stack.insert(0, Status.network);

View File

@@ -2,6 +2,7 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:refilc/api/providers/database_provider.dart';
import 'package:refilc/api/providers/status_provider.dart';
import 'package:refilc/api/providers/user_provider.dart';
@@ -28,7 +29,7 @@ import 'liveactivity/platform_channel.dart';
// Mutex
bool lock = false;
Future<void> syncAll(BuildContext context) {
Future<void> syncAll(BuildContext context) async {
if (lock) return Future.value();
// Lock
lock = true;
@@ -40,6 +41,12 @@ Future<void> syncAll(BuildContext context) {
StatusProvider statusProvider =
Provider.of<StatusProvider>(context, listen: false);
// check if access token isn't expired
// if (user.user?.accessToken == null) {
// lock = false;
// return Future.value();
// }
List<Future<void>> tasks = [];
int taski = 0;
@@ -50,6 +57,49 @@ Future<void> syncAll(BuildContext context) {
}
tasks = [
// refresh login
syncStatus(() async {
// print(user.user?.accessTokenExpire);
// print('${user.user?.accessToken ?? "no token"} - ACCESS TOKEN');
// user.user!.accessToken = "";
if (user.user == null) {
Navigator.of(context).pushNamedAndRemoveUntil("login", (_) => false);
lock = false;
return Future.value();
}
if (user.user!.accessToken.replaceAll(" ", "") == "") {
String uid = user.user!.id;
user.removeUser(uid);
await Provider.of<DatabaseProvider>(context, listen: false)
.store
.removeUser(uid);
Navigator.of(context).pushNamedAndRemoveUntil("login", (_) => false);
lock = false;
return;
}
if (user.user!.accessTokenExpire.isBefore(DateTime.now())) {
String authRes = await Provider.of<KretaClient>(context, listen: false)
.refreshLogin() ??
'';
if (authRes != 'success') {
if (kDebugMode) print('ERROR: failed to refresh login');
lock = false;
return Future.value();
} else {
if (kDebugMode) print('INFO: access token refreshed');
}
} else {
if (kDebugMode) print('INFO: access token is not expired');
}
}()),
syncStatus(Provider.of<GradeProvider>(context, listen: false).fetch()),
syncStatus(Provider.of<TimetableProvider>(context, listen: false)
.fetch(week: Week.current())),
@@ -71,6 +121,8 @@ Future<void> syncAll(BuildContext context) {
if (studentJson == null) return;
Student student = Student.fromJson(studentJson);
// print(studentJson);
user.user?.name = student.name;
// Store user
@@ -89,13 +141,11 @@ Future<void> syncAll(BuildContext context) {
return false;
}
return Future.wait(tasks).then((value) {
// Unlock
lock = false;
if(Platform.isIOS && LiveCardProvider.hasActivityStarted == true){
if (Platform.isIOS && LiveCardProvider.hasActivityStarted == true) {
PlatformChannel.endLiveActivity();
LiveCardProvider.hasActivityStarted = false;
}

View File

@@ -31,6 +31,7 @@ import 'package:provider/provider.dart';
import 'package:refilc_mobile_ui/common/system_chrome.dart' as mobile;
import 'package:refilc_mobile_ui/screens/login/login_route.dart' as mobile;
import 'package:refilc_mobile_ui/screens/login/login_screen.dart' as mobile;
// import 'package:refilc_mobile_ui/screens/login/kreten_login.dart' as mobileTest;
import 'package:refilc_mobile_ui/screens/navigation/navigation_screen.dart'
as mobile;
import 'package:refilc_mobile_ui/screens/settings/settings_route.dart'
@@ -80,7 +81,8 @@ class App extends StatelessWidget {
CorePalette? corePalette;
final status = StatusProvider();
final kreta = KretaClient(user: user, settings: settings, status: status);
final kreta = KretaClient(
user: user, settings: settings, database: database, status: status);
final timetable =
TimetableProvider(user: user, database: database, kreta: kreta);
final premium = PlusProvider(settings: settings);
@@ -235,7 +237,7 @@ class App extends StatelessWidget {
},
onGenerateRoute: (settings) => rootNavigator(settings),
initialRoute:
user.getUsers().isNotEmpty ? "navigation" : "login",
(user.getUsers().isNotEmpty) ? "navigation" : "login",
);
},
);

View File

@@ -27,7 +27,8 @@ const settingsDB = DatabaseStruct("settings", {
"notifications_absences": int,
"notifications_messages": int,
"notifications_lessons": int, // notifications
"x_filc_id": String, "graph_class_avg": int, "presentation_mode": int,
"x_filc_id": String, "graph_class_avg": int,
"analytics_enabled": int, "presentation_mode": int,
"bell_delay": int, "bell_delay_enabled": int,
"grade_opening_fun": int, "icon_pack": String, "premium_scopes": String,
"premium_token": String, "premium_login": String,
@@ -54,6 +55,10 @@ const settingsDB = DatabaseStruct("settings", {
"new_colors": int,
"uwu_mode": int,
"new_popups": int,
"unseen_new_features": String,
"cloud_sync_enabled": int,
"cloud_sync_token": String,
"local_updated_at": String,
// quick settings
"q_timetable_lesson_num": int, "q_timetable_sub_tiles": int,
"q_subjects_sub_tiles": int,
@@ -65,6 +70,8 @@ const usersDB = DatabaseStruct("users", {
"institute_code": String, "student": String, "role": int,
"nickname": String, "picture": String, // premium only (it's now plus btw)
"grade_streak": int,
"access_token": String, "access_token_expire": String,
"refresh_token": String,
});
const userDataDB = DatabaseStruct("user_data", {
"id": String, "grades": String, "timetable": String, "exams": String,
@@ -137,7 +144,10 @@ Future<Database> initDB(DatabaseProvider database) async {
"role": 0,
"nickname": "",
"picture": "",
"grade_streak": 0
"grade_streak": 0,
"access_token": "",
"access_token_expire": "",
"refresh_token": "",
},
);
await migrateDB(db, struct: userDataDB, defaultValues: {

View File

@@ -8,10 +8,10 @@ class DatabaseStruct {
String typeName = "";
switch (type.runtimeType) {
case int:
case const (int):
typeName = "integer";
break;
case String:
case const (String):
typeName = "text";
break;
}

View File

@@ -22,7 +22,7 @@ import 'package:intl/intl.dart';
import 'package:refilc_kreta_api/models/message.dart';
// if you want to add a new category, also add it to the DB or else the app will probably crash
enum LastSeenCategory {
enum LastSeenCategory {
grade,
surprisegrade,
absence,
@@ -71,9 +71,11 @@ class NotificationsHelper {
// Refresh kreta login for current user
final status = StatusProvider();
KretaClient kretaClientForUser = KretaClient(
user: userProviderForUser,
settings: settingsProvider,
status: status);
user: userProviderForUser,
settings: settingsProvider,
database: database,
status: status,
);
await kretaClientForUser.refreshLogin();
// Process notifications for current user
@@ -95,7 +97,7 @@ class NotificationsHelper {
/*
ezt a kódot nagyon szépen megírta az AI, picit szerkesztgettem is rajta
ezt a kódot nagyon szépen megírta az AI, picit szerkesztgettem is rajta //pearoo what did you do - zypherift
nem lesz tőle használhatatlan az app, de kikommenteltem, mert még a végén kima bántani fog
Future<void> liveNotification(UserProvider currentuserProvider, KretaClient currentKretaClient) async {
@@ -655,7 +657,7 @@ nem lesz tőle használhatatlan az app, de kikommenteltem, mert még a végén k
lesson.lessonIndex,
lesson.name,
dayTitle(lesson.date),
lesson.substituteTeacher!.isRenamed
(lesson.substituteTeacher?.isRenamed ?? false)
? lesson.substituteTeacher!.renamedTo!
: lesson.substituteTeacher!.name
],

View File

@@ -6,10 +6,9 @@ import 'package:share_plus/share_plus.dart';
class ShareHelper {
static Future<void> shareText(String text, {String? subject}) =>
Share.share(text, subject: subject);
// ignore: deprecated_member_use
static Future<void> shareFile(String path, {String? text, String? subject}) =>
// ignore: deprecated_member_use
Share.shareFiles([path], text: text, subject: subject);
Share.shareXFiles([XFile(path)], text: text, subject: subject);
static Future<void> shareAttachment(Attachment attachment,
{required BuildContext context}) async {

View File

@@ -15,6 +15,8 @@ import 'package:refilc/utils/service_locator.dart';
import 'package:refilc_mobile_ui/screens/error_screen.dart';
import 'package:refilc_mobile_ui/screens/error_report_screen.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:shake_flutter/models/shake_report_configuration.dart';
import 'package:shake_flutter/shake_flutter.dart';
import 'helpers/live_activity_helper.dart';
@@ -38,6 +40,28 @@ void main() async {
BackgroundFetch.registerHeadlessTask(backgroundHeadlessTask);
// setting up things for shakebugs
// List<ShakePickerItem> pickerItems = [
// ShakePickerItem('Bug', 'Hiba', tag: 'bug'),
// ShakePickerItem('Suggestion', 'Fejlesztési javaslat', tag: 'suggestion'),
// ShakePickerItem('Question', 'Kérdés', tag: 'question')
// ];
// ShakePicker picker =
// ShakePicker('Feedback type', 'Visszajelzés típusa', pickerItems);
// ShakeTitle title = ShakeTitle('Title', 'Leírás', required: true);
// ShakeInspectButton inspect = ShakeInspectButton();
// ShakeAttachments attachments = ShakeAttachments();
// List<ShakeFormComponent> components = [picker, title, inspect, attachments];
// ShakeForm form = ShakeForm(components);
// Shake.setShakeForm(form);
// shakebugs initialization
// Shake.setInvokeShakeOnScreenshot(true);
Shake.start('Y44AwzfY6091xO2Nr0w59RHSpNxJhhiSFGs4enmoJwelN82ZRzTLE5X');
// pre-cache required icons
const todaySvg = SvgAssetLoader('assets/svg/menu_icons/today_selected.svg');
const gradesSvg = SvgAssetLoader('assets/svg/menu_icons/grades_selected.svg');
@@ -170,6 +194,18 @@ Widget errorBuilder(FlutterErrorDetails details) {
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
if (kReleaseMode) {
// silent report to shakebugs
ShakeReportConfiguration configuration = ShakeReportConfiguration();
configuration.blackBoxData = true;
configuration.activityHistoryData = true;
configuration.screenshot = true;
configuration.video = false;
Shake.silentReport(
configuration: configuration,
description:
'Silent Report #${DateTime.now().year}${DateTime.now().month}${DateTime.now().day}',
);
// show error report screen
return ErrorReportScreen(details);
} else {
return ErrorScreen(details);
@@ -244,7 +280,8 @@ void backgroundHeadlessTask(HeadlessTask task) {
LiveActivityHelper().backgroundJob();
} else {
NotificationsHelper().backgroundJob();
} BackgroundFetch.finish(task.taskId);
}
BackgroundFetch.finish(task.taskId);
}
Future<void> initAdditionalBackgroundFetch() async {

View File

@@ -0,0 +1,22 @@
class CloudSyncData {
Map settings;
List<String> deviceIds;
String reFilcPlusId;
Map json;
CloudSyncData({
this.settings = const {},
this.deviceIds = const [],
this.reFilcPlusId = "",
required this.json,
});
factory CloudSyncData.fromJson(Map json) {
return CloudSyncData(
settings: json['settings'] ?? {},
deviceIds: List<String>.from(json['device_ids'] ?? []),
reFilcPlusId: json['refilc_plus_id'] ?? "",
json: json,
);
}
}

View File

@@ -7,6 +7,8 @@ class News {
String platform;
bool emergency;
DateTime expireDate;
List<String>? appVersions;
String? specificAppId;
Map? json;
News({
@@ -18,6 +20,8 @@ class News {
required this.platform,
required this.emergency,
required this.expireDate,
this.appVersions,
this.specificAppId,
this.json,
});
@@ -31,6 +35,10 @@ class News {
platform: json["platform"] ?? "",
emergency: json["emergency"] ?? false,
expireDate: DateTime.parse(json["expire_date"] ?? ''),
appVersions: json["app_versions"] != null
? List<String>.from(json["app_versions"])
: null,
specificAppId: json["specific_app_id"],
json: json,
);
}

View File

@@ -60,7 +60,7 @@ class TodoItem {
);
}
get toJson => {
Map<String, dynamic> get toJson => {
'id': id,
'title': title,
'content': content,

View File

@@ -60,6 +60,7 @@ class SettingsProvider extends ChangeNotifier {
UpdateChannel _updateChannel;
Config _config;
String _xFilcId;
bool _analyticsEnabled;
bool _graphClassAvg;
bool _goodStudent;
bool _presentationMode;
@@ -107,6 +108,10 @@ class SettingsProvider extends ChangeNotifier {
bool _newColors;
bool _uwuMode;
bool _newPopups;
List<String> _unseenNewFeatures;
bool _cloudSyncEnabled;
String _cloudSyncToken;
DateTime _updatedAt;
// quick settings
bool _qTimetableLessonNum;
bool _qTimetableSubTiles;
@@ -136,6 +141,7 @@ class SettingsProvider extends ChangeNotifier {
required UpdateChannel updateChannel,
required Config config,
required String xFilcId,
required bool analyticsEnabled,
required bool graphClassAvg,
required bool goodStudent,
required bool presentationMode,
@@ -180,6 +186,10 @@ class SettingsProvider extends ChangeNotifier {
required bool newColors,
required bool uwuMode,
required bool newPopups,
required List<String> unseenNewFeatures,
required bool cloudSyncEnabled,
required String cloudSyncToken,
required DateTime updatedAt,
required bool qTimetableLessonNum,
required bool qTimetableSubTiles,
required bool qSubjectsSubTiles,
@@ -206,6 +216,7 @@ class SettingsProvider extends ChangeNotifier {
_updateChannel = updateChannel,
_config = config,
_xFilcId = xFilcId,
_analyticsEnabled = analyticsEnabled,
_graphClassAvg = graphClassAvg,
_goodStudent = goodStudent,
_presentationMode = presentationMode,
@@ -250,6 +261,10 @@ class SettingsProvider extends ChangeNotifier {
_newColors = newColors,
_uwuMode = uwuMode,
_newPopups = newPopups,
_unseenNewFeatures = unseenNewFeatures,
_cloudSyncEnabled = cloudSyncEnabled,
_cloudSyncToken = cloudSyncToken,
_updatedAt = updatedAt,
_qTimetableLessonNum = qTimetableLessonNum,
_qTimetableSubTiles = qTimetableSubTiles,
_qSubjectsSubTiles = qSubjectsSubTiles;
@@ -294,6 +309,7 @@ class SettingsProvider extends ChangeNotifier {
updateChannel: UpdateChannel.values[map["update_channel"]],
config: Config.fromJson(configMap ?? {}),
xFilcId: map["x_filc_id"],
analyticsEnabled: map["analytics_enabled"] == 1,
graphClassAvg: map["graph_class_avg"] == 1,
goodStudent: false,
presentationMode: map["presentation_mode"] == 1,
@@ -339,6 +355,10 @@ class SettingsProvider extends ChangeNotifier {
newColors: map['new_colors'] == 1,
uwuMode: map['uwu_mode'] == 1,
newPopups: map['new_popups'] == 1,
unseenNewFeatures: jsonDecode(map["unseen_new_features"]).cast<String>(),
cloudSyncEnabled: map['cloud_sync_enabled'] == 1,
cloudSyncToken: map['cloud_sync_token'],
updatedAt: DateTime.tryParse(map['local_updated_at']) ?? DateTime.now(),
qTimetableLessonNum: map['q_timetable_lesson_num'] == 1,
qTimetableSubTiles: map['q_timetable_sub_tiles'] == 1,
qSubjectsSubTiles: map['q_subjects_sub_tiles'] == 1,
@@ -373,6 +393,7 @@ class SettingsProvider extends ChangeNotifier {
"notification_poll_interval": _notificationPollInterval,
"config": jsonEncode(config.json),
"x_filc_id": _xFilcId,
"analytics_enabled": _analyticsEnabled ? 1 : 0,
"graph_class_avg": _graphClassAvg ? 1 : 0,
"presentation_mode": _presentationMode ? 1 : 0,
"bell_delay_enabled": _bellDelayEnabled ? 1 : 0,
@@ -416,6 +437,10 @@ class SettingsProvider extends ChangeNotifier {
"new_colors": _newColors ? 1 : 0,
"uwu_mode": _uwuMode ? 1 : 0,
"new_popups": _newPopups ? 1 : 0,
"unseen_new_features": jsonEncode(_unseenNewFeatures),
"cloud_sync_enabled": _cloudSyncEnabled ? 1 : 0,
"cloud_sync_token": _cloudSyncToken,
"local_updated_at": _updatedAt.toIso8601String(),
"q_timetable_lesson_num": _qTimetableLessonNum ? 1 : 0,
"q_timetable_sub_tiles": _qTimetableSubTiles ? 1 : 0,
"q_subjects_sub_tiles": _qSubjectsSubTiles ? 1 : 0,
@@ -453,6 +478,7 @@ class SettingsProvider extends ChangeNotifier {
updateChannel: UpdateChannel.stable,
config: Config.fromJson({}),
xFilcId: const Uuid().v4(),
analyticsEnabled: true,
graphClassAvg: false,
goodStudent: false,
presentationMode: false,
@@ -497,6 +523,10 @@ class SettingsProvider extends ChangeNotifier {
newColors: true,
uwuMode: false,
newPopups: true,
unseenNewFeatures: ['grade_exporting'],
cloudSyncEnabled: false,
cloudSyncToken: '',
updatedAt: DateTime.now(),
qTimetableLessonNum: true,
qTimetableSubTiles: true,
qSubjectsSubTiles: true,
@@ -526,6 +556,7 @@ class SettingsProvider extends ChangeNotifier {
UpdateChannel get updateChannel => _updateChannel;
Config get config => _config;
String get xFilcId => _xFilcId;
bool get analyticsEnabled => _analyticsEnabled;
bool get graphClassAvg => _graphClassAvg;
bool get goodStudent => _goodStudent;
bool get presentationMode => _presentationMode;
@@ -569,6 +600,10 @@ class SettingsProvider extends ChangeNotifier {
bool get newColors => _newColors;
bool get uwuMode => _uwuMode;
bool get newPopups => _newPopups;
List<String> get unseenNewFeatures => _unseenNewFeatures;
bool get cloudSyncEnabled => _cloudSyncEnabled;
String get cloudSyncToken => _cloudSyncToken;
DateTime get updatedAt => _updatedAt;
bool get qTimetableLessonNum => _qTimetableLessonNum;
bool get qTimetableSubTiles => _qTimetableSubTiles;
bool get qSubjectsSubTiles => _qSubjectsSubTiles;
@@ -583,6 +618,7 @@ class SettingsProvider extends ChangeNotifier {
List<Color>? gradeColors,
bool? newsEnabled,
String? seenNewsId,
String? seenNews, // only for restoring from map
bool? notificationsEnabled,
bool? notificationsGradesEnabled,
bool? notificationsAbsencesEnabled,
@@ -597,6 +633,7 @@ class SettingsProvider extends ChangeNotifier {
UpdateChannel? updateChannel,
Config? config,
String? xFilcId,
bool? analyticsEnabled,
bool? graphClassAvg,
bool? goodStudent,
bool? presentationMode,
@@ -637,6 +674,9 @@ class SettingsProvider extends ChangeNotifier {
bool? newColors,
bool? uwuMode,
bool? newPopups,
List<String>? unseenNewFeatures,
bool? cloudSyncEnabled,
String? cloudSyncToken,
bool? qTimetableLessonNum,
bool? qTimetableSubTiles,
bool? qSubjectsSubTiles,
@@ -659,6 +699,7 @@ class SettingsProvider extends ChangeNotifier {
tempList.add(seenNewsId);
_seenNews = tempList.join(',');
}
if (seenNews != null && seenNews != _seenNews) _seenNews = seenNews;
if (notificationsEnabled != null &&
notificationsEnabled != _notificationsEnabled) {
_notificationsEnabled = notificationsEnabled;
@@ -700,6 +741,9 @@ class SettingsProvider extends ChangeNotifier {
}
if (config != null && config != _config) _config = config;
if (xFilcId != null && xFilcId != _xFilcId) _xFilcId = xFilcId;
if (analyticsEnabled != null && analyticsEnabled != _analyticsEnabled) {
_analyticsEnabled = analyticsEnabled;
}
if (graphClassAvg != null && graphClassAvg != _graphClassAvg) {
_graphClassAvg = graphClassAvg;
}
@@ -828,6 +872,15 @@ class SettingsProvider extends ChangeNotifier {
if (newPopups != null && newPopups != _newPopups) {
_newPopups = newPopups;
}
if (unseenNewFeatures != null && unseenNewFeatures != _unseenNewFeatures) {
_unseenNewFeatures = unseenNewFeatures;
}
if (cloudSyncEnabled != null && cloudSyncEnabled != _cloudSyncEnabled) {
_cloudSyncEnabled = cloudSyncEnabled;
}
if (cloudSyncToken != null && cloudSyncToken != _cloudSyncToken) {
_cloudSyncToken = cloudSyncToken;
}
if (qTimetableLessonNum != null &&
qTimetableLessonNum != _qTimetableLessonNum) {
_qTimetableLessonNum = qTimetableLessonNum;
@@ -839,11 +892,115 @@ class SettingsProvider extends ChangeNotifier {
if (qSubjectsSubTiles != null && qSubjectsSubTiles != _qSubjectsSubTiles) {
_qSubjectsSubTiles = qSubjectsSubTiles;
}
// change updated at time
_updatedAt = DateTime.now();
// store or not
if (store) await _database?.store.storeSettings(this);
notifyListeners();
}
Future<void> updateFromMap({
required Map<dynamic, dynamic> map,
bool store = true,
}) async {
print(map);
await update(
store: store,
language: map["language"],
startPage: Pages.values[map["start_page"] ?? _startPage.index],
rounding: map["rounding"],
theme: ThemeMode.values[map["theme"] ?? _theme.index],
accentColor:
AccentColor.values[map["accent_color"] ?? _accentColor.index],
gradeColors: [
Color(map["grade_color1"] ?? _gradeColors[0].value),
Color(map["grade_color2"] ?? _gradeColors[1].value),
Color(map["grade_color3"] ?? _gradeColors[2].value),
Color(map["grade_color4"] ?? _gradeColors[3].value),
Color(map["grade_color5"] ?? _gradeColors[4].value),
],
newsEnabled: map["news"] == 1,
seenNews: map["seen_news"],
notificationsEnabled: map["notifications"] == 1,
notificationsGradesEnabled: map["notifications_grades"] == 1,
notificationsAbsencesEnabled: map["notifications_absences"] == 1,
notificationsMessagesEnabled: map["notifications_messages"] == 1,
notificationsLessonsEnabled: map["notifications_lessons"] == 1,
notificationsBitfield: map["notifications_bitfield"],
notificationPollInterval: map["notification_poll_interval"],
developerMode: map["developer_mode"] == 1,
vibrate:
VibrationStrength.values[map["vibration_strength"] ?? _vibrate.index],
abWeeks: map["ab_weeks"] == 1,
swapABweeks: map["swap_ab_weeks"] == 1,
updateChannel:
UpdateChannel.values[map["update_channel"] ?? _updateChannel.index],
config: Config.fromJson(jsonDecode(map["config"] ?? "{}")),
xFilcId: map["x_filc_id"],
analyticsEnabled: map["analytics_enabled"] == 1,
graphClassAvg: map["graph_class_avg"] == 1,
goodStudent: false,
presentationMode: map["presentation_mode"] == 1,
bellDelayEnabled: map["bell_delay_enabled"] == 1,
bellDelay: map["bell_delay"],
gradeOpeningFun: map["grade_opening_fun"] == 1,
iconPack: Map.fromEntries(
IconPack.values.map((e) => MapEntry(e.name, e)))[map["icon_pack"]]!,
customAccentColor:
Color(map["custom_accent_color"] ?? _customAccentColor.value),
customBackgroundColor:
Color(map["custom_background_color"] ?? _customBackgroundColor.value),
customHighlightColor:
Color(map["custom_highlight_color"] ?? _customHighlightColor.value),
customIconColor:
Color(map["custom_icon_color"] ?? _customIconColor.value),
customTextColor:
Color(map["custom_text_color"] ?? _customTextColor.value),
shadowEffect: map["shadow_effect"] == 1,
premiumScopes:
jsonDecode(map["premium_scopes"] ?? _premiumScopes).cast<String>(),
premiumAccessToken: map["premium_token"],
premiumLogin: map["premium_login"],
lastAccountId: map["last_account_id"],
renamedSubjectsEnabled: map["renamed_subjects_enabled"] == 1,
renamedSubjectsItalics: map["renamed_subjects_italics"] == 1,
renamedTeachersEnabled: map["renamed_teachers_enabled"] == 1,
renamedTeachersItalics: map["renamed_teachers_italics"] == 1,
liveActivityColor:
Color(map["live_activity_color"] ?? _liveActivityColor),
welcomeMessage: map["welcome_message"],
appIcon: map["app_icon"],
currentThemeId: map['current_theme_id'],
currentThemeDisplayName: map['current_theme_display_name'],
currentThemeCreator: map['current_theme_creator'],
showBreaks: map['show_breaks'] == 1,
// pinSetGeneral: map['general_s_pin'],
// pinSetPersonalize: map['personalize_s_pin'],
// pinSetNotify: map['notify_s_pin'],
// pinSetExtras: map['extras_s_pin'],
fontFamily: map['font_family'],
titleOnlyFont: map['title_only_font'] == 1,
plusSessionId: map['plus_session_id'],
calSyncRoomLocation: map['cal_sync_room_location'],
calSyncShowExams: map['cal_sync_show_exams'] == 1,
calSyncShowTeacher: map['cal_sync_show_teacher'] == 1,
calSyncRenamed: map['cal_sync_renamed'] == 1,
calendarId: map['calendar_id'],
navShadow: map['nav_shadow'] == 1,
newColors: map['new_colors'] == 1,
uwuMode: map['uwu_mode'] == 1,
newPopups: map['new_popups'] == 1,
unseenNewFeatures:
jsonDecode(map["unseen_new_features"] ?? "[]").cast<String>(),
cloudSyncEnabled: map['cloud_sync_enabled'] == 1,
cloudSyncToken: map['cloud_sync_token'],
qTimetableLessonNum: map['q_timetable_lesson_num'] == 1,
qTimetableSubTiles: map['q_timetable_sub_tiles'] == 1,
qSubjectsSubTiles: map['q_subjects_sub_tiles'] == 1,
);
}
void exportJson() {
String sets = json.encode(toMap());
Clipboard.setData(ClipboardData(text: sets));

View File

@@ -17,6 +17,14 @@ class User {
String nickname;
String picture;
int gradeStreak;
// new login method
String accessToken;
DateTime accessTokenExpire;
String refreshToken;
// cloud sync
// String qwidAccessToken;
// DateTime? qwidAccessTokenExpire;
// String qwidRefreshToken;
String get displayName => nickname != '' ? nickname : name;
bool get hasStreak => gradeStreak > 0;
@@ -32,6 +40,12 @@ class User {
this.nickname = "",
this.picture = "",
this.gradeStreak = 0,
required this.accessToken,
required this.accessTokenExpire,
required this.refreshToken,
// this.qwidAccessToken = "",
// this.qwidAccessTokenExpire,
// this.qwidRefreshToken = "",
}) {
if (id != null) {
this.id = id;
@@ -56,11 +70,22 @@ class User {
birth: DateTime.now(),
yearId: '1',
parents: [],
gradeDelay: 0,
),
role: Role.values[map["role"] ?? 0],
nickname: map["nickname"] ?? "",
picture: map["picture"] ?? "",
gradeStreak: map["grade_streak"] ?? 0,
accessToken: map["access_token"] ?? "",
accessTokenExpire: DateTime.parse(map["access_token_expire"] != ""
? map["access_token_expire"]
: DateTime.now().toIso8601String()),
refreshToken: map["refresh_token"] ?? "",
// qwidAccessToken: map["qwid_access_token"] ?? "",
// qwidAccessTokenExpire: map["qwid_access_token_expire"] != ""
// ? DateTime.parse(map["qwid_access_token_expire"])
// : null,
// qwidRefreshToken: map["qwid_refresh_token"] ?? "",
);
}
@@ -75,6 +100,15 @@ class User {
"role": role.index,
"nickname": nickname,
"picture": picture,
"grade_streak": gradeStreak,
"access_token": accessToken,
"access_token_expire": accessTokenExpire.toIso8601String(),
"refresh_token": refreshToken,
// "qwid_access_token": qwidAccessToken,
// "qwid_access_token_expire": qwidAccessTokenExpire != null
// ? qwidAccessTokenExpire!.toIso8601String()
// : "",
// "qwid_refresh_token": qwidRefreshToken,
};
}

View File

@@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
import 'package:home_widget/home_widget.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:shake_flutter/models/shake_theme.dart';
import 'package:shake_flutter/shake_flutter.dart';
Future<bool?> updateWidget() async {
try {
@@ -22,7 +24,9 @@ class ThemeModeObserver extends ChangeNotifier {
ThemeMode get themeMode => _themeMode;
bool get updateNavbarColor => _updateNavbarColor;
ThemeModeObserver({ThemeMode initialTheme = ThemeMode.system, bool updateNavbarColor = true})
ThemeModeObserver(
{ThemeMode initialTheme = ThemeMode.system,
bool updateNavbarColor = true})
: _themeMode = initialTheme,
_updateNavbarColor = updateNavbarColor;
@@ -31,5 +35,12 @@ class ThemeModeObserver extends ChangeNotifier {
_updateNavbarColor = updateNavbarColor;
if (Platform.isAndroid) updateWidget();
notifyListeners();
// change shake theme as well
ShakeTheme darkTheme = ShakeTheme();
darkTheme.accentColor = "#FFFFFF";
ShakeTheme lightTheme = ShakeTheme();
lightTheme.accentColor = "#000000";
Shake.setShakeTheme(mode == ThemeMode.dark ? darkTheme : lightTheme);
}
}

View File

@@ -125,8 +125,6 @@ class AppTheme {
onTertiary:
(newTertiary.computeLuminance() > 0.5 ? Colors.black : Colors.white)
.withOpacity(.9),
background: highlightColor,
onBackground: Colors.black.withOpacity(.9),
brightness: Brightness.light,
error: lightColors.red,
onError: Colors.white.withOpacity(.9),
@@ -141,9 +139,9 @@ class AppTheme {
indicatorColor:
accent.withOpacity(accentColor == AccentColor.adaptive ? 0.4 : 0.8),
iconTheme:
MaterialStateProperty.all(IconThemeData(color: lightColors.text)),
WidgetStateProperty.all(IconThemeData(color: lightColors.text)),
backgroundColor: highlightColor,
labelTextStyle: MaterialStateProperty.all(TextStyle(
labelTextStyle: WidgetStateProperty.all(TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.w500,
color: lightColors.text.withOpacity(0.8),
@@ -250,8 +248,6 @@ class AppTheme {
onTertiary:
(newTertiary.computeLuminance() > 0.5 ? Colors.black : Colors.white)
.withOpacity(.9),
background: highlightColor,
onBackground: Colors.white.withOpacity(.9),
brightness: Brightness.dark,
error: darkColors.red,
onError: Colors.black.withOpacity(.9),
@@ -266,9 +262,9 @@ class AppTheme {
indicatorColor:
accent.withOpacity(accentColor == AccentColor.adaptive ? 0.4 : 0.8),
iconTheme:
MaterialStateProperty.all(IconThemeData(color: darkColors.text)),
WidgetStateProperty.all(IconThemeData(color: darkColors.text)),
backgroundColor: highlightColor,
labelTextStyle: MaterialStateProperty.all(TextStyle(
labelTextStyle: WidgetStateProperty.all(TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.w500,
color: darkColors.text.withOpacity(0.8),

View File

@@ -178,7 +178,8 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData,
// Ads
case FilterType.ads:
if (adProvider.available) {
items = ad_filter.getWidgets(adProvider.ads);
items = ad_filter.getWidgets(
adProvider.ads, context);
}
break;
}
@@ -259,7 +260,7 @@ Widget filterItemBuilder(
? const EdgeInsets.symmetric(vertical: 8.0)
: const EdgeInsets.symmetric(vertical: 4.0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.vertical(
top: separated || isAfterSeparated
? const Radius.circular(16.0)

View File

@@ -1,23 +1,70 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:refilc/models/ad.dart';
import 'package:refilc/ui/date_widget.dart';
import 'package:refilc_mobile_ui/common/widgets/ad/ad_tile.dart';
import 'package:refilc_mobile_ui/common/widgets/ad/ad_viewable.dart' as mobile;
import 'package:refilc_mobile_ui/plus/plus_screen.dart';
import 'package:refilc_plus/providers/plus_provider.dart';
import 'package:uuid/uuid.dart';
List<DateWidget> getWidgets(List<Ad> providerAds) {
List<DateWidget> getWidgets(List<Ad> providerAds, BuildContext context) {
List<DateWidget> items = [];
bool hasPlus = Provider.of<PlusProvider>(context).hasPremium;
DateWidget plusWidget = DateWidget(
key: const Uuid().v4(),
date: DateTime.now(),
widget: AdTile(
Ad(
title: 'reFilc+',
description:
'Fizess elő reFilc+-ra, rejtsd el a hirdetéseket és támogasd az app működését!',
author: '',
logoUrl: Uri.parse('https://refilc.hu/image/brand/logo.png'),
overridePremium: false,
date: DateTime(2007, 6, 29, 9, 41),
expireDate: DateTime.now().add(const Duration(days: 11)),
launchUrl: Uri.parse('https://refilc.hu/plus'),
),
onTap: () => Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
return const PlusScreen();
})),
padding: const EdgeInsets.symmetric(horizontal: 5.0),
showExternalIcon: false,
),
);
if (providerAds.isNotEmpty) {
for (var ad in providerAds) {
if (ad.date.isBefore(DateTime.now()) &&
ad.expireDate.isAfter(DateTime.now())) {
providerAds.sort((a, b) => -a.date.compareTo(b.date));
ad.expireDate.isAfter(DateTime.now()) &&
DateTime.now().hour.isOdd) {
if (!hasPlus || ad.overridePremium) {
providerAds.sort((a, b) => -a.date.compareTo(b.date));
items.add(DateWidget(
key: ad.description,
date: ad.date,
widget: mobile.AdViewable(ad),
));
items.add(DateWidget(
key: ad.description,
date: ad.date,
widget: mobile.AdViewable(ad),
));
}
} else {
if (DateTime.now().weekday == DateTime.saturday &&
items.isEmpty &&
!hasPlus) {
items.add(plusWidget);
}
}
}
} else {
if (DateTime.now().weekday == DateTime.saturday &&
items.isEmpty &&
!hasPlus) {
items.add(plusWidget);
}
}
return items;

View File

@@ -364,7 +364,7 @@ class ColorPickerInputState extends State<ColorPickerInput> {
controller: textEditingController,
style: TextStyle(
fontSize: 18,
color: Theme.of(context).colorScheme.onBackground,
color: Theme.of(context).colorScheme.onSurface,
),
inputFormatters: [
UpperCaseTextFormatter(),

View File

@@ -39,4 +39,16 @@ class JwtUtils {
}
return null;
}
static String? getInstituteFromJWT(String jwt) {
var jwtData = decodeJwt(jwt);
return jwtData?["kreta:institute_code"];
}
static String? getUsernameFromJWT(String jwt) {
var jwtData = decodeJwt(jwt);
return jwtData?["kreta:user_name"];
}
}

View File

@@ -3,10 +3,10 @@ description: "Egy nem hivatalos e-KRÉTA kliens, diákoktól diákoknak."
homepage: https://refilc.hu
publish_to: "none"
version: 5.0.2+266
version: 5.0.6+277
environment:
sdk: ">=2.17.0 <=3.3.2"
sdk: ">=3.3.2 <=3.6.0"
dependencies:
flutter:
@@ -25,9 +25,9 @@ dependencies:
flutter_localizations:
sdk: flutter
i18n_extension: ^11.0.11
i18n_extension: ^12.0.1
sqflite: ^2.2.0+2
intl: ^0.18.1
intl: ^0.19.0
provider: ^6.1.1
http: ^1.1.2
uuid: ^4.2.1
@@ -39,53 +39,60 @@ dependencies:
# ref: master
path_provider: ^2.0.2
permission_handler: ^11.0.1
share_plus: ^7.0.2
connectivity_plus: ^5.0.2
share_plus: ^10.0.3
connectivity_plus: ^6.0.3
flutter_displaymode: ^0.6.0
quick_actions: ^1.0.1
animated_list_plus: ^0.5.0
dynamic_color: ^1.2.2
material_color_utilities: ^0.8.0
material_color_utilities: ^0.11.1
crypto: ^3.0.2
elegant_notification: ^1.6.1
elegant_notification: ^2.2.0
flutter_feather_icons: ^2.0.0+1
live_activities: ^1.7.4
animated_flip_counter: ^0.2.5
# live_activities: ^1.7.4
animated_flip_counter: ^0.3.4
lottie: ^3.1.0
rive: ^0.12.4
animated_background: ^2.0.0
dropdown_button2: ^2.3.9
home_widget: ^0.4.1
home_widget:
git:
url: https://github.com/refilc/home_widget.git
ref: flutter-beta
flutter_expandable_fab: ^2.0.0
uni_links: ^0.5.1
url_launcher: ^6.1.6
workmanager: ^0.5.1
# workmanager:
# git:
# url: https://github.com/refilc/flutter_workmanager.git
# ref: v0.5.1
flutter_svg: ^2.0.10+1
image_picker: ^1.0.7
animations: ^2.0.1
background_fetch: ^1.1.5
flutter_local_notifications: ^16.2.0
package_info_plus: ^5.0.1
screenshot: ^2.1.0
flutter_local_notifications: ^18.0.1
package_info_plus: ^8.0.0
screenshot: ^3.0.0
flutter_staggered_grid_view: ^0.7.0
sqflite_common_ffi_web: ^0.4.0
image_crop:
git:
url: https://github.com/kimaah/image_crop.git
googleapis: ^12.0.0
googleapis: ^13.2.0
google_sign_in: ^6.2.1
extension_google_sign_in_as_googleapis_auth: ^2.0.12
maps_launcher: ^2.2.0
google_fonts: ^6.1.0
flutter_stripe: ^10.0.0
# flutter_stripe: ^11.3.0
get_it: ^7.6.7
xml: ^6.5.0
carousel_slider: ^4.2.1
carousel_slider: ^5.0.0
flutter_portal: ^1.1.4
shake_flutter: ^17.0.0
dev_dependencies:
flutter_lints: ^3.0.1
flutter_launcher_icons: "^0.13.1"
flutter_lints: ^5.0.0
flutter_launcher_icons: ^0.14.2
flutter_native_splash: "^2.3.10"
sqflite_common_ffi: ^2.0.0+3

View File

@@ -41,7 +41,7 @@ class FilterBar extends StatelessWidget implements PreferredSizeWidget {
color: Theme.of(context).colorScheme.secondary.withOpacity(0.25),
borderRadius: BorderRadius.circular(45.0),
),
overlayColor: MaterialStateProperty.all(const Color(0x00000000)),
overlayColor: WidgetStateProperty.all(const Color(0x00000000)),
// Tabs
padding: EdgeInsets.zero,
tabs: items,

View File

@@ -287,7 +287,7 @@ class AbsencesPageState extends State<AbsencesPage>
return FadeThroughTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
fillColor: Theme.of(context).colorScheme.background,
fillColor: Theme.of(context).colorScheme.surface,
child: child,
);
},

View File

@@ -68,7 +68,7 @@ class LoginScreenState extends State<LoginScreen> {
overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.red),
),
onActionPressed: () {},
// onActionPressed: () {},
onCloseButtonPressed: () {},
onDismiss: () {},
onProgressFinished: () {},
@@ -340,7 +340,7 @@ class LoginScreenState extends State<LoginScreen> {
overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.black),
),
onActionPressed: () {},
// onActionPressed: () {},
onCloseButtonPressed: () {},
onDismiss: () {},
onProgressFinished: () {},

View File

@@ -776,7 +776,7 @@ class SettingsScreenState extends State<SettingsScreen>
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.background),
.surface),
child: Material(
type: MaterialType.transparency,
child: SwitchListTile(

View File

@@ -2,7 +2,7 @@ name: refilc_desktop_ui
publish_to: "none"
environment:
sdk: ">=2.17.0 <=3.3.2"
sdk: ">=3.3.2 <=3.6.0"
dependencies:
flutter:
@@ -26,22 +26,22 @@ dependencies:
provider: ^6.1.1
url_launcher: ^6.2.5
flutter_linkify: ^6.0.0
flutter_markdown: ^0.6.20+1
flutter_markdown: ^0.7.2+1
animations: ^2.0.11
confetti: ^0.7.0
auto_size_text: ^3.0.0
flutter_acrylic: ^1.1.3
elegant_notification: ^1.13.0
elegant_notification: ^2.2.0
flutter_staggered_grid_view: ^0.7.0
i18n_extension: ^11.0.12
i18n_extension: ^12.0.1
flutter_expandable_fab: ^2.0.0
collection: ^1.18.0
animated_list_plus: ^0.5.2
intl: ^0.18.1
intl: ^0.19.0
flutter_custom_tabs: ^2.0.0+1
dev_dependencies:
flutter_lints: ^3.0.1
flutter_lints: ^4.0.0
flutter:
uses-material-design: true

View File

@@ -5,7 +5,7 @@ class KretaAPI {
static const login = BaseKreta.kretaIdp + KretaApiEndpoints.token;
static const logout = BaseKreta.kretaIdp + KretaApiEndpoints.revoke;
static const nonce = BaseKreta.kretaIdp + KretaApiEndpoints.nonce;
static const clientId = "kreta-ellenorzo-mobile-android";
static const clientId = "kreta-ellenorzo-student-mobile-ios";
// ELLENORZO API
static String notes(String iss) =>

View File

@@ -1,15 +1,16 @@
// ignore_for_file: avoid_print
// ignore_for_file: avoid_print, use_build_context_synchronously
import 'dart:convert';
import 'dart:io';
import 'package:refilc/api/login.dart';
import 'package:refilc/api/nonce.dart';
// import 'package:refilc/api/login.dart';
// import 'package:refilc/api/nonce.dart';
import 'package:refilc/api/providers/database_provider.dart';
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/api/providers/status_provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/models/user.dart';
import 'package:refilc/utils/jwt.dart';
// import 'package:refilc/utils/jwt.dart';
import 'package:refilc_kreta_api/client/api.dart';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart' as http;
@@ -24,17 +25,20 @@ class KretaClient {
late final SettingsProvider _settings;
late final UserProvider _user;
late final DatabaseProvider _database;
late final StatusProvider _status;
bool _loginRefreshing = false;
// bool _loginRefreshing = false;
KretaClient({
this.accessToken,
required SettingsProvider settings,
required UserProvider user,
required DatabaseProvider database,
required StatusProvider status,
}) : _settings = settings,
_user = user,
_database = database,
_status = status,
userAgent = settings.config.userAgent {
var ioclient = HttpClient();
@@ -63,10 +67,14 @@ class KretaClient {
headerMap = {};
}
if (accessToken == null || accessToken == '') {
accessToken = _user.user?.accessToken;
}
try {
http.Response? res;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 2; i++) {
if (autoHeader) {
if (!headerMap.containsKey("authorization") && accessToken != null) {
headerMap["authorization"] = "Bearer $accessToken";
@@ -81,13 +89,15 @@ class KretaClient {
if (res.statusCode == 401) {
headerMap.remove("authorization");
await refreshLogin();
print("DEBUG: 401 error, refreshing login");
print("DEBUG: 401 error, URL: $url");
// await refreshLogin();
} else {
break;
}
// Wait before retrying
await Future.delayed(const Duration(milliseconds: 500));
await Future.delayed(const Duration(milliseconds: 1500));
}
if (res == null) throw "Login error";
@@ -125,10 +135,14 @@ class KretaClient {
headerMap = {};
}
if (accessToken == null || accessToken == '') {
accessToken = _user.user?.accessToken;
}
try {
http.Response? res;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 2; i++) {
if (autoHeader) {
if (!headerMap.containsKey("authorization") && accessToken != null) {
headerMap["authorization"] = "Bearer $accessToken";
@@ -146,11 +160,14 @@ class KretaClient {
res = await client.post(Uri.parse(url), headers: headerMap, body: body);
if (res.statusCode == 401) {
await refreshLogin();
// await refreshLogin();
headerMap.remove("authorization");
} else {
break;
}
// Wait before retrying
await Future.delayed(const Duration(milliseconds: 1500));
}
if (res == null) throw "Login error";
@@ -183,6 +200,10 @@ class KretaClient {
headerMap = {};
}
if (accessToken == null || accessToken == '') {
accessToken = _user.user?.accessToken;
}
try {
http.StreamedResponse? res;
@@ -212,8 +233,8 @@ class KretaClient {
res = await request.send();
if (res.statusCode == 401) {
headerMap.remove("authorization");
await refreshLogin();
headerMap.remove("authorization");
// await refreshLogin();
} else {
break;
}
@@ -232,65 +253,86 @@ class KretaClient {
}
}
Future<void> refreshLogin() async {
if (_loginRefreshing) return;
_loginRefreshing = true;
Future<String?> refreshLogin() async {
// if (_loginRefreshing) return null;
// _loginRefreshing = true;
User? loginUser = _user.user;
if (loginUser == null) return;
if (loginUser == null) return null;
Map<String, String> headers = {
"content-type": "application/x-www-form-urlencoded",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"accept": "*/*",
"user-agent": "eKretaStudent/264745 CFNetwork/1494.0.7 Darwin/23.4.0",
};
String nonceStr = await getAPI(KretaAPI.nonce, json: false);
Nonce nonce =
getNonce(nonceStr, loginUser.username, loginUser.instituteCode);
headers.addAll(nonce.header());
if (_settings.presentationMode) {
print("DEBUG: refreshLogin: ${loginUser.id}");
} else {
print("DEBUG: refreshLogin: ${loginUser.id} ${loginUser.name}");
}
Map? loginRes = await postAPI(
KretaAPI.login,
headers: headers,
body: User.loginBody(
username: loginUser.username,
password: loginUser.password,
instituteCode: loginUser.instituteCode,
),
);
refreshToken ??= loginUser.refreshToken;
if (loginRes != null) {
if (loginRes.containsKey("access_token")) {
accessToken = loginRes["access_token"];
}
if (loginRes.containsKey("refresh_token")) {
refreshToken = loginRes["refresh_token"];
}
// Update role
loginUser.role =
JwtUtils.getRoleFromJWT(accessToken ?? "") ?? Role.student;
}
print("REFRESH TOKEN BELOW");
print(refreshToken);
if (refreshToken != null) {
Map? refreshRes = await postAPI(KretaAPI.login,
// print("REFRESHING LOGIN");
Map? res = await postAPI(KretaAPI.login,
headers: headers,
body: User.refreshBody(
refreshToken: refreshToken!,
instituteCode: loginUser.instituteCode));
if (refreshRes != null) {
if (refreshRes.containsKey("id_token")) {
idToken = refreshRes["id_token"];
refreshToken: loginUser.refreshToken,
instituteCode: loginUser.instituteCode,
));
print("REFRESH RESPONSE BELOW");
print(res);
if (res != null) {
if (res.containsKey("error")) {
// remove user if refresh token expired
if (res["error"] == "invalid_grant") {
// remove user from app
// _user.removeUser(loginUser.id);
// await _database.store.removeUser(loginUser.id);
print("invalid refresh token (invalid_grant)");
// return error
return "refresh_token_expired";
}
}
if (res.containsKey("access_token")) {
accessToken = res["access_token"];
loginUser.accessToken = res["access_token"];
loginUser.accessTokenExpire =
DateTime.now().add(Duration(seconds: (res["expires_in"] - 30)));
_database.store.storeUser(loginUser);
_user.refresh();
}
if (res.containsKey("refresh_token")) {
refreshToken = res["refresh_token"];
loginUser.refreshToken = res["refresh_token"];
_database.store.storeUser(loginUser);
_user.refresh();
}
if (res.containsKey("id_token")) {
idToken = res["id_token"];
}
// _loginRefreshing = false;
print('successful refresh');
return 'success';
} else {
// _loginRefreshing = false;
return null;
}
} else {
// _loginRefreshing = false;
return null;
}
_loginRefreshing = false;
// return null;
}
Future<void> logout() async {

View File

@@ -11,6 +11,8 @@ class Student {
String? address;
String? groupId;
List<String> parents;
int gradeDelay;
String? bankAccount;
// List<String> parentsPhone;
String? className;
@@ -22,6 +24,8 @@ class Student {
required this.yearId,
this.address,
required this.parents,
required this.gradeDelay,
this.bankAccount,
// required this.parentsPhone,
this.json,
});
@@ -57,6 +61,10 @@ class Student {
: null
: null,
parents: parents,
gradeDelay: json["Intezmeny"]["TestreszabasBeallitasok"]
["ErtekelesekMegjelenitesenekKesleltetesenekMerteke"] ??
0,
bankAccount: json["Bankszamla"]["BankszamlaSzam"],
json: json,
);
}

View File

@@ -111,13 +111,16 @@ class GradeProvider with ChangeNotifier {
grade.teacher.renamedTo =
renamedTeachers.isNotEmpty ? renamedTeachers[grade.teacher.id] : null;
grade.value.value =
_settings.goodStudent ? 5 : grade.json!["SzamErtek"] ?? 0;
grade.value.value = _settings.goodStudent
? (grade.value.percentage ? 100 : 5)
: grade.json!["SzamErtek"] ?? 0;
grade.value.valueName = _settings.goodStudent
? "Jeles".i18n
: '${grade.json!["SzovegesErtek"]}'
.replaceAll(RegExp(r'[(]+[12345]?[)]'), '')
.i18n;
: (grade.value.percentage
? '${grade.json!["SzovegesErtek"]}'
: '${grade.json!["SzovegesErtek"]}'
.replaceAll(RegExp(r'[(]+[12345]?[)]'), '')
.i18n);
grade.value.shortName = _settings.goodStudent
? "Jeles".i18n
: '${grade.json!["SzovegesErtekelesRovidNev"]}' != "null" &&
@@ -150,7 +153,7 @@ class GradeProvider with ChangeNotifier {
for (Grade grade in grs) {
if (grade.value.value == 5) {
gradeStreak++;
} else {
} else if (grade.value.value !=0) {
break;
}
}

View File

@@ -8,21 +8,27 @@ extension Localization on String {
"Elégséges": "Warning but passing",
"Közepes": "Passed",
"": "Good",
"Jeles": "Excellent"
"Jeles": "Excellent",
"Példás": "Excellent",
"Nem írt": "Did not write",
},
"hu_hu": {
"Elégtelen": "Elégtelen",
"Elégséges": "Elégséges",
"Közepes": "Közepes",
"": "",
"Jeles": "Jeles"
"Jeles": "Jeles",
"Példás": "Példás",
"Nem írt": "Nem írt",
},
"de_de": {
"Elégtelen": "Ungenügend",
"Elégséges": "Mangelhaft",
"Közepes": "Ausreichend",
"": "Befriedigend",
"Jeles": "Gut"
"Jeles": "Gut",
"Példás": "Gut",
"Nem írt": "Nicht geschrieben",
},
};

View File

@@ -19,7 +19,7 @@ class ShareProvider extends ChangeNotifier {
// }
// themes
Future<SharedTheme> shareCurrentTheme(
Future<(SharedTheme?, int)> shareCurrentTheme(
BuildContext context, {
bool isPublic = false,
bool shareNick = true,
@@ -56,9 +56,13 @@ class ShareProvider extends ChangeNotifier {
};
SharedTheme theme = SharedTheme.fromJson(themeJson, gradeColors);
FilcAPI.addSharedTheme(theme);
int shareResult = await FilcAPI.addSharedTheme(theme);
return theme;
if (shareResult == 201) {
return (theme, 201);
} else {
return (null, shareResult);
}
}
Future<SharedTheme?> getThemeById(BuildContext context,
@@ -142,7 +146,7 @@ class ShareProvider extends ChangeNotifier {
}
// grade colors
Future<SharedGradeColors> shareCurrentGradeColors(
Future<(SharedGradeColors?, int)> shareCurrentGradeColors(
BuildContext context, {
bool isPublic = false,
bool shareNick = true,
@@ -162,9 +166,13 @@ class ShareProvider extends ChangeNotifier {
};
SharedGradeColors gradeColors = SharedGradeColors.fromJson(gradeColorsJson);
FilcAPI.addSharedGradeColors(gradeColors);
int shareResult = await FilcAPI.addSharedGradeColors(gradeColors);
return gradeColors;
if (shareResult == 201) {
return (gradeColors, 201);
} else {
return (null, shareResult);
}
}
Future<SharedGradeColors?> getGradeColorsById(BuildContext context,

View File

@@ -2,7 +2,7 @@ name: refilc_kreta_api
publish_to: "none"
environment:
sdk: ">=2.17.0 <=3.3.2"
sdk: ">=3.3.2 <=3.6.0"
dependencies:
flutter:
@@ -11,10 +11,10 @@ dependencies:
path: ../refilc/
http: ^1.1.2
provider: ^6.1.1
file_picker: ^6.1.1
intl: ^0.18.1
i18n_extension: ^11.0.11
file_picker: ^8.0.5
intl: ^0.19.0
i18n_extension: ^12.0.1
uuid: ^4.3.3
dev_dependencies:
flutter_lints: ^3.0.1
flutter_lints: ^4.0.0

View File

@@ -14,7 +14,7 @@ class BottomCard extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14.0),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
),
child: Column(
mainAxisSize: MainAxisSize.min,

View File

@@ -22,7 +22,7 @@ class RoundedBottomSheet extends StatelessWidget {
return AnimatedContainer(
duration: const Duration(milliseconds: 500),
decoration: BoxDecoration(
color: backgroundColor ?? Theme.of(context).colorScheme.background,
color: backgroundColor ?? Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(borderRadius),
topRight: Radius.circular(borderRadius),

View File

@@ -1,5 +1,6 @@
import 'package:refilc/theme/colors/colors.dart';
import 'package:flutter/material.dart';
import 'chips.i18n.dart';
class BetaChip extends StatelessWidget {
const BetaChip({super.key, this.disabled = false});
@@ -22,7 +23,7 @@ class BetaChip extends StatelessWidget {
padding: const EdgeInsets.only(left: 8, right: 8),
child: Center(
child: Text(
"BETA",
"beta".i18n,
softWrap: true,
style: TextStyle(
fontSize: 10,

View File

@@ -0,0 +1,24 @@
import 'package:i18n_extension/i18n_extension.dart';
extension ScreensLocalization on String {
static final _t = Translations.byLocale("hu_hu") +
{
"en_en": {
"new": "NEW",
"beta": "BETA",
},
"hu_hu": {
"new": "ÚJ",
"beta": "BÉTA",
},
"de_de": {
"new": "NEU",
"beta": "BETA",
},
};
String get i18n => localize(this, _t);
String fill(List<Object> params) => localizeFill(this, params);
String plural(int value) => localizePlural(value, this, _t);
String version(Object modifier) => localizeVersion(modifier, this, _t);
}

View File

@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'chips.i18n.dart';
class NewChip extends StatelessWidget {
const NewChip({super.key, this.disabled = false});
final bool disabled;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color:
disabled ? AppColors.of(context).text.withOpacity(.25) : Colors.red,
borderRadius: BorderRadius.circular(12.0),
),
padding:
const EdgeInsets.only(left: 6.0, right: 8.0, top: 4.0, bottom: 4.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.hotel_class_rounded,
color: disabled
? AppColors.of(context).text.withOpacity(.5)
: Colors.white,
size: 14.0,
),
const SizedBox(width: 2.0),
Text(
'new'.i18n,
style: TextStyle(
color: disabled
? AppColors.of(context).text.withOpacity(.5)
: Colors.white,
fontSize: 12.0,
fontWeight: FontWeight.bold,
),
),
],
),
);
}
}

View File

@@ -49,7 +49,7 @@ class _FilterBarState extends State<FilterBar> {
controller: widget.controller,
isScrollable: widget.scrollable,
physics: const BouncingScrollPhysics(),
// Label
// label
labelStyle: Theme.of(context).textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w600,
fontSize: 15.0,
@@ -57,15 +57,17 @@ class _FilterBarState extends State<FilterBar> {
labelPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
labelColor: Theme.of(context).colorScheme.secondary,
unselectedLabelColor: AppColors.of(context).text.withOpacity(0.65),
// Indicator
// indicator
indicatorSize: TabBarIndicatorSize.tab,
indicatorPadding: const EdgeInsets.symmetric(vertical: 8.0),
indicator: BoxDecoration(
color: Theme.of(context).colorScheme.tertiary.withOpacity(.2),
borderRadius: BorderRadius.circular(45.0),
),
overlayColor: MaterialStateProperty.all(const Color(0x00000000)),
// Tabs
overlayColor: WidgetStateProperty.all(const Color(0x00000000)),
// underline (bottom border)
dividerColor: Colors.transparent,
// tabs
padding: EdgeInsets.zero,
tabs: widget.censored
? censoredItemsWidth

View File

@@ -22,7 +22,7 @@ class OutlinedRoundButton extends StatelessWidget {
width: size,
height: size,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
border: Border.all(
color: Theme.of(context).colorScheme.secondary.withOpacity(0.1),
width: 1.1,

View File

@@ -35,7 +35,7 @@ class Panel extends StatelessWidget {
borderRadius: BorderRadius.circular(16.0),
color: isTransparent
? Colors.transparent
: Theme.of(context).colorScheme.background,
: Theme.of(context).colorScheme.surface,
boxShadow: [
if ((hasShadow && !isTransparent) &&
Provider.of<SettingsProvider>(context, listen: false)
@@ -87,7 +87,7 @@ class PanelHeader extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0)),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)
.shadowEffect)
@@ -113,7 +113,7 @@ class PanelBody extends StatelessWidget {
return Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)
.shadowEffect)
@@ -144,7 +144,7 @@ class PanelFooter extends StatelessWidget {
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(16.0),
bottomRight: Radius.circular(16.0)),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)
.shadowEffect)

View File

@@ -266,12 +266,16 @@ class _ProfileImageState extends State<ProfileImage> {
child: Transform.translate(
offset: Offset(-widget.radius / 4, -widget.radius / 4),
child: Container(
alignment: Alignment.topLeft,
child: Text(
'🔥',
style: TextStyle(fontSize: widget.radius * 0.8),
),
),
alignment: Alignment.topLeft,
child: Image.asset(
'assets/images/apple_fire_emoji.png',
width: widget.radius,
)
// Text(
// '🔥',
// style: TextStyle(fontSize: widget.radius * 0.8),
// ),
),
),
),
),

View File

@@ -9,7 +9,7 @@ void showSlidingBottomSheet(
cornerRadius: 16,
cornerRadiusOnFullscreen: 0,
avoidStatusBar: true,
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
duration: const Duration(milliseconds: 400),
snapSpec: const ss.SnapSpec(
snap: true,
@@ -18,7 +18,7 @@ void showSlidingBottomSheet(
),
headerBuilder: (context, state) {
return Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -37,7 +37,7 @@ void showSlidingBottomSheet(
},
builder: (context, state) {
return Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
child: Padding(
padding: const EdgeInsets.fromLTRB(12.0, 0, 12.0, 8.0),
child: child),

View File

@@ -46,7 +46,7 @@ class SplittedPanel extends StatelessWidget {
decoration: BoxDecoration(
color: isTransparent
? Colors.transparent
: Theme.of(context).colorScheme.background,
: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.vertical(
top: Radius.circular(i == 0 ? 16.0 : 8.0),
bottom: Radius.circular(children!.length == i + 1 ? 16.0 : 8.0),

View File

@@ -10,7 +10,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
double valueFromPercentageInRange({required final double min, max, percentage}) {
double valueFromPercentageInRange(
{required final double min, max, percentage}) {
return percentage * (max - min) + min;
}
@@ -44,7 +45,8 @@ typedef _ViewablePreviewBuilderChildless = Widget Function(
Rect _getRect(GlobalKey globalKey) {
assert(globalKey.currentContext != null);
final RenderBox renderBoxContainer = globalKey.currentContext!.findRenderObject()! as RenderBox;
final RenderBox renderBoxContainer =
globalKey.currentContext!.findRenderObject()! as RenderBox;
final Offset containerOffset = renderBoxContainer.localToGlobal(
renderBoxContainer.paintBounds.topLeft,
);
@@ -101,7 +103,8 @@ class _ViewableState extends State<Viewable> with TickerProviderStateMixin {
final double screenWidth = MediaQuery.of(context).size.width;
final double center = screenWidth / 2;
final bool centerDividesChild = childRect.left < center && childRect.right > center;
final bool centerDividesChild =
childRect.left < center && childRect.right > center;
final double distanceFromCenter = (center - childRect.center.dx).abs();
if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
return _ViewableLocation.center;
@@ -132,7 +135,7 @@ class _ViewableState extends State<Viewable> with TickerProviderStateMixin {
return ClipRRect(
borderRadius: BorderRadius.circular(16.0),
child: Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16.0),
child: Stack(
children: [
@@ -270,7 +273,8 @@ class _DecoyChild extends StatefulWidget {
_DecoyChildState createState() => _DecoyChildState();
}
class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin {
class _DecoyChildState extends State<_DecoyChild>
with TickerProviderStateMixin {
static const Color _lightModeMaskColor = Color(0xFF888888);
static const Color _masklessColor = Color(0xFFFFFFFF);
@@ -327,7 +331,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
}
Widget _buildAnimation(BuildContext context, Widget? child) {
final Color color = widget.controller.status == AnimationStatus.reverse ? _masklessColor : _mask.value;
final Color color = widget.controller.status == AnimationStatus.reverse
? _masklessColor
: _mask.value;
return Positioned.fromRect(
rect: _rect.value!,
child: ShaderMask(
@@ -373,7 +379,8 @@ class _ViewableRoute<T> extends PopupRoute<T> {
static const Color _kModalBarrierColor = Color(0x6604040F);
static const Duration _kModalPopupTransitionDuration = Duration(milliseconds: 335);
static const Duration _kModalPopupTransitionDuration =
Duration(milliseconds: 335);
final List<Widget> _actions;
final _ViewablePreviewBuilderChildless? _builder;
@@ -396,7 +403,8 @@ class _ViewableRoute<T> extends PopupRoute<T> {
static final RectTween _rectTween = RectTween();
static final Animatable<Rect?> _rectAnimatable = _rectTween.chain(_curve);
static final RectTween _rectTweenReverse = RectTween();
static final Animatable<Rect?> _rectAnimatableReverse = _rectTweenReverse.chain(
static final Animatable<Rect?> _rectAnimatableReverse =
_rectTweenReverse.chain(
_curveReverse,
);
static final RectTween _sheetRectTween = RectTween();
@@ -407,10 +415,12 @@ class _ViewableRoute<T> extends PopupRoute<T> {
_curveReverse,
);
static final Tween<double> _sheetScaleTween = Tween<double>();
static final Animatable<double> _sheetScaleAnimatable = _sheetScaleTween.chain(
static final Animatable<double> _sheetScaleAnimatable =
_sheetScaleTween.chain(
_curve,
);
static final Animatable<double> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(
static final Animatable<double> _sheetScaleAnimatableReverse =
_sheetScaleTween.chain(
_curveReverse,
);
final Tween<double> _opacityTween = Tween<double>(begin: 0.0, end: 1.0);
@@ -441,7 +451,8 @@ class _ViewableRoute<T> extends PopupRoute<T> {
return offsetScaled & sizeScaled;
}
static AlignmentDirectional getSheetAlignment(_ViewableLocation contextMenuLocation) {
static AlignmentDirectional getSheetAlignment(
_ViewableLocation contextMenuLocation) {
switch (contextMenuLocation) {
case _ViewableLocation.center:
return AlignmentDirectional.topCenter;
@@ -452,17 +463,24 @@ class _ViewableRoute<T> extends PopupRoute<T> {
}
}
static Rect _getSheetRectBegin(Orientation? orientation, _ViewableLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
static Rect _getSheetRectBegin(Orientation? orientation,
_ViewableLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
switch (contextMenuLocation) {
case _ViewableLocation.center:
final Offset target = orientation == Orientation.portrait ? childRect.bottomCenter : childRect.topCenter;
final Offset target = orientation == Orientation.portrait
? childRect.bottomCenter
: childRect.topCenter;
final Offset centered = target - Offset(sheetRect.width / 2, 0.0);
return centered & sheetRect.size;
case _ViewableLocation.right:
final Offset target = orientation == Orientation.portrait ? childRect.bottomRight : childRect.topRight;
final Offset target = orientation == Orientation.portrait
? childRect.bottomRight
: childRect.topRight;
return (target - Offset(sheetRect.width, 0.0)) & sheetRect.size;
case _ViewableLocation.left:
final Offset target = orientation == Orientation.portrait ? childRect.bottomLeft : childRect.topLeft;
final Offset target = orientation == Orientation.portrait
? childRect.bottomLeft
: childRect.topLeft;
return target & sheetRect.size;
}
}
@@ -478,7 +496,9 @@ class _ViewableRoute<T> extends PopupRoute<T> {
}
void _updateTweenRects() {
final Rect childRect = _scale == null ? _getRect(_childGlobalKey) : _getScaledRect(_childGlobalKey, _scale!);
final Rect childRect = _scale == null
? _getRect(_childGlobalKey)
: _getScaledRect(_childGlobalKey, _scale!);
_rectTween.begin = _previousChildRect;
_rectTween.end = childRect;
@@ -546,21 +566,29 @@ class _ViewableRoute<T> extends PopupRoute<T> {
}
@override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return Container();
}
@override
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
_lastOrientation = orientation;
if (!animation.isCompleted) {
final bool reverse = animation.status == AnimationStatus.reverse;
final Rect rect = reverse ? _rectAnimatableReverse.evaluate(animation)! : _rectAnimatable.evaluate(animation)!;
final Rect sheetRect = reverse ? _sheetRectAnimatableReverse.evaluate(animation)! : _sheetRectAnimatable.evaluate(animation)!;
final double sheetScale = reverse ? _sheetScaleAnimatableReverse.evaluate(animation) : _sheetScaleAnimatable.evaluate(animation);
final Rect rect = reverse
? _rectAnimatableReverse.evaluate(animation)!
: _rectAnimatable.evaluate(animation)!;
final Rect sheetRect = reverse
? _sheetRectAnimatableReverse.evaluate(animation)!
: _sheetRectAnimatable.evaluate(animation)!;
final double sheetScale = reverse
? _sheetScaleAnimatableReverse.evaluate(animation)
: _sheetScaleAnimatable.evaluate(animation);
return Stack(
children: <Widget>[
Positioned.fromRect(
@@ -623,7 +651,8 @@ class _ContextMenuRouteStatic extends StatefulWidget {
_ContextMenuRouteStaticState createState() => _ContextMenuRouteStaticState();
}
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with TickerProviderStateMixin {
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic>
with TickerProviderStateMixin {
static const double _kMinScale = 0.8;
static const double _kSheetScaleThreshold = 0.9;
@@ -639,7 +668,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
late Animation<double> _sheetScaleAnimation;
late Animation<double> _sheetOpacityAnimation;
static double _getScale(Orientation orientation, double maxDragDistance, double dy) {
static double _getScale(
Orientation orientation, double maxDragDistance, double dy) {
final double dyDirectional = dy <= 0.0 ? dy : -dy;
return math.max(
_kMinScale,
@@ -659,11 +689,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
void _onPanEnd(DragEndDetails details) {
if (details.velocity.pixelsPerSecond.dy.abs() >= kMinFlingVelocity) {
final bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
final double finalPosition = flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
final double finalPosition =
flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
_sheetController.forward();
} else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
} else if (!flingIsAway &&
_sheetController.status != AnimationStatus.reverse) {
_sheetController.reverse();
}
@@ -713,20 +745,29 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
widget.onDismiss!(context, _lastScale, _sheetOpacityAnimation.value);
}
Alignment _getChildAlignment(Orientation orientation, _ViewableLocation contextMenuLocation) {
Alignment _getChildAlignment(
Orientation orientation, _ViewableLocation contextMenuLocation) {
switch (contextMenuLocation) {
case _ViewableLocation.center:
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topRight;
case _ViewableLocation.right:
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topLeft;
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topLeft;
case _ViewableLocation.left:
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
return orientation == Orientation.portrait
? Alignment.bottomCenter
: Alignment.topRight;
}
}
void _setDragOffset(Offset dragOffset) {
final double endX = _kPadding * dragOffset.dx / _kDamping;
final double endY = dragOffset.dy >= 0.0 ? dragOffset.dy : _kPadding * dragOffset.dy / _kDamping;
final double endY = dragOffset.dy >= 0.0
? dragOffset.dy
: _kPadding * dragOffset.dy / _kDamping;
setState(() {
_dragOffset = dragOffset;
_moveAnimation = Tween<Offset>(
@@ -742,15 +783,20 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
),
);
if (_lastScale <= _kSheetScaleThreshold && _sheetController.status != AnimationStatus.forward && _sheetScaleAnimation.value != 0.0) {
if (_lastScale <= _kSheetScaleThreshold &&
_sheetController.status != AnimationStatus.forward &&
_sheetScaleAnimation.value != 0.0) {
_sheetController.forward();
} else if (_lastScale > _kSheetScaleThreshold && _sheetController.status != AnimationStatus.reverse && _sheetScaleAnimation.value != 1.0) {
} else if (_lastScale > _kSheetScaleThreshold &&
_sheetController.status != AnimationStatus.reverse &&
_sheetScaleAnimation.value != 1.0) {
_sheetController.reverse();
}
});
}
List<Widget> _getChildren(Orientation orientation, _ViewableLocation contextMenuLocation) {
List<Widget> _getChildren(
Orientation orientation, _ViewableLocation contextMenuLocation) {
final Expanded child = Expanded(
child: Align(
alignment: _getChildAlignment(
@@ -781,7 +827,9 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
case _ViewableLocation.center:
return <Widget>[child, spacer, sheet];
case _ViewableLocation.right:
return orientation == Orientation.portrait ? <Widget>[child, spacer, sheet] : <Widget>[sheet, spacer, child];
return orientation == Orientation.portrait
? <Widget>[child, spacer, sheet]
: <Widget>[sheet, spacer, child];
case _ViewableLocation.left:
return <Widget>[child, spacer, sheet];
}
@@ -915,7 +963,8 @@ class _ViewableSheet extends StatelessWidget {
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: CupertinoDynamicColor.resolve(_borderColor, context),
color:
CupertinoDynamicColor.resolve(_borderColor, context),
width: 0.5,
)),
),

View File

@@ -5,11 +5,13 @@ import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
class AdTile extends StatelessWidget {
const AdTile(this.ad, {super.key, this.onTap, this.padding});
const AdTile(this.ad,
{super.key, this.onTap, this.padding, this.showExternalIcon = true});
final Ad ad;
final Function()? onTap;
final EdgeInsetsGeometry? padding;
final bool showExternalIcon;
@override
Widget build(BuildContext context) {
@@ -28,6 +30,7 @@ class AdTile extends StatelessWidget {
Text(
ad.description,
style: TextStyle(
fontSize: 14.5,
fontWeight: FontWeight.w500,
color: AppColors.of(context).text.withOpacity(0.7),
),
@@ -38,6 +41,8 @@ class AdTile extends StatelessWidget {
? ClipRRect(
borderRadius: BorderRadius.circular(50.0),
child: Image.network(
width: 42.0,
height: 42.0,
ad.logoUrl.toString(),
errorBuilder: (context, error, stackTrace) {
ad.logoUrl = null;
@@ -46,7 +51,12 @@ class AdTile extends StatelessWidget {
),
)
: null,
trailing: const Icon(FeatherIcons.externalLink),
trailing: showExternalIcon
? const Icon(
FeatherIcons.externalLink,
size: 20.0,
)
: null,
),
);
}

View File

@@ -12,6 +12,7 @@ class AdViewable extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AdTile(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
ad,
onTap: () => launchUrl(
ad.launchUrl,

View File

@@ -59,7 +59,7 @@ class CertificationTile extends StatelessWidget {
}
return Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(8.0),
child: Padding(
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),

View File

@@ -13,31 +13,43 @@ class CertificationView extends StatelessWidget {
final List<Grade> grades;
final GradeType gradeType;
static show(List<Grade> grades, {required BuildContext context, required GradeType gradeType}) =>
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(builder: (context) => CertificationView(grades, gradeType: gradeType)));
static show(List<Grade> grades,
{required BuildContext context, required GradeType gradeType}) =>
Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute(
builder: (context) =>
CertificationView(grades, gradeType: gradeType)));
@override
Widget build(BuildContext context) {
grades.sort((a, b) => a.subject.name.compareTo(b.subject.name));
List<Widget> tiles = grades.map((e) => CertificationTile(e)).toList();
List<Widget> tiles = grades
.map((e) => CertificationTile(
e,
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 5.0),
))
.toList();
return Scaffold(
body: HeroScrollView(
body: HeroScrollView(
title: getGradeTypeTitle(gradeType),
icon: FeatherIcons.award,
iconSize: 50,
child: ListView(
child: ListView(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 24.0),
physics: const BouncingScrollPhysics(),
children: [
SafeArea(
child: Panel(
padding:
const EdgeInsets.symmetric(vertical: 8.0, horizontal: 4.0),
child: Column(
children: tiles,
),
),
)
],
)));
),
),
);
}
}

View File

@@ -38,7 +38,7 @@ class CustomSegmentedControl extends StatelessWidget {
borderRadius: BorderRadius.circular(12.0),
),
thumbDecoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(10.0),
// boxShadow: [
// BoxShadow(

View File

@@ -13,7 +13,7 @@ class EventTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(14.0),
child: Padding(
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),

View File

@@ -31,8 +31,18 @@ class ExamViewable extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (Provider.of<SettingsProvider>(context).newPopups) {
bool pressed = false;
return GestureDetector(
onTap: () => ExamPopup.show(context: context, exam: exam),
onTap: () {
// prevent double tap things
if (pressed) return;
pressed = true;
ExamPopup.show(context: context, exam: exam);
Future.delayed(const Duration(seconds: 2), () {
pressed = false;
});
},
child: ExamTile(
exam,
showSubject: showSubject,
@@ -198,7 +208,7 @@ class ExamPopup extends StatelessWidget {
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(6.0)),
@@ -256,7 +266,7 @@ class ExamPopup extends StatelessWidget {
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(6.0),
bottom: Radius.circular(12.0)),
@@ -338,7 +348,7 @@ class ExamPopup extends StatelessWidget {
// child: Container(
// width: double.infinity,
// decoration: BoxDecoration(
// color: Theme.of(context).colorScheme.background,
// color: Theme.of(context).colorScheme.surface,
// borderRadius: BorderRadius.circular(12.0),
// ),
// padding: const EdgeInsets.all(16.0),

View File

@@ -34,7 +34,7 @@ class ChangedLessonTile extends StatelessWidget {
}
return Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(14.0),
child: Padding(
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),

View File

@@ -417,7 +417,7 @@ class TimetableLessonPopup extends StatelessWidget {
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(6.0),
@@ -521,7 +521,7 @@ class TimetableLessonPopup extends StatelessWidget {
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(6.0),
bottom: Radius.circular(6.0),
@@ -549,7 +549,7 @@ class TimetableLessonPopup extends StatelessWidget {
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.vertical(
top: const Radius.circular(6.0),
bottom: lesson.exam != ''
@@ -580,7 +580,7 @@ class TimetableLessonPopup extends StatelessWidget {
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(6.0),
bottom: Radius.circular(12.0)),
@@ -654,7 +654,7 @@ class TimetableLessonPopup extends StatelessWidget {
// child: Container(
// width: double.infinity,
// decoration: BoxDecoration(
// color: Theme.of(context).colorScheme.background,
// color: Theme.of(context).colorScheme.surface,
// borderRadius: BorderRadius.circular(12.0),
// ),
// padding: const EdgeInsets.all(16.0),

View File

@@ -23,9 +23,9 @@ class MessageViewable extends StatelessWidget {
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
closedShape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
middleColor: Theme.of(context).colorScheme.background,
middleColor: Theme.of(context).colorScheme.surface,
openColor: Theme.of(context).scaffoldBackgroundColor,
closedColor: Theme.of(context).colorScheme.background,
closedColor: Theme.of(context).colorScheme.surface,
transitionType: ContainerTransitionType.fadeThrough,
transitionDuration: const Duration(milliseconds: 400),
useRootNavigator: true,

View File

@@ -48,7 +48,7 @@ class StatisticsTile extends StatelessWidget {
padding: const EdgeInsets.all(18.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)
.shadowEffect)

View File

@@ -84,9 +84,9 @@ class AverageSelectorState extends State<AverageSelector> {
elevation: 8,
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(40),
thickness: MaterialStateProperty.all<double>(6.0),
trackVisibility: MaterialStateProperty.all<bool>(true),
thumbVisibility: MaterialStateProperty.all<bool>(true),
thickness: WidgetStateProperty.all<double>(6.0),
trackVisibility: WidgetStateProperty.all<bool>(true),
thumbVisibility: WidgetStateProperty.all<bool>(true),
),
offset: const Offset(-10, -10),
),

View File

@@ -7,6 +7,7 @@ import 'dart:math';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:collection/collection.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:refilc/api/providers/update_provider.dart';
import 'package:refilc/models/settings.dart';
@@ -83,6 +84,7 @@ class GradesPageState extends State<GradesPage> {
late GradeCalculatorProvider calculatorProvider;
late HomeworkProvider homeworkProvider;
late ExamProvider examProvider;
late SettingsProvider settingsProvider;
late String firstName;
late Widget yearlyGraph;
@@ -162,7 +164,14 @@ class GradesPageState extends State<GradesPage> {
bool hasHomework = homeworkCount > 0;
List<Exam> allExams = examProvider.exams;
allExams.sort((a, b) => a.date.compareTo(b.date));
try {
allExams.sort((a, b) => a.date.compareTo(b.date));
} catch (e) {
if (kDebugMode) {
print('failed to sort exams, reason: flutter');
}
allExams = [];
}
Exam? nearestExam = allExams.firstWhereOrNull((e) =>
e.subject.id == subject.id && e.writeDate.isAfter(DateTime.now()));
@@ -196,7 +205,7 @@ class GradesPageState extends State<GradesPage> {
? const Radius.circular(8.0)
: const Radius.circular(16.0),
),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
),
child: Padding(
padding: const EdgeInsets.symmetric(
@@ -247,7 +256,7 @@ class GradesPageState extends State<GradesPage> {
? const Radius.circular(8.0)
: const Radius.circular(16.0),
),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
),
child: Padding(
padding: const EdgeInsets.only(
@@ -298,7 +307,7 @@ class GradesPageState extends State<GradesPage> {
bottomLeft: Radius.circular(16.0),
bottomRight: Radius.circular(16.0),
),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
),
child: ExamViewable(
nearestExam,
@@ -368,8 +377,14 @@ class GradesPageState extends State<GradesPage> {
);
}
// print('rounding:');
// print(settingsProvider.rounding);
double subjectAvg = subjectAvgs.isNotEmpty
? subjectAvgs.values.fold(0.0, (double a, double b) => a + b) /
? subjectAvgs.values.fold(
0.0,
(double a, double b) =>
a.round().toDouble() + b.round().toDouble()) /
subjectAvgs.length
: 0.0;
final double classAvg = gradeProvider.groupAverages.isNotEmpty
@@ -440,6 +455,7 @@ class GradesPageState extends State<GradesPage> {
calculatorProvider = Provider.of<GradeCalculatorProvider>(context);
homeworkProvider = Provider.of<HomeworkProvider>(context);
examProvider = Provider.of<ExamProvider>(context);
settingsProvider = Provider.of<SettingsProvider>(context);
context.watch<PlusProvider>();
@@ -673,7 +689,7 @@ class GradesPageState extends State<GradesPage> {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: ListTile(
title: Row(
children: [
@@ -685,12 +701,12 @@ class GradesPageState extends State<GradesPage> {
],
),
onTap: () {
if (!Provider.of<PlusProvider>(context, listen: false)
.hasScope(PremiumScopes.totalGradeCalculator)) {
PlusLockedFeaturePopup.show(
context: context, feature: PremiumFeature.gradeCalculation);
return;
}
// if (!Provider.of<PlusProvider>(context, listen: false)
// .hasScope(PremiumScopes.totalGradeCalculator)) {
// PlusLockedFeaturePopup.show(
// context: context, feature: PremiumFeature.gradeCalculation);
// return;
// }
// SoonAlert.show(context: context);
gradeCalcTotal(context);
@@ -705,7 +721,7 @@ class GradesPageState extends State<GradesPage> {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: ListTile(
title: Row(
children: [
@@ -763,7 +779,7 @@ class GradesPageState extends State<GradesPage> {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: SwitchListTile(
title: Row(
children: [

View File

@@ -179,7 +179,7 @@ class GradeGraphState extends State<GradeGraph> {
? Alignment.topRight
: Alignment.topLeft,
style: TextStyle(
backgroundColor: Theme.of(context).colorScheme.background,
backgroundColor: Theme.of(context).colorScheme.surface,
color: AppColors.of(context).text,
fontSize: 16.0,
fontWeight: FontWeight.w600,
@@ -217,7 +217,7 @@ class GradeGraphState extends State<GradeGraph> {
height: 158,
child: subjectSpots.length > 1
? Padding(
padding: const EdgeInsets.only(top: 8.0, right: 8.0),
padding: const EdgeInsets.only(top: 6.0, right: 0.0),
child: LineChart(
LineChartData(
extraLinesData: ExtraLinesData(
@@ -228,22 +228,32 @@ class GradeGraphState extends State<GradeGraph> {
preventCurveOverShooting: false,
spots: subjectSpots,
isCurved: true,
colors: averageColors.reversed.toList(),
// colors: averageColors.reversed.toList(),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: averageColors.reversed.toList(),
),
barWidth: 6,
curveSmoothness: 0.2,
isStrokeCapRound: true,
dotData: FlDotData(show: false),
dotData: const FlDotData(show: false),
belowBarData: BarAreaData(
show: true,
colors: [
averageColor.withOpacity(0.7),
averageColor.withOpacity(0.3),
averageColor.withOpacity(0.2),
averageColor.withOpacity(0.1),
],
gradientColorStops: [0.1, 0.6, 0.8, 1],
gradientFrom: const Offset(0, 0),
gradientTo: const Offset(0, 1),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
averageColor.withOpacity(0.7),
averageColor.withOpacity(0.3),
averageColor.withOpacity(0.2),
averageColor.withOpacity(0.1),
],
stops: const [0.1, 0.6, 0.8, 1],
),
// gradientColorStops: [0.1, 0.6, 0.8, 1],
// gradientFrom: const Offset(0, 0),
// gradientTo: const Offset(0, 1),
),
),
if (ghostData.isNotEmpty && ghostSpots.isNotEmpty)
@@ -251,28 +261,41 @@ class GradeGraphState extends State<GradeGraph> {
preventCurveOverShooting: false,
spots: ghostSpots,
isCurved: true,
colors: [AppColors.of(context).text],
color: AppColors.of(context).text,
barWidth: 6,
curveSmoothness: 0.2,
isStrokeCapRound: true,
dotData: FlDotData(show: false),
dotData: const FlDotData(show: false),
belowBarData: BarAreaData(
show: true,
colors: [
AppColors.of(context).text.withOpacity(0.7),
AppColors.of(context).text.withOpacity(0.3),
AppColors.of(context).text.withOpacity(0.2),
AppColors.of(context).text.withOpacity(0.1),
],
gradientColorStops: [0.1, 0.6, 0.8, 1],
gradientFrom: const Offset(0, 0),
gradientTo: const Offset(0, 1),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.of(context)
.text
.withOpacity(0.7),
AppColors.of(context)
.text
.withOpacity(0.3),
AppColors.of(context)
.text
.withOpacity(0.2),
AppColors.of(context)
.text
.withOpacity(0.1),
],
stops: const [0.1, 0.6, 0.8, 1],
),
// gradientColorStops: [0.1, 0.6, 0.8, 1],
// gradientFrom: const Offset(0, 0),
// gradientTo: const Offset(0, 1),
),
),
],
minY: 1,
maxY: 5,
gridData: FlGridData(
gridData: const FlGridData(
show: true,
horizontalInterval: 1,
// checkToShowVerticalLine: (_) => false,
@@ -286,8 +309,8 @@ class GradeGraphState extends State<GradeGraph> {
// ),
),
lineTouchData: LineTouchData(
touchTooltipData: LineTouchTooltipData(
tooltipBgColor: Colors.grey.shade800,
touchTooltipData: const LineTouchTooltipData(
// tooltipBgColor: Colors.grey.shade800,
fitInsideVertically: true,
fitInsideHorizontally: true,
),
@@ -321,64 +344,111 @@ class GradeGraphState extends State<GradeGraph> {
),
),
titlesData: FlTitlesData(
bottomTitles: SideTitles(
showTitles: true,
reservedSize: 24,
getTextStyles: (context, value) => TextStyle(
color:
AppColors.of(context).text.withOpacity(.75),
fontWeight: FontWeight.bold,
fontSize: 14.0,
),
margin: 12.0,
getTitles: (value) {
var format = DateFormat(
"MMM", I18n.of(context).locale.toString());
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 25,
getTitlesWidget: (value, meta) {
if (value == meta.max || value == meta.min) {
return Container();
}
String title = format
.format(DateTime(0, value.floor() % 12))
.replaceAll(".", "");
title =
title.substring(0, min(title.length, 4));
var format = DateFormat("MMM",
I18n.of(context).locale.toString());
return title.toUpperCase();
},
interval: () {
List<Grade> tData =
ghostData.isNotEmpty ? ghostData : data;
tData.sort((a, b) =>
a.writeDate.compareTo(b.writeDate));
return ghostData.isNotEmpty
? 3.0
: tData.first.writeDate
.add(const Duration(days: 120))
.isBefore(tData.last.writeDate)
? 2.0
: 2.5;
}(),
checkToShowTitle: (double minValue,
double maxValue,
SideTitles sideTitles,
double appliedInterval,
double value) {
if (value == maxValue || value == minValue) {
return false;
}
return true;
},
),
leftTitles: SideTitles(
showTitles: true,
interval: 1.0,
getTextStyles: (context, value) => TextStyle(
color: AppColors.of(context).text,
fontWeight: FontWeight.bold,
fontSize: 18.0,
String title = format
.format(DateTime(0, value.floor() % 12))
.replaceAll(".", "");
title =
title.substring(0, min(title.length, 4));
return Text(
title.toUpperCase(),
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(.75),
fontWeight: FontWeight.bold,
fontSize: 14.0,
),
);
},
// getTextStyles: (context, value) => TextStyle(
// color: AppColors.of(context)
// .text
// .withOpacity(.75),
// fontWeight: FontWeight.bold,
// fontSize: 14.0,
// ),
// margin: 12.0,
// getTitles: (value) {
// var format = DateFormat("MMM",
// I18n.of(context).locale.toString());
// String title = format
// .format(DateTime(0, value.floor() % 12))
// .replaceAll(".", "");
// title =
// title.substring(0, min(title.length, 4));
// return title.toUpperCase();
// },
interval: () {
List<Grade> tData =
ghostData.isNotEmpty ? ghostData : data;
tData.sort((a, b) =>
a.writeDate.compareTo(b.writeDate));
return ghostData.isNotEmpty
? 3.0
: tData.first.writeDate
.add(const Duration(days: 120))
.isBefore(tData.last.writeDate)
? 2.0
: 2.5;
}(),
// checkToShowTitle: (double minValue,
// double maxValue,
// SideTitles sideTitles,
// double appliedInterval,
// double value) {
// if (value == maxValue || value == minValue) {
// return false;
// }
// return true;
// },
),
margin: 16,
),
rightTitles: SideTitles(showTitles: false),
topTitles: SideTitles(showTitles: false),
leftTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
interval: 1.0,
reservedSize: 26.0,
getTitlesWidget: (value, meta) => Padding(
padding: const EdgeInsets.only(
left: 6.0, right: 10.0),
child: Text(
value.toInt().toString(),
style: TextStyle(
color: AppColors.of(context).text,
fontWeight: FontWeight.bold,
fontSize: 16.0,
),
),
),
// getTextStyles: (context, value) => TextStyle(
// color: AppColors.of(context).text,
// fontWeight: FontWeight.bold,
// fontSize: 18.0,
// ),
// margin: 16,
),
),
rightTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
),
),
),

View File

@@ -1,6 +1,7 @@
// ignore_for_file: unnecessary_null_comparison
import 'package:animations/animations.dart';
import 'package:flutter/services.dart';
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/helpers/subject.dart';
import 'package:refilc/models/settings.dart';
@@ -43,6 +44,10 @@ class LiveCardStateA extends State<LiveCard> {
_userProvider = Provider.of<UserProvider>(context, listen: false);
liveCard = Provider.of<LiveCardProvider>(context, listen: false);
_userProvider.addListener(liveCard.update);
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
}
@override
@@ -419,14 +424,38 @@ class LiveCardStateA extends State<LiveCard> {
if (progressCurrent != null &&
progressMax != null)
GestureDetector(
onTap: () {
showDialog(
onTap: () async {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]);
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness:
Brightness.dark,
systemNavigationBarColor:
Colors.transparent,
systemNavigationBarIconBrightness:
Brightness.dark,
));
var result = await showDialog(
barrierColor: Colors.black,
context: context,
builder: (context) => HeadsUpCountdown(
maxTime: maxTime,
elapsedTime: elapsedTime),
);
if (result != null) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
}
},
child: Container(
color: Colors.transparent,
@@ -825,14 +854,38 @@ class LiveCardStateA extends State<LiveCard> {
if (progressCurrent != null &&
progressMax != null)
GestureDetector(
onTap: () {
showDialog(
onTap: () async {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]);
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness:
Brightness.dark,
systemNavigationBarColor:
Colors.transparent,
systemNavigationBarIconBrightness:
Brightness.dark,
));
var result = await showDialog(
barrierColor: Colors.black,
context: context,
builder: (context) => HeadsUpCountdown(
maxTime: maxTime,
elapsedTime: elapsedTime),
);
if (result != null) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
}
},
child: Container(
color: Colors.transparent,

View File

@@ -72,10 +72,10 @@ class _LiveCardWidgetState extends State<LiveCardWidget> {
? const EdgeInsets.all(12.0)
: EdgeInsets.zero,
decoration: BoxDecoration(
// color: Theme.of(context).colorScheme.background,
// color: Theme.of(context).colorScheme.surface,
color: widget.children != null
? Colors.transparent
: Theme.of(context).colorScheme.background,
: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16.0),
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)

View File

@@ -125,7 +125,7 @@ class MessagesPageState extends State<MessagesPage>
BackButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
padding: WidgetStateProperty.all<EdgeInsetsGeometry>(
EdgeInsets.zero),
),
),

View File

@@ -105,9 +105,9 @@ class SendMessageSheetState extends State<SendMessageSheet> {
elevation: 8,
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(40),
thickness: MaterialStateProperty.all<double>(6.0),
trackVisibility: MaterialStateProperty.all<bool>(true),
thumbVisibility: MaterialStateProperty.all<bool>(true),
thickness: WidgetStateProperty.all<double>(6.0),
trackVisibility: WidgetStateProperty.all<bool>(true),
thumbVisibility: WidgetStateProperty.all<bool>(true),
),
offset: const Offset(-10, -10),
),

View File

@@ -88,6 +88,7 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
// todo tiles
List<Widget> toDoTiles = [];
// TODO: FIX THIS ASAP
if (hw.isNotEmpty &&
Provider.of<PlusProvider>(context, listen: false)
.hasScope(PremiumScopes.unlimitedSelfNotes)) {
@@ -98,13 +99,23 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
'${(e.subject.isRenamed ? e.subject.renamedTo : e.subject.name) ?? ''}, ${e.content.escapeHtml()}',
isTicked: doneItems[e.id] ?? false,
onTap: (p0) async {
// print(p0);
// print(doneItems);
if (!doneItems.containsKey(e.id)) {
doneItems.addAll({e.id: p0});
} else {
doneItems[e.id] = p0;
}
// print(doneItems);
// print(doneItems[e.id]);
// print(user.id);
await databaseProvider.userStore
.storeToDoItem(doneItems, userId: user.id!);
setState(() {});
// print(
// await databaseProvider.userQuery.toDoItems(userId: user.id!));
},
)));
}
@@ -116,10 +127,20 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
description: e.content,
isTicked: e.done,
onTap: (p0) async {
todoItems.firstWhere((element) => element.id == e.id).done = p0;
final todoItemIndex =
todoItems.indexWhere((element) => element.id == e.id);
if (todoItemIndex != -1) {
TodoItem todoItem = todoItems[todoItemIndex];
Map<String, dynamic> todoItemJson = todoItem.toJson;
todoItemJson['done'] = p0;
todoItem = TodoItem.fromJson(todoItemJson);
todoItems[todoItemIndex] = todoItem;
await databaseProvider.userStore
.storeSelfTodoItems(todoItems, userId: user.id!);
}
await databaseProvider.userStore
.storeSelfTodoItems(todoItems, userId: user.id!);
// await databaseProvider.userStore
// .storeSelfTodoItems(todoItems, userId: user.id!);
},
)));
}
@@ -410,7 +431,7 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: ListTile(
title: Row(
children: [
@@ -432,7 +453,7 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: ListTile(
title: Row(
children: [
@@ -456,7 +477,7 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: ListTile(
title: Row(
children: [
@@ -468,13 +489,13 @@ class NotesPageState extends State<NotesPage> with TickerProviderStateMixin {
],
),
onTap: () {
if (!Provider.of<PlusProvider>(context, listen: false)
.hasScope(PremiumScopes.unlimitedSelfNotes)) {
PlusLockedFeaturePopup.show(
context: context, feature: PremiumFeature.selfNotes);
// if (!Provider.of<PlusProvider>(context, listen: false)
// .hasScope(PremiumScopes.unlimitedSelfNotes)) {
// PlusLockedFeaturePopup.show(
// context: context, feature: PremiumFeature.selfNotes);
return;
}
// return;
// }
showTaskCreation(context);
},

View File

@@ -22,7 +22,7 @@ class SelfNoteTile extends StatelessWidget {
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
boxShadow: [
if (Provider.of<SettingsProvider>(context, listen: false)
.shadowEffect)

View File

@@ -75,7 +75,7 @@ class _FSTimetableState extends State<FSTimetable> {
body: ListView.builder(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 24.0),
itemCount: maxLessonCount + 1,
itemCount: maxLessonCount + 2,
itemBuilder: (context, index) {
List<Widget> columns = [];
for (int dayIndex = -1; dayIndex < days.length; dayIndex++) {
@@ -119,10 +119,8 @@ class _FSTimetableState extends State<FSTimetable> {
if (lessons.isEmpty) continue;
int lsnIndx = int.tryParse(lessons.first.lessonIndex) ?? 1;
final dayOffset = lsnIndx == 0 ? 1 : lsnIndx;
if (index == 0 && dayIndex >= 0) {
// if (index == 0 || dayIndex >=0) {
columns.add(
SizedBox(
width: colw,
@@ -141,16 +139,10 @@ class _FSTimetableState extends State<FSTimetable> {
continue;
}
final lessonIndex = index - dayOffset;
Lesson? lsn = lessons.firstWhereOrNull(
(e) => e.lessonIndex == (index - 1).toString());
if (lessonIndex < 0 ||
lessonIndex > lessons.length ||
(index == 1 && lsnIndx != 0) ||
(lsnIndx != 0 && lessonIndex - 1 == -1) ||
lsn == null) {
if (lsn == null) {
columns.add(SizedBox(width: colw));
continue;
}
@@ -259,4 +251,4 @@ class _FSTimetableState extends State<FSTimetable> {
),
);
}
}
}

View File

@@ -700,7 +700,7 @@ class TimetablePageState extends State<TimetablePage>
],
color: Theme.of(context)
.colorScheme
.background,
.surface,
borderRadius:
BorderRadius.only(
topLeft: index == 0
@@ -786,7 +786,7 @@ class TimetablePageState extends State<TimetablePage>
indicatorPadding:
const EdgeInsets.symmetric(horizontal: 10.0),
indicator: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
// color: Colors.transparent,
// border: Border.all(
// color: AppColors.of(context)
@@ -798,7 +798,7 @@ class TimetablePageState extends State<TimetablePage>
// .withOpacity(0.25),
borderRadius: BorderRadius.circular(16.0),
),
overlayColor: MaterialStateProperty.all(
overlayColor: WidgetStateProperty.all(
const Color(0x00000000)),
// Tabs
padding: const EdgeInsets.symmetric(
@@ -899,7 +899,7 @@ class TimetablePageState extends State<TimetablePage>
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: ListTile(
contentPadding: const EdgeInsets.only(left: 16.0, right: 10.0),
title: Row(
@@ -943,7 +943,7 @@ class TimetablePageState extends State<TimetablePage>
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: SwitchListTile(
contentPadding: const EdgeInsets.only(left: 16.0, right: 10.0),
title: Row(
@@ -990,7 +990,7 @@ class TimetablePageState extends State<TimetablePage>
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).colorScheme.background),
color: Theme.of(context).colorScheme.surface),
child: SwitchListTile(
contentPadding: const EdgeInsets.only(left: 16.0, right: 10.0),
title: Row(

View File

@@ -51,7 +51,7 @@ class ActiveSponsorCard extends StatelessWidget {
return const SizedBox();
}
Color? glow = Colors.white; //TODO: only temp fix kima (idk what but die)
Color? glow = Colors.white;
switch (level) {
case PremiumFeatureLevel.cap:

View File

@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc_mobile_ui/common/action_button.dart';
import 'package:refilc_plus/providers/plus_provider.dart';
import 'package:refilc_plus/ui/mobile/plus/activation_view/activation_view.dart';
import 'package:refilc_mobile_ui/plus/plus_screen.i18n.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:uuid/uuid.dart';
class PlusPlanCard extends StatelessWidget {
const PlusPlanCard({
@@ -38,33 +40,39 @@ class PlusPlanCard extends StatelessWidget {
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (!docsAccepted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
"El kell fogadnod az ÁSZF-et és az Adatkezelési Tájékoztatót!",
style:
TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
),
backgroundColor: Colors.white,
));
// if (!docsAccepted) {
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
// content: Text(
// "El kell fogadnod az ÁSZF-et és az Adatkezelési Tájékoztatót!",
// style:
// TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
// ),
// backgroundColor: Colors.white,
// ));
return;
}
// return;
// }
if (Provider.of<SettingsProvider>(context, listen: false).xFilcId ==
"none") {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
"Be kell kapcsolnod a Névtelen Analitikát a beállítások főoldalán, mielőtt reFilc+ előfizetést vásárolnál!",
style:
TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
),
backgroundColor: Colors.white,
));
return;
Provider.of<SettingsProvider>(context, listen: false)
.update(xFilcId: const Uuid().v4(), store: true);
}
// if (Provider.of<SettingsProvider>(context, listen: false).xFilcId ==
// "none") {
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
// content: Text(
// "Be kell kapcsolnod a Névtelen Analitikát a beállítások főoldalán, mielőtt reFilc+ előfizetést vásárolnál!",
// style:
// TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
// ),
// backgroundColor: Colors.white,
// ));
// return;
// }
if (Provider.of<PlusProvider>(context, listen: false).hasPremium) {
if (!active) {
launchUrl(
@@ -77,9 +85,66 @@ class PlusPlanCard extends StatelessWidget {
return;
}
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return PremiumActivationView(product: id);
}));
showDialog(
context: context,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0)),
title: Text('docs'.i18n),
content: Text('docs_acceptance'.i18n),
actions: [
ActionButton(
label: "next".i18n,
onTap: () {
// pop dialog
Navigator.of(context).pop();
// show payment option selector
showDialog(
context: context,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0)),
title: Text('payment_method'.i18n),
content: Text('select_payment_method'.i18n),
actions: [
ActionButton(
label: "stripe".i18n,
onTap: () {
// pop dialog
Navigator.of(context).pop();
// start payment process
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) {
return PremiumActivationView(
product: id,
paymentProvider: "stripe",
);
}));
},
),
ActionButton(
label: "paypal".i18n,
onTap: () {
// pop dialog
Navigator.of(context).pop();
// start payment process
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) {
return PremiumActivationView(
product: id,
paymentProvider: "paypal",
);
}));
},
),
],
),
);
},
),
],
),
);
},
child: Container(
decoration: BoxDecoration(

View File

@@ -1,5 +1,6 @@
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/services.dart';
import 'package:refilc_mobile_ui/plus/plus_screen.i18n.dart';
import 'package:refilc_mobile_ui/plus/components/plan_card.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
@@ -222,10 +223,11 @@ class PlusScreenState extends State<PlusScreen> {
// ['👥', 'rfp_2'.i18n],
['👋', 'rfp_3'.i18n],
['📓', 'rfp_4'.i18n],
['🎓', 'rfp_6'.i18n],
// ['🎓', 'rfp_6'.i18n],
['📩', 'rfp_17'.i18n],
['🪟', 'rfp_18'.i18n],
['👕', 'rfp_14'.i18n],
['👑', 'rfp_15'.i18n],
['📩', 'rfp_17'.i18n],
['🔜', 'more_soon'.i18n],
],
docsAccepted: docsAccepted,
@@ -334,6 +336,46 @@ class PlusScreenState extends State<PlusScreen> {
contentPadding:
const EdgeInsets.only(left: 15.0, right: 10.0),
onTap: () async {
// try clipboard re-activation
final data = await Clipboard.getData("text/plain");
if (data != null &&
data.text != null &&
data.text != "") {
// activate using clipboard data
final result = await context
.read<PlusProvider>()
.auth
.finishAuth(data.text!);
if (!result && mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text(
"Sikertelen aktiválás. Kérlek próbáld újra később!",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
backgroundColor: Colors.red,
));
} else {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text(
"Sikeres aktiválás!",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
backgroundColor: Colors.green,
));
Future.delayed(const Duration(seconds: 2),
() => Navigator.of(context).pop());
}
}
// try re-activation using refresh
final result = await context
.read<PlusProvider>()
.auth
@@ -378,39 +420,41 @@ class PlusScreenState extends State<PlusScreen> {
),
),
// aszf warning
const SizedBox(
height: 18.0,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0),
border: Border.all(
color: Colors.black.withOpacity(0.2),
),
),
child: CheckboxListTile(
contentPadding:
const EdgeInsets.only(left: 15.0, right: 10.0),
value: docsAccepted,
onChanged: (value) {
setState(() {
docsAccepted = !docsAccepted;
});
},
// title: Text(
// 'show_lifetime'.i18n,
// style: const TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.w500,
// ),
// ),
subtitle: const Text(
'Elfogadod a reFilc előfizetésekkel kapcsolatos Általános Szerződési Feltételeit (elérhető az alábbi link-en: filc.one/pay-terms), valamint Adatkezelési Tájékoztatónkat (elérhető az alábbi link-en: filc.one/pay-privacy)?',
textAlign: TextAlign.start,
style: TextStyle(color: Colors.black),
),
),
),
// const SizedBox(
// height: 18.0,
// ),
// Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16.0),
// border: Border.all(
// color: Colors.black.withOpacity(0.2),
// ),
// ),
// child: CheckboxListTile(
// side:
// const BorderSide(color: Colors.black, width: 2.0),
// contentPadding:
// const EdgeInsets.only(left: 15.0, right: 10.0),
// value: docsAccepted,
// onChanged: (value) {
// setState(() {
// docsAccepted = !docsAccepted;
// });
// },
// // title: Text(
// // 'show_lifetime'.i18n,
// // style: const TextStyle(
// // color: Colors.black,
// // fontWeight: FontWeight.w500,
// // ),
// // ),
// subtitle: const Text(
// 'Elfogadod a reFilc előfizetésekkel kapcsolatos Általános Szerződési Feltételeit (elérhető az alábbi link-en: filc.one/pay-terms), valamint Adatkezelési Tájékoztatónkat (elérhető az alábbi link-en: filc.one/pay-privacy)?',
// textAlign: TextAlign.start,
// style: TextStyle(color: Colors.black),
// ),
// ),
// ),
// CheckboxListTile(value: false, onChanged: onChanged)
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 12.0),

View File

@@ -46,13 +46,25 @@ extension SettingsLocalization on String {
"rfp_15": "Subscriber role in our Discord community",
"rfp_16": "Private leaks and informations about upcoming features",
"rfp_17": "Grade exporting",
"rfp_18": "Viewing exported grades",
// docs and payment method popup
"docs": "Documents",
"docs_acceptance":
"By pressing the \"Next\" button, you accept reFilc's Terms and Conditions for subscriptions (available at the following link: filc.one/pay-terms) and our Privacy Policy (available at the following link: filc.one/pay-privacy).",
"next": "Next",
"payment_method": "Payment Method",
"select_payment_method":
"Please select a preferred payment method! Credit card payments are handled by Stripe, which also supports Apple Pay, Google Pay and Revolut Pay.",
"stripe": "Credit Card",
"paypal": "PayPal",
// other
"and": " and ",
"every": "Every ",
"benefit": " benefit",
"show_lifetime": "Show Lifetime Plans",
"more_soon": "More coming soon...",
"faq_dc": "To redeem your benefits, contact us on Discord in DMs!",
"faq_dc":
"To redeem your Discord-related benefits, contact us on Discord in DMs!",
"reactivate": "Reactivate Existing Subscription",
},
"hu_hu": {
@@ -98,6 +110,17 @@ extension SettingsLocalization on String {
"rfp_15": "Előfizetői rang a Discord szerverünkön",
"rfp_16": "Privát betekintések és információk közelgő újításokról",
"rfp_17": "Jegy exportálás",
"rfp_18": "Exportált jegyek megtekintése",
// docs and payment method popup
"docs": "Dokumentumok",
"docs_acceptance":
"A \"Tovább\" gombra kattintva elfogadod a reFilc előfizetésekkel kapcsolatos Általános Szerződési Feltételeit (elérhető az alábbi link-en: filc.one/pay-terms), valamint Adatkezelési Tájékoztatónkat (elérhető az alábbi link-en: filc.one/pay-privacy).",
"next": "Tovább",
"payment_method": "Fizetési mód",
"select_payment_method":
"Kérlek válassz egy fizetési módot! A bankkártyás fizetést a Stripe biztosítja, mely támogat Apple Pay-t, Google Pay-t és Revolut Pay-t is.",
"stripe": "Bankkártya",
"paypal": "PayPal",
// other
"and": " és ",
"every": "Minden ",
@@ -105,7 +128,7 @@ extension SettingsLocalization on String {
"show_lifetime": "Örökre szóló csomagok",
"more_soon": "Hamarosan mégtöbb finomság...",
"faq_dc":
"Az előnyök beváltásához írj nekünk Discord-on privát üzenetet!",
"A Discord-al kapcsolatos előnyök beváltásához írj nekünk Discord-on privát üzenetet!",
"reactivate": "Meglévő előfizetés újraaktiválása",
},
"de_de": {
@@ -153,6 +176,17 @@ extension SettingsLocalization on String {
"rfp_15": "Abonnentenrolle in unserer Discord-Community",
"rfp_16": "Private Leaks und Informationen über kommende Funktionen",
"rfp_17": "Notenexport",
"rfp_18": "Anzeigen exportierter Noten",
// docs and payment method popup
"docs": "Dokumente",
"docs_acceptance":
"Durch Drücken der Schaltfläche \"Weiter\" akzeptieren Sie die Allgemeinen Geschäftsbedingungen von reFilc für Abonnements (verfügbar unter folgendem Link: filc.one/pay-terms) und unsere Datenschutzrichtlinie (verfügbar unter folgendem Link: filc.one/pay-privacy).",
"next": "Weiter",
"payment_method": "Zahlungsmethode",
"select_payment_method":
"Bitte wählen Sie eine bevorzugte Zahlungsmethode aus! Kreditkartenzahlungen werden von Stripe abgewickelt, der auch Apple Pay, Google Pay und Revolut Pay unterstützt.",
"stripe": "Kreditkarte",
"paypal": "PayPal",
// other
"and": " und ",
"every": "Jeder ",

View File

@@ -110,10 +110,10 @@ class ErrorReportScreen extends StatelessWidget {
height: 48,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(vertical: 10.0)),
backgroundColor: MaterialStateProperty.all(Colors.black),
shape: MaterialStateProperty.all(
backgroundColor: WidgetStateProperty.all(Colors.black),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0)),
),
@@ -135,18 +135,18 @@ class ErrorReportScreen extends StatelessWidget {
height: 48,
child: OutlinedButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
padding: WidgetStateProperty.all(
const EdgeInsets.symmetric(vertical: 14.0),
),
backgroundColor: MaterialStateProperty.all(
backgroundColor: WidgetStateProperty.all(
const Color(0xFFF3F7FE),
),
shape: MaterialStateProperty.all(
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
),
side: MaterialStateProperty.all(
side: WidgetStateProperty.all(
const BorderSide(width: 1.0, color: Color(0xFFC7D3EB)),
),
),

View File

@@ -39,7 +39,7 @@ class ErrorScreen extends StatelessWidget {
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14.0),
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
),
child: CupertinoScrollbar(
child: SingleChildScrollView(

View File

@@ -1,141 +1,104 @@
import 'package:flutter/foundation.dart';
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:refilc_kreta_api/client/api.dart';
import 'package:refilc_kreta_api/client/client.dart';
import 'package:webview_flutter/webview_flutter.dart';
class KretenLoginScreen extends StatefulWidget {
const KretenLoginScreen({super.key});
class KretenLoginWidget extends StatefulWidget {
const KretenLoginWidget({super.key, required this.onLogin});
// final String selectedSchool;
final void Function(String code) onLogin;
@override
State<KretenLoginScreen> createState() => _KretenLoginScreenState();
State<KretenLoginWidget> createState() => _KretenLoginWidgetState();
}
class _KretenLoginScreenState extends State<KretenLoginScreen> {
class _KretenLoginWidgetState extends State<KretenLoginWidget>
with TickerProviderStateMixin {
late final WebViewController controller;
late AnimationController _animationController;
var loadingPercentage = 0;
var currentUrl = '';
bool _hasFadedIn = false;
@override
void initState() {
super.initState();
_animationController = AnimationController(
vsync: this, // Use the TickerProviderStateMixin
duration: const Duration(milliseconds: 350),
);
controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(NavigationDelegate(
onPageStarted: (url) async {
setState(() {
loadingPercentage = 0;
currentUrl = url;
});
onNavigationRequest: (n) async {
if (n.url.startsWith('https://mobil.e-kreta.hu')) {
setState(() {
loadingPercentage = 0;
currentUrl = n.url;
});
List<String> requiredThings = url
.replaceAll(
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
'')
.replaceAll(
'&scope=openid email offline_access kreta-ellenorzo-webapi.public kreta-eugyintezes-webapi.public kreta-fileservice-webapi.public kreta-mobile-global-webapi.public kreta-dkt-webapi.public kreta-ier-webapi.public&state=refilc_student_mobile&session_state=',
':')
.split(':');
String code = requiredThings[0];
// String sessionState = requiredThings[1];
debugPrint('url: $url');
// actual login (token grant) logic
Map<String, String> headers = {
"content-type": "application/x-www-form-urlencoded",
"accept": "*/*",
"user-agent":
"eKretaStudent/264745 CFNetwork/1494.0.7 Darwin/23.4.0",
"code_verifier": "THDUSddKOOndwCkqBtVHvRjh2LK0V2kMyLP2QirqVWQ",
};
Map? res = await Provider.of<KretaClient>(context, listen: false)
.postAPI(KretaAPI.login, headers: headers, body: {
"code": code,
"redirect_uri":
"https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect",
"client_id": "kreta-ellenorzo-student-mobile-ios",
"grant_type": "authorization_code",
});
if (res != null) {
if (kDebugMode) {
print(res);
}
// if (res.containsKey("error")) {
// if (res["error"] == "invalid_grant") {
// print("ERROR: invalid_grant");
// return;
// }
// } else {
// if (res.containsKey("access_token")) {
// try {
// Provider.of<KretaClient>(context, listen: false).accessToken =
// res["access_token"];
// Map? studentJson =
// await Provider.of<KretaClient>(context, listen: false)
// .getAPI(KretaAPI.student(instituteCode));
// Student student = Student.fromJson(studentJson!);
// var user = User(
// username: username,
// password: password,
// instituteCode: instituteCode,
// name: student.name,
// student: student,
// role: JwtUtils.getRoleFromJWT(res["access_token"])!,
// );
// if (onLogin != null) onLogin(user);
// // Store User in the database
// await Provider.of<DatabaseProvider>(context, listen: false)
// .store
// .storeUser(user);
// Provider.of<UserProvider>(context, listen: false)
// .addUser(user);
// Provider.of<UserProvider>(context, listen: false)
// .setUser(user.id);
// // Get user data
// try {
// await Future.wait([
// Provider.of<GradeProvider>(context, listen: false)
// .fetch(),
// Provider.of<TimetableProvider>(context, listen: false)
// .fetch(week: Week.current()),
// Provider.of<ExamProvider>(context, listen: false).fetch(),
// Provider.of<HomeworkProvider>(context, listen: false)
// .fetch(),
// Provider.of<MessageProvider>(context, listen: false)
// .fetchAll(),
// Provider.of<MessageProvider>(context, listen: false)
// .fetchAllRecipients(),
// Provider.of<NoteProvider>(context, listen: false).fetch(),
// Provider.of<EventProvider>(context, listen: false)
// .fetch(),
// Provider.of<AbsenceProvider>(context, listen: false)
// .fetch(),
// ]);
// } catch (error) {
// print("WARNING: failed to fetch user data: $error");
// }
// if (onSuccess != null) onSuccess();
// return LoginState.success;
// } catch (error) {
// print("ERROR: loginAPI: $error");
// // maybe check debug mode
// // ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("ERROR: $error")));
// return LoginState.failed;
// }
// }
// final String instituteCode = widget.selectedSchool;
// if (!n.url.startsWith(
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
// return;
// }
List<String> requiredThings = n.url
.replaceAll(
'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
'')
.replaceAll(
'&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&state=refilc_student_mobile&session_state=',
':')
.split(':');
String code = requiredThings[0];
// String sessionState = requiredThings[1];
widget.onLogin(code);
// Future.delayed(const Duration(milliseconds: 500), () {
// Navigator.of(context).pop();
// });
// Navigator.of(context).pop();
return NavigationDecision.prevent;
} else {
return NavigationDecision.navigate;
}
},
onPageStarted: (url) async {
// setState(() {
// loadingPercentage = 0;
// currentUrl = url;
// });
// // final String instituteCode = widget.selectedSchool;
// if (!url.startsWith(
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
// return;
// }
// List<String> requiredThings = url
// .replaceAll(
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
// '')
// .replaceAll(
// '&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&state=refilc_student_mobile&session_state=',
// ':')
// .split(':');
// String code = requiredThings[0];
// // String sessionState = requiredThings[1];
// widget.onLogin(code);
// // Future.delayed(const Duration(milliseconds: 500), () {
// // Navigator.of(context).pop();
// // });
// // Navigator.of(context).pop();
},
onProgress: (progress) {
setState(() {
loadingPercentage = progress;
@@ -149,7 +112,7 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
))
..loadRequest(
Uri.parse(
'https://idp.e-kreta.hu/connect/authorize?prompt=login&nonce=refilc&response_type=code&code_challenge_method=S256&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&code_challenge=Oj_aVMRJHYsv00mrtGJY72NJa7HY54lVnU2Cb4CWbWw&redirect_uri=https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect&client_id=kreta-ellenorzo-student-mobile-ios&state=refilc_student_mobile'),
'https://idp.e-kreta.hu/connect/authorize?prompt=login&nonce=wylCrqT4oN6PPgQn2yQB0euKei9nJeZ6_ffJ-VpSKZU&response_type=code&code_challenge_method=S256&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&code_challenge=HByZRRnPGb-Ko_wTI7ibIba1HQ6lor0ws4bcgReuYSQ&redirect_uri=https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect&client_id=kreta-ellenorzo-student-mobile-ios&state=refilc_student_mobile'), // &institute_code=${widget.selectedSchool}
);
}
@@ -160,24 +123,57 @@ class _KretenLoginScreenState extends State<KretenLoginScreen> {
// Nonce nonce = getNonce(nonceStr, );
// }
@override
void dispose() {
// Step 3: Dispose of the animation controller
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
title: const Text('e-KRÉTA Bejelentkezés'),
),
body: Stack(
children: [
WebViewWidget(
controller: controller,
),
if (loadingPercentage < 100)
LinearProgressIndicator(
value: loadingPercentage / 100.0,
// Trigger the fade-in animation only once when loading reaches 100%
if (loadingPercentage == 100 && !_hasFadedIn) {
_animationController.forward(); // Play the animation
_hasFadedIn =
true; // Set the flag to true, so the animation is not replayed
}
return Stack(
children: [
// Webview that will be displayed only when the loading is 100%
if (loadingPercentage == 100)
FadeTransition(
opacity: Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeIn,
),
),
],
),
child: WebViewWidget(
controller: controller,
),
),
// Show the CircularProgressIndicator while loading is not 100%
if (loadingPercentage < 100)
Center(
child: TweenAnimationBuilder(
tween: Tween<double>(begin: 0, end: loadingPercentage / 100.0),
duration: const Duration(milliseconds: 300),
builder: (context, double value, child) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(
value: value, // Smoothly animates the progress
),
],
);
},
),
),
],
);
}
}

View File

@@ -1,17 +1,18 @@
// import 'dart:async';
import 'package:refilc/api/client.dart';
import 'dart:io' show Platform;
import 'package:refilc/api/login.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
import 'package:refilc_mobile_ui/common/system_chrome.dart';
import 'package:refilc_mobile_ui/screens/login/login_button.dart';
import 'package:refilc_mobile_ui/screens/login/login_input.dart';
import 'package:refilc_mobile_ui/screens/login/school_input/school_input.dart';
import 'package:refilc_mobile_ui/screens/settings/privacy_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'login_screen.i18n.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:refilc_mobile_ui/screens/login/kreten_login.dart'; //new library for new web login
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key, this.back = false});
@@ -27,6 +28,7 @@ class LoginScreenState extends State<LoginScreen> {
final passwordController = TextEditingController();
final schoolController = SchoolInputController();
final _scrollController = ScrollController();
final codeController = TextEditingController();
LoginState _loginState = LoginState.normal;
bool showBack = false;
@@ -73,225 +75,292 @@ class LoginScreenState extends State<LoginScreen> {
});
}
double paddingTop = 0;
@override
Widget build(BuildContext context) {
precacheImage(const AssetImage('assets/images/showcase1.png'), context);
precacheImage(const AssetImage('assets/images/showcase2.png'), context);
precacheImage(const AssetImage('assets/images/showcase3.png'), context);
precacheImage(const AssetImage('assets/images/showcase4.png'), context);
if (Platform.isIOS) {
paddingTop = 0;
} else if (Platform.isAndroid) {
paddingTop = 20;
}
return Scaffold(
body: Container(
decoration: BoxDecoration(color: AppColors.of(context).loginBackground),
decoration: const BoxDecoration(color: Color(0xFFDAE4F7)),
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
controller: _scrollController,
child: Container(
decoration:
BoxDecoration(color: AppColors.of(context).loginBackground),
decoration: const BoxDecoration(color: Color(0xFFDAE4F7)),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
alignment: Alignment.topLeft,
padding: const EdgeInsets.only(left: 16.0, top: 12.0),
child: ClipOval(
child: Material(
type: MaterialType.transparency,
child: showBack
? BackButton(
color: AppColors.of(context).loginPrimary)
: const SizedBox(height: 48.0),
),
),
),
// app icon
Padding(
padding: EdgeInsets.zero,
child: Image.asset(
'assets/icons/ic_rounded.png',
width: 50.0,
),
),
// texts
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0,
vertical: 12.0,
),
child: Text(
'reFilc',
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontSize: 28.0,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0,
),
child: Text(
'login_w_kreten'.i18n,
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontSize: 18.0,
fontWeight: FontWeight.w500,
height: 1.2,
),
),
),
const Spacer(
flex: 2,
),
// inputs
Padding(
padding: const EdgeInsets.only(
left: 22.0,
right: 22.0,
top: 0.0,
),
child: AutofillGroup(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
padding: EdgeInsets.only(left: 24, top: paddingTop),
child: Row(
children: [
// username
Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"username".i18n,
maxLines: 1,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
Expanded(
child: Text(
"usernameHint".i18n,
maxLines: 1,
textAlign: TextAlign.right,
style: TextStyle(
color:
AppColors.of(context).loginSecondary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
],
),
Image.asset(
'assets/icons/ic_rounded.png',
width: 30.0,
),
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: LoginInput(
style: LoginInputStyle.username,
controller: usernameController,
),
const SizedBox(width: 8),
const Text(
'reFilc',
style: TextStyle(
color: Color(0xFF050B15),
fontSize: 18.0,
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat'),
),
// password
Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"password".i18n,
maxLines: 1,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
Expanded(
child: Text(
"passwordHint".i18n,
maxLines: 1,
textAlign: TextAlign.right,
style: TextStyle(
color:
AppColors.of(context).loginSecondary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
],
),
Material(
type: MaterialType.transparency,
child: showBack
? BackButton(color: AppColors.of(context).text)
: const SizedBox(height: 48.0),
),
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: LoginInput(
style: LoginInputStyle.password,
controller: passwordController,
),
),
// school
Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Text(
"school".i18n,
maxLines: 1,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
SchoolInput(
scroll: _scrollController,
controller: schoolController,
],
)),
Stack(
alignment: Alignment.bottomCenter,
children: [
Column(
//login buttons and ui starts here
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
const SizedBox(height: 21),
CarouselSlider(
options: CarouselOptions(
height: MediaQuery.of(context).size.height,
viewportFraction: 1,
autoPlay: true,
autoPlayInterval: const Duration(seconds: 6),
pauseAutoPlayOnTouch: true),
items: [1, 2, 3, 4].map((i) {
return Builder(
builder: (BuildContext context) {
return Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding:
const EdgeInsets.only(left: 24),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text(
"welcome_title_$i".i18n,
style: const TextStyle(
color: Color(0xFF050B15),
fontSize: 19,
fontFamily: 'Montserrat',
fontWeight: FontWeight.w700,
height: 1.3),
),
const SizedBox(
height: 14.375), //meth
Padding(
padding: const EdgeInsets.only(
right: 20),
child: Text(
"welcome_text_$i".i18n,
style: const TextStyle(
color: Color(0xFF050B15),
fontFamily: 'FigTree',
fontWeight:
FontWeight.w500,
fontSize: 17,
height: 1.3),
),
),
],
)),
const SizedBox(height: 15.625),
Padding(
padding: const EdgeInsets.only(
left: 16, right: 16),
child: Image.asset(
'assets/images/showcase$i.png'))
],
);
},
);
}).toList(),
),
],
),
),
),
// login button
Padding(
padding: const EdgeInsets.only(
top: 35.0,
left: 22.0,
right: 22.0,
),
child: Visibility(
visible: _loginState != LoginState.inProgress,
replacement: const Padding(
padding: EdgeInsets.symmetric(vertical: 6.0),
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(Colors.white),
Container(
height: 280,
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0x00DAE4F7), Color(0xFFDAE4F7)],
stops: [0, 0.12],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Padding(
padding: EdgeInsets.only(
top: 50,
bottom: MediaQuery.of(context).viewInsets.bottom),
child: Column(
children: [
SizedBox(
height: 48,
width: double.infinity,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16),
child: FilledButton(
style: ButtonStyle(
shape: WidgetStateProperty.all<
RoundedRectangleBorder>(
const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(12)),
))),
onPressed: () {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
isScrollControlled:
true, // This ensures the modal accommodates input fields properly
builder: (BuildContext context) {
return Container(
height: MediaQuery.of(context)
.size
.height *
0.9 +
MediaQuery.of(context)
.viewInsets
.bottom,
decoration: const BoxDecoration(
color: Color(0xFFDAE4F7),
borderRadius: BorderRadius.only(
topRight:
Radius.circular(24.0),
topLeft:
Radius.circular(24.0),
),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets
.symmetric(
vertical: 18),
child: Container(
decoration:
const BoxDecoration(
color:
Color(0xFFB9C8E5),
borderRadius:
BorderRadius.only(
topRight:
Radius.circular(
2.0),
topLeft:
Radius.circular(
2.0),
),
),
width: 40,
height: 4,
),
),
Expanded(
child: Padding(
padding:
const EdgeInsets.only(
right: 14,
left: 14,
bottom: 24),
child: ClipRRect(
borderRadius:
BorderRadius
.circular(16),
child: Container(
decoration:
BoxDecoration(
borderRadius:
BorderRadius
.circular(
16),
),
child:
KretenLoginWidget(
onLogin:
(String code) {
codeController
.text = code;
Navigator.of(
context)
.pop();
},
),
),
),
),
)
],
),
);
},
).then((value) {
// After closing the modal bottom sheet, check if the code is set
if (codeController.text.isNotEmpty) {
// Call your API after retrieving the code
_NewLoginAPI(context: context);
}
});
},
child: Text(
"login_w_kreta_acc".i18n,
style: const TextStyle(
fontFamily: 'Montserrat',
fontSize: 16,
fontWeight: FontWeight.w700),
)),
),
),
const SizedBox(height: 19),
// privacy policy
GestureDetector(
onTap: () => PrivacyView.show(context),
child: Text(
'privacy'.i18n,
style: TextStyle(
color: AppColors.of(context).loginSecondary,
fontWeight: FontWeight.w500,
fontSize: 14.0,
),
),
),
],
),
),
),
child: LoginButton(
child: Text("login".i18n,
maxLines: 1,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
)),
onPressed: () => _loginAPI(context: context),
),
),
],
),
// error messages
if (_loginState == LoginState.missingFields ||
_loginState == LoginState.invalidGrant ||
_loginState == LoginState.failed)
@@ -312,8 +381,6 @@ class LoginScreenState extends State<LoginScreen> {
textAlign: TextAlign.center,
),
),
const SizedBox(height: 22.0),
// privacy policy
GestureDetector(
onTap: () => PrivacyView.show(context),
@@ -326,10 +393,6 @@ class LoginScreenState extends State<LoginScreen> {
),
),
),
const Spacer(
flex: 1,
),
],
),
),
@@ -339,24 +402,65 @@ class LoginScreenState extends State<LoginScreen> {
);
}
void _loginAPI({required BuildContext context}) {
String username = usernameController.text;
String password = passwordController.text;
// void _loginAPI({required BuildContext context}) {
// String username = usernameController.text;
// String password = passwordController.text;
tempUsername = username;
// tempUsername = username;
if (username == "" ||
password == "" ||
schoolController.selectedSchool == null) {
return setState(() => _loginState = LoginState.missingFields);
// if (username == "" ||
// password == "" ||
// schoolController.selectedSchool == null) {
// return setState(() => _loginState = LoginState.missingFields);
// }
// // ignore: no_leading_underscores_for_local_identifiers
// void _callAPI() {
// loginAPI(
// username: username,
// password: password,
// instituteCode: schoolController.selectedSchool!.instituteCode,
// context: context,
// onLogin: (user) {
// ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
// context: context,
// brightness: Brightness.light,
// content: Text("welcome".i18n.fill([user.name]),
// overflow: TextOverflow.ellipsis),
// ));
// },
// onSuccess: () {
// ScaffoldMessenger.of(context).hideCurrentSnackBar();
// setSystemChrome(context);
// Navigator.of(context).pushReplacementNamed("login_to_navigation");
// }).then(
// (res) => setState(() {
// // if (res == LoginState.invalidGrant &&
// // tempUsername.replaceAll(username, '').length <= 3) {
// // tempUsername = username + ' ';
// // Timer(
// // const Duration(milliseconds: 500),
// // () => _loginAPI(context: context),
// // );
// // // _loginAPI(context: context);
// // } else {
// _loginState = res;
// // }
// }),
// );
// }
// ignore: non_constant_identifier_names
void _NewLoginAPI({required BuildContext context}) {
String code = codeController.text;
if (code == "") {
return setState(() => _loginState = LoginState.failed);
}
// ignore: no_leading_underscores_for_local_identifiers
void _callAPI() {
loginAPI(
username: username,
password: password,
instituteCode: schoolController.selectedSchool!.instituteCode,
newLoginAPI(
code: code,
context: context,
onLogin: (user) {
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(

View File

@@ -33,6 +33,7 @@ extension Localization on String {
"welcome_title_4": "Take as many notes as you want.",
"welcome_text_4":
"You can also organise your notes by lesson in the built-in notebook, so you can find everything in one app.",
"login_w_kreta_acc": "Log in with your e-KRÉTA account",
},
"hu_hu": {
"username": "Felhasználónév",
@@ -64,6 +65,7 @@ extension Localization on String {
"welcome_title_4": "Füzetelj annyit, amennyit csak szeretnél.",
"welcome_text_4":
"A beépített jegyzetfüzetbe órák szerint is rendezheted a jegyzeteidet, így mindent megtalálsz egy appban.",
"login_w_kreta_acc": "Bejelentkezés e-KRÉTA fiókkal",
},
"de_de": {
"username": "Benutzername",
@@ -95,6 +97,7 @@ extension Localization on String {
"welcome_title_4": "Take as many notes as you want.",
"welcome_text_4":
"You can also organise your notes by lesson in the built-in notebook, so you can find everything in one app.",
"login_w_kreta_acc": "Mit e-KRÉTA-Konto anmelden",
},
};

View File

@@ -1,618 +0,0 @@
// // import 'dart:async';
// import 'package:refilc/api/client.dart';
// import 'package:refilc/api/login.dart';
// import 'package:refilc/theme/colors/colors.dart';
// import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
// import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
// import 'package:refilc_mobile_ui/common/system_chrome.dart';
// import 'package:refilc_mobile_ui/common/widgets/absence/absence_display.dart';
// import 'package:refilc_mobile_ui/screens/login/login_button.dart';
// import 'package:refilc_mobile_ui/screens/login/login_input.dart';
// import 'package:refilc_mobile_ui/screens/login/school_input/school_input.dart';
// import 'package:refilc_mobile_ui/screens/settings/privacy_view.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter/services.dart';
// import 'login_screen.i18n.dart';
// import 'package:carousel_slider/carousel_slider.dart';
// import 'package:flutter_svg/flutter_svg.dart';
// class LoginScreen extends StatefulWidget {
// const LoginScreen({super.key, this.back = false});
// final bool back;
// @override
// LoginScreenState createState() => LoginScreenState();
// }
// class LoginScreenState extends State<LoginScreen> {
// final usernameController = TextEditingController();
// final passwordController = TextEditingController();
// final schoolController = SchoolInputController();
// final _scrollController = ScrollController();
// LoginState _loginState = LoginState.normal;
// bool showBack = false;
// // Scaffold Gradient background
// // final LinearGradient _backgroundGradient = const LinearGradient(
// // colors: [
// // Color.fromARGB(255, 61, 122, 244),
// // Color.fromARGB(255, 23, 77, 185),
// // Color.fromARGB(255, 7, 42, 112),
// // ],
// // begin: Alignment(-0.8, -1.0),
// // end: Alignment(0.8, 1.0),
// // stops: [-1.0, 0.0, 1.0],
// // );
// late String tempUsername = '';
// @override
// void initState() {
// super.initState();
// showBack = widget.back;
// SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
// statusBarColor: Colors.transparent,
// statusBarIconBrightness: Brightness.light,
// systemNavigationBarColor: Colors.white,
// systemNavigationBarIconBrightness: Brightness.dark,
// ));
// FilcAPI.getSchools().then((schools) {
// if (schools != null) {
// schoolController.update(() {
// schoolController.schools = schools;
// });
// } else {
// ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
// content: Text("schools_error".i18n,
// style: const TextStyle(color: Colors.white)),
// backgroundColor: AppColors.of(context).red,
// context: context,
// ));
// }
// });
// }
// @override
// Widget build(BuildContext context) {
// precacheImage(const AssetImage('assets/images/showcase1.png'), context);
// precacheImage(const AssetImage('assets/images/showcase2.png'), context);
// precacheImage(const AssetImage('assets/images/showcase3.png'), context);
// precacheImage(const AssetImage('assets/images/showcase4.png'), context);
// bool selected = false;
// return Scaffold(
// body: Container(
// decoration: const BoxDecoration(color: Color(0xFFDAE4F7)),
// child: SingleChildScrollView(
// physics: const ClampingScrollPhysics(),
// controller: _scrollController,
// child: Container(
// decoration: const BoxDecoration(color: Color(0xFFDAE4F7)),
// width: MediaQuery.of(context).size.width,
// height: MediaQuery.of(context).size.height,
// child: SafeArea(
// child: Column(
// children: [
// // app icon
// Padding(
// padding: const EdgeInsets.only(left: 24, top: 20),
// child: Row(
// children: [
// Image.asset(
// 'assets/icons/ic_rounded.png',
// width: 30.0,
// ),
// const SizedBox(width: 8),
// const Text(
// 'reFilc',
// style: TextStyle(
// color: Color(0xFF050B15),
// fontSize: 18.0,
// fontWeight: FontWeight.bold,
// fontFamily: 'Montserrat'),
// ),
// Material(
// type: MaterialType.transparency,
// child: showBack
// ? BackButton(color: AppColors.of(context).text)
// : const SizedBox(height: 48.0),
// ),
// ],
// )),
// Stack(
// alignment: Alignment.bottomCenter,
// children: [
// Column(
// //login buttons and ui starts here
// mainAxisAlignment: MainAxisAlignment.end,
// crossAxisAlignment: CrossAxisAlignment.end,
// children: [
// const SizedBox(height: 21),
// CarouselSlider(
// options: CarouselOptions(
// height: MediaQuery.of(context).size.height,
// viewportFraction: 1,
// autoPlay: true,
// autoPlayInterval: const Duration(seconds: 6),
// pauseAutoPlayOnTouch: true),
// items: [1, 2, 3, 4].map((i) {
// return Builder(
// builder: (BuildContext context) {
// return Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// Padding(
// padding:
// const EdgeInsets.only(left: 24),
// child: Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// mainAxisAlignment:
// MainAxisAlignment.start,
// children: [
// Text(
// "welcome_title_$i".i18n,
// style: const TextStyle(
// color: Color(0xFF050B15),
// fontSize: 19,
// fontFamily: 'Montserrat',
// fontWeight: FontWeight.w700,
// height: 1.3),
// ),
// const SizedBox(
// height: 14.375), //meth
// Padding(
// padding: const EdgeInsets.only(
// right: 20),
// child: Text(
// "welcome_text_$i".i18n,
// style: const TextStyle(
// color: Color(0xFF050B15),
// fontFamily: 'FigTree',
// fontWeight:
// FontWeight.w500,
// fontSize: 17,
// height: 1.3),
// ),
// ),
// ],
// )),
// const SizedBox(height: 15.625),
// Padding(
// padding: const EdgeInsets.only(
// left: 16, right: 16),
// child: Image.asset(
// 'assets/images/showcase$i.png'))
// ],
// );
// },
// );
// }).toList(),
// ),
// ],
// ),
// Container(
// height: 300,
// width: double.infinity,
// decoration: const BoxDecoration(
// gradient: LinearGradient(
// colors: [Color(0x00DAE4F7), Color(0xFFDAE4F7)],
// stops: [0, 0.12],
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// ),
// ),
// child: Padding(
// padding: EdgeInsets.only(top: 50, bottom: MediaQuery.of(context).viewInsets.bottom),
// child: Column(
// children: [
// SizedBox(
// height: 48,
// width: double.infinity,
// child: Padding(
// padding: const EdgeInsets.symmetric(
// horizontal: 16),
// child: FilledButton(
// style: ButtonStyle(
// shape: MaterialStateProperty.all<
// RoundedRectangleBorder>(
// const RoundedRectangleBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(12)),
// ))),
// onPressed: () {
// showModalBottomSheet(
// backgroundColor: Colors.transparent,
// context: context,
// builder: (BuildContext context) {
// return Container(
// height: MediaQuery.of(context)
// .size
// .height *
// 0.5 + MediaQuery.of(context).viewInsets.bottom,
// decoration: const BoxDecoration(
// color: Color(0xFFDAE4F7),
// borderRadius: BorderRadius.only(
// topRight:
// Radius.circular(24.0),
// topLeft:
// Radius.circular(24.0),
// ),
// ),
// child: Column(
// crossAxisAlignment:
// CrossAxisAlignment.center,
// mainAxisAlignment:
// MainAxisAlignment.start,
// children: [
// Padding(
// padding:
// const EdgeInsets.only(
// top: 18),
// child: Container(
// decoration:
// const BoxDecoration(
// color:
// Color(0xFFB9C8E5),
// borderRadius:
// BorderRadius.only(
// topRight:
// Radius.circular(
// 2.0),
// topLeft:
// Radius.circular(
// 2.0),
// ),
// ),
// width: 40,
// height: 4,
// ),
// ),
// Container(
// width: double.infinity,
// child: AutofillGroup(
// child: Column(
// crossAxisAlignment:
// CrossAxisAlignment
// .end,
// children: [
// // username
// Padding(
// padding:
// const EdgeInsets
// .only(
// bottom:
// 6.0),
// child: Row(
// mainAxisAlignment:
// MainAxisAlignment
// .spaceBetween,
// children: [
// Expanded(
// child: Text(
// "username"
// .i18n,
// maxLines:
// 1,
// style:
// TextStyle(
// color: AppColors.of(context)
// .loginPrimary,
// fontWeight:
// FontWeight.w500,
// fontSize:
// 12.0,
// ),
// ),
// ),
// Expanded(
// child: Text(
// "usernameHint"
// .i18n,
// maxLines:
// 1,
// textAlign:
// TextAlign
// .right,
// style:
// TextStyle(
// color: AppColors.of(context)
// .loginSecondary,
// fontWeight:
// FontWeight.w500,
// fontSize:
// 12.0,
// ),
// ),
// ),
// ],
// ),
// ),
// Padding(
// padding:
// const EdgeInsets
// .only(
// bottom:
// 12.0),
// child: LoginInput(
// style:
// LoginInputStyle
// .username,
// controller:
// usernameController,
// ),
// ),
// // password
// Padding(
// padding:
// const EdgeInsets
// .only(
// bottom:
// 6.0),
// child: Row(
// mainAxisAlignment:
// MainAxisAlignment
// .spaceBetween,
// children: [
// Expanded(
// child: Text(
// "password"
// .i18n,
// maxLines:
// 1,
// style:
// TextStyle(
// color: AppColors.of(context)
// .loginPrimary,
// fontWeight:
// FontWeight.w500,
// fontSize:
// 12.0,
// ),
// ),
// ),
// Expanded(
// child: Text(
// "passwordHint"
// .i18n,
// maxLines:
// 1,
// textAlign:
// TextAlign
// .right,
// style:
// TextStyle(
// color: AppColors.of(context)
// .loginSecondary,
// fontWeight:
// FontWeight.w500,
// fontSize:
// 12.0,
// ),
// ),
// ),
// ],
// ),
// ),
// Padding(
// padding:
// const EdgeInsets
// .only(
// bottom:
// 12.0),
// child: LoginInput(
// style:
// LoginInputStyle
// .password,
// controller:
// passwordController,
// ),
// ),
// // school
// Padding(
// padding:
// const EdgeInsets
// .only(
// bottom:
// 6.0),
// child: Text(
// "school".i18n,
// maxLines: 1,
// style:
// TextStyle(
// color: AppColors.of(
// context)
// .loginPrimary,
// fontWeight:
// FontWeight
// .w500,
// fontSize:
// 12.0,
// ),
// ),
// ),
// SchoolInput(
// scroll:
// _scrollController,
// controller:
// schoolController,
// ),
// ],
// ),
// ),
// ),
// const Padding(
// padding: EdgeInsets.only(
// left: 22.0,
// right: 22.0,
// top: 0.0,
// ),
// ),
// Padding(
// padding:
// const EdgeInsets.only(
// top: 35.0,
// left: 22.0,
// right: 22.0,
// ),
// child: Visibility(
// visible: _loginState !=
// LoginState
// .inProgress,
// replacement:
// const Padding(
// padding: EdgeInsets
// .symmetric(
// vertical:
// 6.0),
// child:
// CircularProgressIndicator(
// valueColor:
// AlwaysStoppedAnimation<
// Color>(
// Colors
// .white),
// ),
// ),
// child: LoginButton(
// child: Text(
// "login".i18n,
// maxLines: 1,
// style:
// const TextStyle(
// fontWeight:
// FontWeight
// .bold,
// fontSize: 20.0,
// )),
// onPressed: () =>
// _loginAPI(
// context:
// context),
// ),
// ),
// ),
// ]),
// );
// },
// );
// },
// child: Text(
// "login".i18n,
// style: const TextStyle(
// fontFamily: 'Montserrat',
// fontSize: 20,
// fontWeight: FontWeight.w700),
// )),
// ),
// ),
// const SizedBox(height: 8),
// ],
// ),
// ),
// ),
// ],
// ),
// if (_loginState == LoginState.missingFields ||
// _loginState == LoginState.invalidGrant ||
// _loginState == LoginState.failed)
// Padding(
// padding: const EdgeInsets.only(
// top: 8.0, left: 12.0, right: 12.0),
// child: Text(
// [
// "missing_fields",
// "invalid_grant",
// "error"
// ][_loginState.index]
// .i18n,
// style: const TextStyle(
// color: Colors.red,
// fontWeight: FontWeight.w500,
// ),
// textAlign: TextAlign.center,
// ),
// ),
// // privacy policy
// GestureDetector(
// onTap: () => PrivacyView.show(context),
// child: Text(
// 'privacy'.i18n,
// style: TextStyle(
// color: AppColors.of(context).loginSecondary,
// fontWeight: FontWeight.w500,
// fontSize: 14.0,
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
// ),
// );
// }
// void _loginAPI({required BuildContext context}) {
// String username = usernameController.text;
// String password = passwordController.text;
// tempUsername = username;
// if (username == "" ||
// password == "" ||
// schoolController.selectedSchool == null) {
// return setState(() => _loginState = LoginState.missingFields);
// }
// // ignore: no_leading_underscores_for_local_identifiers
// void _callAPI() {
// loginAPI(
// username: username,
// password: password,
// instituteCode: schoolController.selectedSchool!.instituteCode,
// context: context,
// onLogin: (user) {
// ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
// context: context,
// brightness: Brightness.light,
// content: Text("welcome".i18n.fill([user.name]),
// overflow: TextOverflow.ellipsis),
// ));
// },
// onSuccess: () {
// ScaffoldMessenger.of(context).hideCurrentSnackBar();
// setSystemChrome(context);
// Navigator.of(context).pushReplacementNamed("login_to_navigation");
// }).then(
// (res) => setState(() {
// // if (res == LoginState.invalidGrant &&
// // tempUsername.replaceAll(username, '').length <= 3) {
// // tempUsername = username + ' ';
// // Timer(
// // const Duration(milliseconds: 500),
// // () => _loginAPI(context: context),
// // );
// // // _loginAPI(context: context);
// // } else {
// _loginState = res;
// // }
// }),
// );
// }
// setState(() => _loginState = LoginState.inProgress);
// _callAPI();
// }
// }

View File

@@ -0,0 +1,513 @@
// import 'dart:async';
import 'package:refilc/api/client.dart';
import 'package:refilc/api/login.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
import 'package:refilc_mobile_ui/common/system_chrome.dart';
// import 'package:refilc_mobile_ui/screens/login/kreten_login.dart';
import 'package:refilc_mobile_ui/screens/login/login_button.dart';
import 'package:refilc_mobile_ui/screens/login/login_input.dart';
import 'package:refilc_mobile_ui/screens/login/school_input/school_input.dart';
import 'package:refilc_mobile_ui/screens/settings/privacy_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'login_screen.i18n.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key, this.back = false});
final bool back;
@override
LoginScreenState createState() => LoginScreenState();
}
class LoginScreenState extends State<LoginScreen> {
final usernameController = TextEditingController();
final passwordController = TextEditingController();
final schoolController = SchoolInputController();
final _scrollController = ScrollController();
// new controllers
final codeController = TextEditingController();
LoginState _loginState = LoginState.normal;
bool showBack = false;
// Scaffold Gradient background
// final LinearGradient _backgroundGradient = const LinearGradient(
// colors: [
// Color.fromARGB(255, 61, 122, 244),
// Color.fromARGB(255, 23, 77, 185),
// Color.fromARGB(255, 7, 42, 112),
// ],
// begin: Alignment(-0.8, -1.0),
// end: Alignment(0.8, 1.0),
// stops: [-1.0, 0.0, 1.0],
// );
late String tempUsername = '';
@override
void initState() {
super.initState();
showBack = widget.back;
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
systemNavigationBarColor: Colors.white,
systemNavigationBarIconBrightness: Brightness.dark,
));
FilcAPI.getSchools().then((schools) {
if (schools != null) {
schoolController.update(() {
schoolController.schools = schools;
});
} else {
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
content: Text("schools_error".i18n,
style: const TextStyle(color: Colors.white)),
backgroundColor: AppColors.of(context).red,
context: context,
));
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(color: AppColors.of(context).loginBackground),
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
controller: _scrollController,
child: Container(
decoration:
BoxDecoration(color: AppColors.of(context).loginBackground),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
alignment: Alignment.topLeft,
padding: const EdgeInsets.only(left: 16.0, top: 12.0),
child: ClipOval(
child: Material(
type: MaterialType.transparency,
child: showBack
? BackButton(
color: AppColors.of(context).loginPrimary)
: const SizedBox(height: 48.0),
),
),
),
// app icon
Padding(
padding: EdgeInsets.zero,
child: Image.asset(
'assets/icons/ic_rounded.png',
width: 50.0,
),
),
// texts
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0,
vertical: 12.0,
),
child: Text(
'reFilc',
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontSize: 28.0,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0,
),
child: Text(
'login_w_kreten'.i18n,
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontSize: 18.0,
fontWeight: FontWeight.w500,
height: 1.2,
),
),
),
const Spacer(
flex: 2,
),
// kreten login button
// GestureDetector(
// onTap: () {
// final NavigatorState navigator = Navigator.of(context);
// navigator
// .push(
// MaterialPageRoute(
// builder: (context) => KretenLoginScreen(
// onLogin: (String code) {
// codeController.text = code;
// navigator.pop();
// },
// ),
// ),
// )
// .then((value) {
// if (codeController.text != "") {
// _NewLoginAPI(context: context);
// }
// });
// },
// child: Container(
// width: MediaQuery.of(context).size.width * 0.75,
// height: 50.0,
// decoration: BoxDecoration(
// // image: const DecorationImage(
// // image:
// // AssetImage('assets/images/btn_kreten_login.png'),
// // fit: BoxFit.scaleDown,
// // ),
// borderRadius: BorderRadius.circular(12.0),
// color: const Color(0xFF0097C1),
// ),
// padding: const EdgeInsets.only(
// top: 5.0, left: 5.0, right: 5.0, bottom: 5.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Image.asset(
// 'assets/images/btn_kreten_login.png',
// ),
// const SizedBox(
// width: 10.0,
// ),
// Container(
// width: 1.0,
// height: 30.0,
// color: Colors.white,
// ),
// const SizedBox(
// width: 10.0,
// ),
// Text(
// 'login_w_kreta_acc'.i18n,
// textAlign: TextAlign.center,
// style: const TextStyle(
// color: Colors.white,
// fontWeight: FontWeight.bold,
// fontSize: 15.0,
// ),
// ),
// ],
// )),
// ),
// const Spacer(
// flex: 1,
// ),
// inputs
Padding(
padding: const EdgeInsets.only(
left: 22.0,
right: 22.0,
top: 0.0,
),
child: AutofillGroup(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// username
Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"username".i18n,
maxLines: 1,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
Expanded(
child: Text(
"usernameHint".i18n,
maxLines: 1,
textAlign: TextAlign.right,
style: TextStyle(
color:
AppColors.of(context).loginSecondary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: LoginInput(
style: LoginInputStyle.username,
controller: usernameController,
),
),
// password
Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"password".i18n,
maxLines: 1,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
Expanded(
child: Text(
"passwordHint".i18n,
maxLines: 1,
textAlign: TextAlign.right,
style: TextStyle(
color:
AppColors.of(context).loginSecondary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: LoginInput(
style: LoginInputStyle.password,
controller: passwordController,
),
),
// school
Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Text(
"school".i18n,
maxLines: 1,
style: TextStyle(
color: AppColors.of(context).loginPrimary,
fontWeight: FontWeight.w500,
fontSize: 12.0,
),
),
),
SchoolInput(
scroll: _scrollController,
controller: schoolController,
),
],
),
),
),
// login button
Padding(
padding: const EdgeInsets.only(
top: 35.0,
left: 22.0,
right: 22.0,
),
child: Visibility(
visible: _loginState != LoginState.inProgress,
replacement: const Padding(
padding: EdgeInsets.symmetric(vertical: 6.0),
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(Colors.white),
),
),
child: LoginButton(
child: Text("login".i18n,
maxLines: 1,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
)),
onPressed: () => _loginAPI(context: context),
),
),
),
// error messages
if (_loginState == LoginState.missingFields ||
_loginState == LoginState.invalidGrant ||
_loginState == LoginState.failed)
Padding(
padding: const EdgeInsets.only(
top: 8.0, left: 12.0, right: 12.0),
child: Text(
[
"missing_fields",
"invalid_grant",
"error"
][_loginState.index]
.i18n,
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 22.0),
// privacy policy
GestureDetector(
onTap: () => PrivacyView.show(context),
child: Text(
'privacy'.i18n,
style: TextStyle(
color: AppColors.of(context).loginSecondary,
fontWeight: FontWeight.w500,
fontSize: 14.0,
),
),
),
const Spacer(
flex: 1,
),
],
),
),
),
),
),
);
}
// new login api
// ignore: non_constant_identifier_names, unused_element
void _NewLoginAPI({required BuildContext context}) {
String code = codeController.text;
if (code == "") {
return setState(() => _loginState = LoginState.failed);
}
// ignore: no_leading_underscores_for_local_identifiers
void _callAPI() {
newLoginAPI(
code: code,
context: context,
onLogin: (user) {
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
context: context,
brightness: Brightness.light,
content: Text("welcome".i18n.fill([user.name]),
overflow: TextOverflow.ellipsis),
));
},
onSuccess: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
setSystemChrome(context);
Navigator.of(context).pushReplacementNamed("login_to_navigation");
}).then(
(res) => setState(() {
// if (res == LoginState.invalidGrant &&
// tempUsername.replaceAll(username, '').length <= 3) {
// tempUsername = username + ' ';
// Timer(
// const Duration(milliseconds: 500),
// () => _loginAPI(context: context),
// );
// // _loginAPI(context: context);
// } else {
_loginState = res;
// }
}),
);
}
setState(() => _loginState = LoginState.inProgress);
_callAPI();
}
void _loginAPI({required BuildContext context}) {
String username = usernameController.text;
String password = passwordController.text;
tempUsername = username;
if (username == "" ||
password == "" ||
schoolController.selectedSchool == null) {
return setState(() => _loginState = LoginState.missingFields);
}
// ignore: no_leading_underscores_for_local_identifiers
void _callAPI() {
loginAPI(
username: username,
password: password,
instituteCode: schoolController.selectedSchool!.instituteCode,
context: context,
onLogin: (user) {
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
context: context,
brightness: Brightness.light,
content: Text("welcome".i18n.fill([user.name]),
overflow: TextOverflow.ellipsis),
));
},
onSuccess: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
setSystemChrome(context);
Navigator.of(context).pushReplacementNamed("login_to_navigation");
}).then(
(res) => setState(() {
// if (res == LoginState.invalidGrant &&
// tempUsername.replaceAll(username, '').length <= 3) {
// tempUsername = username + ' ';
// Timer(
// const Duration(milliseconds: 500),
// () => _loginAPI(context: context),
// );
// // _loginAPI(context: context);
// } else {
_loginState = res;
// }
}),
);
}
setState(() => _loginState = LoginState.inProgress);
_callAPI();
}
}

View File

@@ -0,0 +1,170 @@
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class QwIDLoginWidget extends StatefulWidget {
const QwIDLoginWidget({super.key, required this.onLogin});
// final String selectedSchool;
final void Function(String code) onLogin;
@override
State<QwIDLoginWidget> createState() => _QwIDLoginWidgetState();
}
class _QwIDLoginWidgetState extends State<QwIDLoginWidget>
with TickerProviderStateMixin {
late final WebViewController controller;
late AnimationController _animationController;
var loadingPercentage = 0;
var currentUrl = '';
bool _hasFadedIn = false;
@override
void initState() {
super.initState();
_animationController = AnimationController(
vsync: this, // Use the TickerProviderStateMixin
duration: const Duration(milliseconds: 350),
);
controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (n) async {
if (n.url.startsWith('refilc://oauth2-callback/qwid')) {
setState(() {
loadingPercentage = 0;
currentUrl = n.url;
});
// final String instituteCode = widget.selectedSchool;
// if (!n.url.startsWith(
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
// return;
// }
String longLivedToken = n.url
.replaceAll('refilc://oauth2-callback/qwid?access_token=', '');
widget.onLogin(longLivedToken);
// Future.delayed(const Duration(milliseconds: 500), () {
// Navigator.of(context).pop();
// });
// Navigator.of(context).pop();
return NavigationDecision.prevent;
} else {
return NavigationDecision.navigate;
}
},
onPageStarted: (url) async {
// setState(() {
// loadingPercentage = 0;
// currentUrl = url;
// });
// // final String instituteCode = widget.selectedSchool;
// if (!url.startsWith(
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=')) {
// return;
// }
// List<String> requiredThings = url
// .replaceAll(
// 'https://mobil.e-kreta.hu/ellenorzo-student/prod/oauthredirect?code=',
// '')
// .replaceAll(
// '&scope=openid%20email%20offline_access%20kreta-ellenorzo-webapi.public%20kreta-eugyintezes-webapi.public%20kreta-fileservice-webapi.public%20kreta-mobile-global-webapi.public%20kreta-dkt-webapi.public%20kreta-ier-webapi.public&state=refilc_student_mobile&session_state=',
// ':')
// .split(':');
// String code = requiredThings[0];
// // String sessionState = requiredThings[1];
// widget.onLogin(code);
// // Future.delayed(const Duration(milliseconds: 500), () {
// // Navigator.of(context).pop();
// // });
// // Navigator.of(context).pop();
},
onProgress: (progress) {
setState(() {
loadingPercentage = progress;
});
},
onPageFinished: (url) {
setState(() {
loadingPercentage = 100;
});
},
))
..loadRequest(
Uri.parse(
'https://qwid.qwit.dev/oauth2/authorize?client_id=99aa103a-0bd7-43e0-8421-3bb0b2f6adb1&scope=*&redirect_uri=https://api.refilc.hu/v4/oauth2/callback/app/qwid&response_type=code'), // &institute_code=${widget.selectedSchool}
);
}
// Future<void> loadLoginUrl() async {
// String nonceStr = await Provider.of<KretaClient>(context, listen: false)
// .getAPI(KretaAPI.nonce, json: false);
// Nonce nonce = getNonce(nonceStr, );
// }
@override
void dispose() {
// Step 3: Dispose of the animation controller
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// Trigger the fade-in animation only once when loading reaches 100%
if (loadingPercentage == 100 && !_hasFadedIn) {
_animationController.forward(); // Play the animation
_hasFadedIn =
true; // Set the flag to true, so the animation is not replayed
}
return Stack(
children: [
// Webview that will be displayed only when the loading is 100%
if (loadingPercentage == 100)
FadeTransition(
opacity: Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeIn,
),
),
child: WebViewWidget(
controller: controller,
),
),
// Show the CircularProgressIndicator while loading is not 100%
if (loadingPercentage < 100)
Center(
child: TweenAnimationBuilder(
tween: Tween<double>(begin: 0, end: loadingPercentage / 100.0),
duration: const Duration(milliseconds: 300),
builder: (context, double value, child) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(
value: value, // Smoothly animates the progress
),
],
);
},
),
),
],
);
}
}

View File

@@ -47,7 +47,7 @@ class SchoolInputOverlayWidget extends StatelessWidget {
showWhenUnlinked: false,
offset: Offset(0.0, size.height + 5.0),
child: Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0)),
elevation: 4.0,

View File

@@ -2,6 +2,7 @@
import 'package:refilc_mobile_ui/pages/absences/absences_page.dart';
import 'package:refilc_mobile_ui/pages/grades/grades_page.dart';
import 'package:refilc_mobile_ui/pages/home/home_page.dart';
import 'package:refilc_mobile_ui/pages/messages/messages_page.dart';
import 'package:refilc_mobile_ui/pages/notes/notes_page.dart';
// import 'package:refilc_mobile_ui/pages/messages/messages_page.dart';
import 'package:refilc_mobile_ui/pages/timetable/timetable_page.dart';
@@ -20,8 +21,8 @@ Route navigationRouteHandler(RouteSettings settings) {
return navigationPageRoute((context) => const NotesPage());
case "absences":
return navigationPageRoute((context) => const AbsencesPage());
// case "messages":
// return navigationPageRoute((context) => const MessagesPage());
case "messages":
return navigationPageRoute((context) => const MessagesPage());
// case "absences":
// return navigationPageRoute((context) => const AbsencesPage());
default:

View File

@@ -302,7 +302,7 @@ class NavigationScreenState extends State<NavigationScreen>
children: [
// Status bar
Material(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
child: const StatusBar(),
),

View File

@@ -56,6 +56,16 @@ class AccountView extends StatelessWidget {
Detail(
title: "parents".plural(user.student.parents.length),
description: user.student.parents.join(", ")),
if (user.student.gradeDelay > 0)
Detail(
title: "grade_delay".i18n,
description: "hrs".i18n.fill([user.student.gradeDelay]),
),
// if ((user.student.bankAccount ?? "").isNotEmpty)
// Detail(
// title: "bank_account".i18n,
// description: (user.student.bankAccount ?? "not_provided".i18n),
// ),
const SizedBox(
height: 10.0,
),

View File

@@ -10,6 +10,8 @@ extension Localization on String {
"address": "Home address",
"parents": "Parent(s)",
"parents_phone": "Parents' phone number: ",
"grade_delay": "Grade visibility delay",
"hrs": "%s hour(s)",
},
"hu_hu": {
"birthdate": "Születési dátum",
@@ -17,6 +19,8 @@ extension Localization on String {
"class": "Osztály",
"address": "Lakcím",
"parents": "Szülő(k)",
"grade_delay": "Jegy megjelenítési késleltetés",
"hrs": "%s óra",
},
"de_de": {
"birthdate": "Geburtsdatum",
@@ -24,6 +28,8 @@ extension Localization on String {
"class": "Klasse",
"address": "Wohnanschrift",
"parents": "Elter(n)",
"grade_delay": "Notenverzögerung",
"hrs": "%s Stunde(n)",
},
};

View File

@@ -13,7 +13,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart';
import 'package:refilc_mobile_ui/screens/settings/settings_screen.i18n.dart';
import 'package:refilc_mobile_ui/common/beta_chip.dart';
import 'package:refilc_mobile_ui/common/chips/beta_chip.dart';
class MenuDesktopSettings extends StatelessWidget {
const MenuDesktopSettings({super.key, required this.settings});

Some files were not shown because too many files have changed in this diff Show More