Compare commits
256 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee0e724b8a | ||
|
|
d6e783f375 | ||
|
|
1e89359333 | ||
|
|
24f8804f60 | ||
|
|
300b951014 | ||
|
|
8b49007cca | ||
|
|
4101dc7c17 | ||
|
|
939cc6bbe2 | ||
|
|
13e00f8462 | ||
|
|
7d89ea0f5d | ||
|
|
fe4d7b318e | ||
|
|
0464624648 | ||
|
|
d09f3772a3 | ||
|
|
a7ff9e7825 | ||
|
|
bc3f8cfff9 | ||
|
|
063cc99d1a | ||
|
|
739e75160d | ||
|
|
889d0d6057 | ||
|
|
f5a7820991 | ||
|
|
580f93fa6f | ||
|
|
654c12e9fb | ||
|
|
7ab14756a6 | ||
|
|
0a02d4e831 | ||
|
|
ac3429f30f | ||
|
|
6388650c77 | ||
|
|
728534170c | ||
|
|
f4d840462e | ||
|
|
b08b127895 | ||
|
|
d41872e6e2 | ||
|
|
0602c2ea3f | ||
|
|
afcff10862 | ||
|
|
9e187fc04c | ||
|
|
7d5b97fe00 | ||
|
|
fd3b21b8e6 | ||
|
|
071f682f77 | ||
|
|
8723f75889 | ||
|
|
c9666f5333 | ||
|
|
a218b62742 | ||
|
|
41b1d899d0 | ||
|
|
ad18efd340 | ||
|
|
cf0dc50df5 | ||
|
|
994d3085bb | ||
|
|
6292708ba0 | ||
|
|
a26ca67892 | ||
|
|
f2d6b6079e | ||
|
|
4faee05823 | ||
|
|
864701fd1e | ||
|
|
80d50cd82b | ||
|
|
521f609707 | ||
|
|
96ff70d7d5 | ||
|
|
658bfe38a3 | ||
|
|
a74b2cd3d7 | ||
|
|
414755c777 | ||
|
|
3708b917c4 | ||
|
|
986b13de68 | ||
|
|
d391448870 | ||
|
|
38d9b5f3b2 | ||
|
|
2dafe5ed02 | ||
|
|
939761695f | ||
|
|
f1ba5230fc | ||
|
|
a50f449f7c | ||
|
|
fe3ed31830 | ||
|
|
0ec33f8631 | ||
|
|
6634010b97 | ||
|
|
816ddf58a2 | ||
|
|
d7741ca1c4 | ||
|
|
a2cbe5d90b | ||
|
|
7919d0e284 | ||
|
|
92fe3b7dcd | ||
|
|
63fd37c31f | ||
|
|
aa10f0672e | ||
|
|
a3694b59ec | ||
|
|
9ecee0bb01 | ||
|
|
b9e9bef182 | ||
|
|
51297ddc09 | ||
|
|
4d64705e59 | ||
|
|
d642f19834 | ||
|
|
51b25395c1 | ||
|
|
4474562538 | ||
|
|
d93dce7857 | ||
|
|
d6fe2812c7 | ||
|
|
ed0f69d155 | ||
|
|
c4a17633f8 | ||
|
|
d426d4866a | ||
|
|
89adf5a26f | ||
|
|
117ee63b18 | ||
|
|
d27b5f8a51 | ||
|
|
9671c250b9 | ||
|
|
2d5c270641 | ||
|
|
eda093a9b5 | ||
|
|
544e9c214a | ||
|
|
5c3dbcbd52 | ||
|
|
cd5f86db00 | ||
|
|
9adfe636d6 | ||
|
|
210e8ce0d4 | ||
|
|
b1a7deca4a | ||
|
|
fa96770c9c | ||
|
|
5be67693c2 | ||
|
|
9ee5e8a35e | ||
|
|
3372c1ffde | ||
|
|
94989687fa | ||
|
|
52b9b4f5db | ||
|
|
75a2fa3726 | ||
|
|
2c1bde9398 | ||
|
|
fd9794f3bf | ||
|
|
a673d3f1b3 | ||
|
|
f2c8e869b5 | ||
|
|
b4f2d38e99 | ||
|
|
d842b2d588 | ||
|
|
f4fd9a3c2f | ||
|
|
a215bd7313 | ||
|
|
3211279a53 | ||
|
|
2d4e281682 | ||
|
|
148f945f3b | ||
|
|
aaa783ac45 | ||
|
|
d70f92d4e5 | ||
|
|
0f08400d63 | ||
|
|
140a8f8e78 | ||
|
|
17c9d1c447 | ||
|
|
d8e23d8fa9 | ||
|
|
c4491eb0c6 | ||
|
|
4945468e02 | ||
|
|
9845ae9539 | ||
|
|
3a2fc67cb2 | ||
|
|
148a43663c | ||
|
|
4a45131359 | ||
|
|
4128018a59 | ||
|
|
0d509c90b1 | ||
|
|
3ef58974c9 | ||
|
|
df75fadfea | ||
|
|
4254a7998a | ||
|
|
17faa545e5 | ||
|
|
506fb82dd0 | ||
|
|
bc8eb1910e | ||
|
|
fd1b15df77 | ||
|
|
dd86c7436a | ||
|
|
8860a0269c | ||
|
|
ce02dda46c | ||
|
|
f16a52d0fb | ||
|
|
cc8ce40222 | ||
|
|
b6a933fe85 | ||
|
|
767eba3776 | ||
|
|
320499a466 | ||
|
|
52c2f3090d | ||
|
|
d4df0170a3 | ||
|
|
796b35e27c | ||
|
|
051cdc895e | ||
|
|
e23bdac995 | ||
|
|
de0e8e1317 | ||
|
|
b5b0046ef5 | ||
|
|
92f16e054d | ||
|
|
9470c848bf | ||
|
|
c40026e594 | ||
|
|
93eaa5a74b | ||
|
|
5503b41be3 | ||
|
|
bd716e1717 | ||
|
|
7f8b716712 | ||
|
|
1a7b59f2fc | ||
|
|
9f62e44b52 | ||
|
|
7c34552aa5 | ||
|
|
57d784443a | ||
|
|
e73ee5a1f2 | ||
|
|
4277f0662a | ||
|
|
604e9dcaad | ||
|
|
c0dd84c665 | ||
|
|
7dc33d3b87 | ||
|
|
9bee0daeb5 | ||
|
|
dd8a4430a9 | ||
|
|
47934620ea | ||
|
|
9e815aff2f | ||
|
|
d8393b24e1 | ||
|
|
1abe990847 | ||
|
|
3a92716019 | ||
|
|
9b947256c8 | ||
|
|
0586da3742 | ||
|
|
9d863e1ec0 | ||
|
|
e080800aa8 | ||
|
|
e6f7728e42 | ||
|
|
ac11da1744 | ||
|
|
cad7bd19dc | ||
|
|
e1870b08e5 | ||
|
|
7842aa447f | ||
|
|
a23b2d63e5 | ||
|
|
58faeb4fa2 | ||
|
|
48e64d7761 | ||
|
|
aef8f78d16 | ||
|
|
2b36528327 | ||
|
|
918252ae4b | ||
|
|
63c650b68d | ||
|
|
090b0ccc85 | ||
|
|
0768dc9404 | ||
|
|
d36351d76b | ||
|
|
45a8e0dd71 | ||
|
|
94da2a9756 | ||
|
|
37aa1858a8 | ||
|
|
82f8a489dd | ||
|
|
96b69b89ae | ||
|
|
d9da7625ed | ||
|
|
c016258fb9 | ||
|
|
855e48aea8 | ||
|
|
b7e83d10dc | ||
|
|
45ffdff324 | ||
|
|
cd0729fa5e | ||
|
|
30cfdfe784 | ||
|
|
16f2593d22 | ||
|
|
14ab0c4ce3 | ||
|
|
9eb1317143 | ||
|
|
910a38650d | ||
|
|
a1f166980d | ||
|
|
0598b94ab9 | ||
|
|
1310ad4f2e | ||
|
|
4d32500d90 | ||
|
|
67558b76a3 | ||
|
|
7ab8914076 | ||
|
|
b0eb819afa | ||
|
|
416f42f42d | ||
|
|
a319b26d82 | ||
|
|
84537fdcef | ||
|
|
30f24d5d33 | ||
|
|
8c118eedc1 | ||
|
|
4dbe3d07a3 | ||
|
|
f1b1b23234 | ||
|
|
540e4d2812 | ||
|
|
93dd275969 | ||
|
|
c79c45705d | ||
|
|
ce31182a5c | ||
|
|
174046f954 | ||
|
|
3fc14ffbb8 | ||
|
|
f579270886 | ||
|
|
365bd7957e | ||
|
|
d24c4ec187 | ||
|
|
75ba5405bb | ||
|
|
e0bf8ac5e5 | ||
|
|
1a3d78a5bc | ||
|
|
c205bc592c | ||
|
|
308c8f966f | ||
|
|
139ac28be6 | ||
|
|
bbe53b8c01 | ||
|
|
56a0c2c02e | ||
|
|
122a5ea210 | ||
|
|
aaa3d79b30 | ||
|
|
cacf566794 | ||
|
|
9b29ede6eb | ||
|
|
9e9e46d0f8 | ||
|
|
9901251cfc | ||
|
|
e7ec93132d | ||
|
|
7cec2ff525 | ||
|
|
2ca8f4b8fe | ||
|
|
ae66a462e7 | ||
|
|
c85f15eb49 | ||
|
|
e04cc5ea2b | ||
|
|
3ed456c01f | ||
|
|
f64b1360d9 | ||
|
|
c9db496e59 | ||
|
|
d915200faa | ||
|
|
32abfe7037 |
9
.gitignore
vendored
@@ -12,10 +12,10 @@ refilc/build/
|
||||
refilc/android/key.properties
|
||||
refilc/android/debug.keystore
|
||||
|
||||
refilc_desktop_ui/.flutter-plugins
|
||||
refilc_desktop_ui/.flutter-plugins-dependencies
|
||||
refilc_desktop_ui/pubspec.lock
|
||||
refilc_desktop_ui/.dart_tool/
|
||||
# refilc_desktop_ui/.flutter-plugins
|
||||
# refilc_desktop_ui/.flutter-plugins-dependencies
|
||||
# refilc_desktop_ui/pubspec.lock
|
||||
# refilc_desktop_ui/.dart_tool/
|
||||
|
||||
refilc_kreta_api/.flutter-plugins
|
||||
refilc_kreta_api/.flutter-plugins-dependencies
|
||||
@@ -37,6 +37,7 @@ refilc_mobile_ui/.dart_tool/
|
||||
.idea
|
||||
.gitmodules
|
||||
.gradle
|
||||
.kotlin
|
||||
|
||||
refilc/.DS_Store
|
||||
.DS_Store
|
||||
|
||||
56
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
ANDROID_SDK = '/home/jenkins/flutter_things/android-sdk'
|
||||
ANDROID_PATH="$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools"
|
||||
FLUTTER = '/home/jenkins/flutter_things/flutter/bin'
|
||||
PATH = "$PATH:$ANDROID_PATH:$FLUTTER"
|
||||
//TODO: need to fix flutter
|
||||
}
|
||||
|
||||
|
||||
stages {
|
||||
stage('Copy Key Properties') {
|
||||
steps {
|
||||
// Copy the key.properties file
|
||||
sh 'cp /home/jenkins/key.properties refilc/android/key.properties'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Flutter Doctor') {
|
||||
steps {
|
||||
// Ensure Flutter is set up correctly
|
||||
sh 'flutter doctor'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Dependencies') {
|
||||
steps {
|
||||
// Get Flutter dependencies
|
||||
sh 'cd refilc && flutter pub get'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
// Build the Flutter project
|
||||
sh 'cd refilc && flutter build apk --release'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Archive') {
|
||||
steps {
|
||||
// Archive the APK
|
||||
archiveArtifacts artifacts: 'build/app/outputs/flutter-apk/app-release.apk', fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
// Clean up workspace after build
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
7
check-outdated.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
cd refilc && flutter pub outdated && cd ..
|
||||
cd refilc_kreta_api && flutter pub outdated && cd ..
|
||||
cd refilc_mobile_ui && flutter pub outdated && cd ..
|
||||
# cd refilc_desktop_ui && flutter pub upgrade && cd ..
|
||||
cd refilc_plus && flutter pub outdated && cd ..
|
||||
|
||||
echo Outdated version list above.
|
||||
7
major-upgrade-pub.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
cd refilc && flutter pub upgrade --major-versions && cd ..
|
||||
cd refilc_kreta_api && flutter pub upgrade --major-versions && cd ..
|
||||
cd refilc_mobile_ui && flutter pub upgrade --major-versions && cd ..
|
||||
# cd refilc_desktop_ui && flutter pub upgrade && cd ..
|
||||
cd refilc_plus && flutter pub upgrade --major-versions && cd ..
|
||||
|
||||
echo "Upgraded pub (major)."
|
||||
2
refilc/.gitignore
vendored
@@ -5,9 +5,11 @@
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.build/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
.swiftpm/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
|
||||
@@ -40,7 +40,9 @@ def debugKeystorePropertiesFile = rootProject.file("debugkey.properties")
|
||||
debugKeystoreProperties.load(new FileInputStream(debugKeystorePropertiesFile))
|
||||
|
||||
android {
|
||||
ndkVersion "25.1.8937393"
|
||||
namespace = "hu.refilc.naplo"
|
||||
|
||||
ndkVersion "27.2.12479018"
|
||||
|
||||
// compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
compileSdkVersion 34
|
||||
@@ -58,7 +60,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "hu.refilc.naplo"
|
||||
minSdkVersion 21
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 34
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
@@ -67,11 +69,19 @@ android {
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
// Flag to enable support for the new language APIs
|
||||
coreLibraryDesugaringEnabled true
|
||||
// Sets Java compatibility to Java 8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
// Flag to enable support for the new language APIs
|
||||
coreLibraryDesugaringEnabled true
|
||||
// Sets Java compatibility to Java 8
|
||||
// sourceCompatibility JavaVersion.VERSION_1_8
|
||||
// targetCompatibility JavaVersion.VERSION_1_8
|
||||
// sourceCompatibility JavaVersion.VERSION_21
|
||||
// targetCompatibility JavaVersion.VERSION_21
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -117,7 +127,7 @@ dependencies {
|
||||
implementation 'joda-time:joda-time:2.9.4'
|
||||
androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
|
||||
implementation 'androidx.window:window:1.0.0'
|
||||
implementation 'androidx.window:window-java:1.0.0'
|
||||
}
|
||||
|
||||
5
refilc/android/app/proguard-rules.pro
vendored
@@ -8,4 +8,7 @@
|
||||
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args
|
||||
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error
|
||||
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
|
||||
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
|
||||
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
|
||||
|
||||
-dontwarn org.joda.convert.FromString
|
||||
-dontwarn org.joda.convert.ToString
|
||||
@@ -2,9 +2,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools" package="hu.refilc.naplo">
|
||||
<application android:name="${applicationName}" android:label="reFilc" tools:replace="android:label" android:icon="@mipmap/ic_launcher"
|
||||
android:requestLegacyExternalStorage="true" android:enableOnBackInvokedCallback="false">
|
||||
<service
|
||||
android:name="com.solusibejo.flutter_dynamic_icon_plus.FlutterDynamicIconPlusService"
|
||||
android:stopWithTask="false"/>
|
||||
|
||||
<activity android:exported="true" android:name="hu.refilc.naplo.MainActivity"
|
||||
android:launchMode="singleTop" android:theme="@style/LaunchTheme"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
android:gravity="center"
|
||||
android:text="1."
|
||||
android:textColor="@color/filc"
|
||||
android:textColorLink="#ff3D7BF4"
|
||||
android:textColorLink="#ff052460"
|
||||
android:textSize="30sp"
|
||||
android:textStyle="bold"
|
||||
tools:ignore="HardcodedText" />
|
||||
@@ -110,4 +110,4 @@
|
||||
android:textColor="@color/white"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<color name="yellow_light">#ffFFCC00</color>
|
||||
<color name="light_yellow_light">#40FFD60A</color>
|
||||
<color name="green_light">#ff34C759</color>
|
||||
<color name="filc_light">#ff3D7BF4</color>
|
||||
<color name="filc_light">#ff052460</color>
|
||||
<color name="teal_light">#ff5AC8FA</color>
|
||||
<color name="blue_light">#ff007AFF</color>
|
||||
<color name="indigo_light">#ff5856D6</color>
|
||||
@@ -49,8 +49,8 @@
|
||||
<color name="yellow">#ffFFD60A</color>
|
||||
<color name="light_yellow">#40FFD60A</color>
|
||||
<color name="green">#ff32D74B</color>
|
||||
<color name="filc">#ff3D7BF4</color>
|
||||
<color name="filc_gradient">#ff3D93F5</color>
|
||||
<color name="filc">#ff052460</color>
|
||||
<color name="filc_gradient">#ff06348f</color>
|
||||
<color name="teal">#ff64D2FF</color>
|
||||
<color name="blue">#ff0A84FF</color>
|
||||
<color name="indigo">#ff5E5CE6</color>
|
||||
@@ -66,4 +66,4 @@
|
||||
<color name="pink_shade300">#FFF06292</color>
|
||||
<color name="purple_shade300">#FFBA68C8</color>
|
||||
<color name="teal_shade300">#FF22AC9B</color>
|
||||
</resources>
|
||||
</resources>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
org.gradle.jvmargs=-Xmx1536M \
|
||||
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
|
||||
--add-opens=java.base/java.lang=ALL-UNNAMED \
|
||||
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
|
||||
--add-opens=java.base/java.io=ALL-UNNAMED \
|
||||
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
|
||||
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
# kotlin.jvm.target.validation.mode=IGNORE
|
||||
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
|
||||
|
||||
@@ -24,8 +24,8 @@ pluginManagement {
|
||||
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "7.1.1" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.8.21" apply false
|
||||
id "com.android.application" version "8.7.3" apply false
|
||||
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
|
||||
}
|
||||
|
||||
include ":app"
|
||||
|
||||
BIN
refilc/assets/images/apple_fire_emoji.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
refilc/assets/images/btn_kreten_login.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 364 KiB After Width: | Height: | Size: 696 KiB |
|
Before Width: | Height: | Size: 581 KiB After Width: | Height: | Size: 616 KiB |
|
Before Width: | Height: | Size: 982 KiB After Width: | Height: | Size: 1009 KiB |
|
Before Width: | Height: | Size: 330 KiB After Width: | Height: | Size: 549 KiB |
43
refilc/assets/svg/cover_arts/grid.svg
Normal file
@@ -0,0 +1,43 @@
|
||||
<svg width="375" height="174" viewBox="0 0 375 174" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_1575_5258)">
|
||||
<g style="mix-blend-mode:color-burn">
|
||||
<rect x="187.881" y="36.8047" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="238.186" y="36.8047" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="187.881" y="-13.5" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="238.186" y="-13.5" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="288.49" y="36.8047" width="49.3049" height="50.4482" stroke="#858585"/>
|
||||
<rect x="337.652" y="36.8047" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="288.49" y="-13.5" width="49.3049" height="50.4482" stroke="#858585"/>
|
||||
<rect x="337.652" y="-13.5" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="187.881" y="136.271" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="238.186" y="136.271" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="187.881" y="87.1099" width="50.4482" height="49.3049" stroke="#858585"/>
|
||||
<rect x="238.186" y="87.1099" width="50.4482" height="49.3049" stroke="#858585"/>
|
||||
<rect x="288.49" y="136.271" width="49.3049" height="50.4482" stroke="#858585"/>
|
||||
<rect x="337.652" y="136.271" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="288.49" y="87.1099" width="49.3049" height="49.3049" stroke="#858585"/>
|
||||
<rect x="337.652" y="87.1099" width="50.4482" height="49.3049" stroke="#858585"/>
|
||||
<rect x="-12.1953" y="36.8047" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="-12.1953" y="-13.5" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="38.1094" y="36.8047" width="49.3049" height="50.4482" stroke="#858585"/>
|
||||
<rect x="87.2705" y="36.8047" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="38.1094" y="-13.5" width="49.3049" height="50.4482" stroke="#858585"/>
|
||||
<rect x="87.2705" y="-13.5" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="-12.1953" y="136.271" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="-12.1953" y="87.1099" width="50.4482" height="49.3049" stroke="#858585"/>
|
||||
<rect x="38.1094" y="136.271" width="49.3049" height="50.4482" stroke="#858585"/>
|
||||
<rect x="87.2705" y="136.271" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="38.1094" y="87.1099" width="49.3049" height="49.3049" stroke="#858585"/>
|
||||
<rect x="87.2705" y="87.1099" width="50.4482" height="49.3049" stroke="#858585"/>
|
||||
<rect x="137.576" y="36.8047" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="137.576" y="-13.5" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="137.576" y="136.271" width="50.4482" height="50.4482" stroke="#858585"/>
|
||||
<rect x="137.576" y="87.1099" width="50.4482" height="49.3049" stroke="#858585"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_1575_5258">
|
||||
<rect width="375" height="173.78" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
27
refilc/assets/svg/cover_arts/line.svg
Normal file
@@ -0,0 +1,27 @@
|
||||
<svg width="375" height="175" viewBox="0 0 375 175" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_1575_5259)">
|
||||
<g style="mix-blend-mode:color-burn">
|
||||
<mask id="path-1-inside-1_1575_5259" fill="white">
|
||||
<path d="M0 37H375V89H0V37Z"/>
|
||||
</mask>
|
||||
<path d="M0 38H375V36H0V38Z" fill="#858585" mask="url(#path-1-inside-1_1575_5259)"/>
|
||||
<mask id="path-3-inside-2_1575_5259" fill="white">
|
||||
<path d="M0 -13H375V38H0V-13Z"/>
|
||||
</mask>
|
||||
<path d="M0 -12H375V-14H0V-12Z" fill="#858585" mask="url(#path-3-inside-2_1575_5259)"/>
|
||||
<mask id="path-5-inside-3_1575_5259" fill="white">
|
||||
<path d="M0 137H375V188H0V137Z"/>
|
||||
</mask>
|
||||
<path d="M0 138H375V136H0V138Z" fill="#858585" mask="url(#path-5-inside-3_1575_5259)"/>
|
||||
<mask id="path-7-inside-4_1575_5259" fill="white">
|
||||
<path d="M0 87H375V138H0V87Z"/>
|
||||
</mask>
|
||||
<path d="M0 88H375V86H0V88Z" fill="#858585" mask="url(#path-7-inside-4_1575_5259)"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_1575_5259">
|
||||
<rect width="375" height="173.78" fill="white" transform="translate(0 0.780518)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
47
refilc/assets/svg/cover_arts/plain.svg
Normal file
@@ -0,0 +1,47 @@
|
||||
<svg width="375" height="175" viewBox="0 0 375 175" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_1575_5260)">
|
||||
<g style="mix-blend-mode:color-burn">
|
||||
<circle cx="17" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="59" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="101" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="143" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="185" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="227" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="269" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="311" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="353" cy="19.561" r="1" fill="#858585"/>
|
||||
<circle cx="17" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="59" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="101" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="143" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="185" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="227" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="269" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="311" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="353" cy="61.561" r="1" fill="#858585"/>
|
||||
<circle cx="17" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="59" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="101" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="143" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="185" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="227" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="269" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="311" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="353" cy="103.561" r="1" fill="#858585"/>
|
||||
<circle cx="17" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="59" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="101" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="143" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="185" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="227" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="269" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="311" cy="145.561" r="1" fill="#858585"/>
|
||||
<circle cx="353" cy="145.561" r="1" fill="#858585"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_1575_5260">
|
||||
<rect width="375" height="173.78" fill="white" transform="translate(0 0.561035)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
28
refilc/assets/svg/cover_arts/vocal.svg
Normal file
@@ -0,0 +1,28 @@
|
||||
<svg width="375" height="175" viewBox="0 0 375 175" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_1575_5261)">
|
||||
<g style="mix-blend-mode:color-burn">
|
||||
<path d="M0 63.0001H375" stroke="#858585"/>
|
||||
<path d="M0 75.0001H375" stroke="#858585"/>
|
||||
<path d="M0 87.0001H375" stroke="#858585"/>
|
||||
<path d="M0 99.0001H375" stroke="#858585"/>
|
||||
<path d="M0 111H375" stroke="#858585"/>
|
||||
</g>
|
||||
<g style="mix-blend-mode:color-burn">
|
||||
<path d="M0 135H375" stroke="#858585"/>
|
||||
<path d="M0 147H375" stroke="#858585"/>
|
||||
<path d="M0 159H375" stroke="#858585"/>
|
||||
<path d="M0 171H375" stroke="#858585"/>
|
||||
</g>
|
||||
<g style="mix-blend-mode:color-burn">
|
||||
<path d="M0 3.00012H375" stroke="#858585"/>
|
||||
<path d="M0 15.0001H375" stroke="#858585"/>
|
||||
<path d="M0 27.0001H375" stroke="#858585"/>
|
||||
<path d="M0 39.0001H375" stroke="#858585"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_1575_5261">
|
||||
<rect width="375" height="173.78" fill="white" transform="translate(0 0.341431)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 973 B |
@@ -1,43 +0,0 @@
|
||||
<svg width="375" height="174" viewBox="0 0 375 174" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_581_2504)">
|
||||
<g style="mix-blend-mode:color-burn">
|
||||
<rect x="138.881" y="36.8047" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="189.186" y="36.8047" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="138.881" y="-13.5" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="189.186" y="-13.5" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="239.49" y="36.8047" width="49.3049" height="50.4482" stroke="black"/>
|
||||
<rect x="288.652" y="36.8047" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="239.49" y="-13.5" width="49.3049" height="50.4482" stroke="black"/>
|
||||
<rect x="288.652" y="-13.5" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="138.881" y="136.271" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="189.186" y="136.271" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="138.881" y="87.1099" width="50.4482" height="49.3049" stroke="black"/>
|
||||
<rect x="189.186" y="87.1099" width="50.4482" height="49.3049" stroke="black"/>
|
||||
<rect x="239.49" y="136.271" width="49.3049" height="50.4482" stroke="black"/>
|
||||
<rect x="288.652" y="136.271" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="239.49" y="87.1099" width="49.3049" height="49.3049" stroke="black"/>
|
||||
<rect x="288.652" y="87.1099" width="50.4482" height="49.3049" stroke="black"/>
|
||||
<rect x="338.957" y="36.8047" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="338.957" y="-13.5" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="338.957" y="136.271" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="338.957" y="87.1099" width="50.4482" height="49.3049" stroke="black"/>
|
||||
<rect x="-10.8906" y="36.8047" width="49.3049" height="50.4482" stroke="black"/>
|
||||
<rect x="38.2705" y="36.8047" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="-10.8906" y="-13.5" width="49.3049" height="50.4482" stroke="black"/>
|
||||
<rect x="38.2705" y="-13.5" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="-10.8906" y="136.271" width="49.3049" height="50.4482" stroke="black"/>
|
||||
<rect x="38.2705" y="136.271" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="-10.8906" y="87.1099" width="49.3049" height="49.3049" stroke="black"/>
|
||||
<rect x="38.2705" y="87.1099" width="50.4482" height="49.3049" stroke="black"/>
|
||||
<rect x="88.5762" y="36.8047" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="88.5762" y="-13.5" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="88.5762" y="136.271" width="50.4482" height="50.4482" stroke="black"/>
|
||||
<rect x="88.5762" y="87.1099" width="50.4482" height="49.3049" stroke="black"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_581_2504">
|
||||
<rect width="375" height="173.78" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.8 KiB |
0
refilc/build.sh
Normal file → Executable 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
|
||||
|
||||
@@ -517,9 +517,11 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
DEVELOPMENT_TEAM = 4DKAF249F3;
|
||||
CURRENT_PROJECT_VERSION = 282;
|
||||
DEVELOPMENT_TEAM = 4J97JVC2FG;
|
||||
ENABLE_BITCODE = NO;
|
||||
FLUTTER_BUILD_NAME = 5.1.0;
|
||||
FLUTTER_BUILD_NUMBER = 282;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = reFilc;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education";
|
||||
@@ -527,8 +529,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 +551,8 @@
|
||||
CODE_SIGN_ENTITLEMENTS = livecard/livecard.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
DEVELOPMENT_TEAM = 4DKAF249F3;
|
||||
CURRENT_PROJECT_VERSION = 282;
|
||||
DEVELOPMENT_TEAM = 4J97JVC2FG;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = livecard/Info.plist;
|
||||
@@ -563,10 +565,10 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.0.0;
|
||||
MARKETING_VERSION = 5.1.0;
|
||||
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 +593,8 @@
|
||||
CODE_SIGN_ENTITLEMENTS = livecard/livecard.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
DEVELOPMENT_TEAM = 4DKAF249F3;
|
||||
CURRENT_PROJECT_VERSION = 282;
|
||||
DEVELOPMENT_TEAM = 4J97JVC2FG;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = livecard/Info.plist;
|
||||
@@ -605,9 +607,9 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.0.0;
|
||||
MARKETING_VERSION = 5.1.0;
|
||||
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 +633,8 @@
|
||||
CODE_SIGN_ENTITLEMENTS = livecard/livecard.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
DEVELOPMENT_TEAM = 4DKAF249F3;
|
||||
CURRENT_PROJECT_VERSION = 282;
|
||||
DEVELOPMENT_TEAM = 4J97JVC2FG;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = livecard/Info.plist;
|
||||
@@ -645,9 +647,9 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 5.0.0;
|
||||
MARKETING_VERSION = 5.1.0;
|
||||
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,9 +777,11 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
DEVELOPMENT_TEAM = 4DKAF249F3;
|
||||
CURRENT_PROJECT_VERSION = 282;
|
||||
DEVELOPMENT_TEAM = 4J97JVC2FG;
|
||||
ENABLE_BITCODE = NO;
|
||||
FLUTTER_BUILD_NAME = 5.1.0;
|
||||
FLUTTER_BUILD_NUMBER = 282;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = reFilc;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education";
|
||||
@@ -785,8 +789,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,9 +807,11 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
DEVELOPMENT_TEAM = 4DKAF249F3;
|
||||
CURRENT_PROJECT_VERSION = 282;
|
||||
DEVELOPMENT_TEAM = 4J97JVC2FG;
|
||||
ENABLE_BITCODE = NO;
|
||||
FLUTTER_BUILD_NAME = 5.1.0;
|
||||
FLUTTER_BUILD_NUMBER = 282;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = reFilc;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education";
|
||||
@@ -813,8 +819,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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<key>livecard.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>83</integer>
|
||||
<integer>86</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
||||
@@ -3,7 +3,7 @@ import background_fetch
|
||||
import ActivityKit
|
||||
import Flutter
|
||||
|
||||
@UIApplicationMain
|
||||
@main
|
||||
@objc class AppDelegate: FlutterAppDelegate {
|
||||
private var methodChannel: FlutterMethodChannel?
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "reFilc_Logo.png",
|
||||
"filename" : "rf_1024.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
|
||||
|
Before Width: | Height: | Size: 577 KiB |
BIN
refilc/ios/Runner/Assets.xcassets/AppIcon.appiconset/rf_1024.png
Normal file
|
After Width: | Height: | Size: 180 KiB |
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +52,23 @@ struct LockScreenLiveActivityView: View {
|
||||
VStack(alignment: .center) {
|
||||
// Jelenlegi óra
|
||||
VStack {
|
||||
Text(context.state.index + " " + context.state.title)
|
||||
.font(.body)
|
||||
.bold()
|
||||
.multilineTextAlignment(.center)
|
||||
if(context.state.title.contains("Az első órádig")) {
|
||||
Text(context.state.title)
|
||||
.font(.system(size: 15))
|
||||
.bold()
|
||||
.multilineTextAlignment(.center)
|
||||
} else if(context.state.title == "Szünet") {
|
||||
Text(context.state.title)
|
||||
.font(.body)
|
||||
.bold()
|
||||
.padding(.trailing, 90)
|
||||
|
||||
Text("Terem: \(context.state.subtitle)")
|
||||
.italic()
|
||||
.font(.caption)
|
||||
} else {
|
||||
MultilineTextView(text: "\(context.state.index) \(context.state.title) - \(context.state.subtitle)", limit: 25)
|
||||
.font(.body)
|
||||
.bold()
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
|
||||
// Leírás
|
||||
@@ -69,29 +78,34 @@ struct LockScreenLiveActivityView: View {
|
||||
}
|
||||
|
||||
// Következő óra
|
||||
if(context.state.nextSubject != "" && context.state.nextRoom != "") {
|
||||
HStack {
|
||||
Image(systemName: "arrow.right")
|
||||
.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 {
|
||||
Spacer(minLength: 5)
|
||||
Text("Ez az utolsó óra! Kitartást!")
|
||||
.font(.system(size: 15))
|
||||
}
|
||||
|
||||
}
|
||||
.padding(15)
|
||||
|
||||
Spacer()
|
||||
|
||||
|
||||
// Visszaszámláló
|
||||
Text(timerInterval: context.state.date, countsDown: true)
|
||||
.multilineTextAlignment(.center)
|
||||
.frame(width: 85)
|
||||
.font(.title2)
|
||||
.monospacedDigit()
|
||||
.padding(.trailing, CGFloat(24))
|
||||
.padding(.trailing)
|
||||
}
|
||||
.activityBackgroundTint(
|
||||
context.state.color != "#676767"
|
||||
@@ -109,7 +123,7 @@ struct LiveCardWidget: Widget {
|
||||
LockScreenLiveActivityView(context: context)
|
||||
/// Dynamic Island
|
||||
} dynamicIsland: { context in
|
||||
|
||||
|
||||
/// Expanded
|
||||
return DynamicIsland {
|
||||
DynamicIslandExpandedRegion(.leading) {
|
||||
@@ -133,39 +147,85 @@ struct LiveCardWidget: Widget {
|
||||
).progressViewStyle(.circular)
|
||||
}
|
||||
}
|
||||
DynamicIslandExpandedRegion(.center) {
|
||||
VStack(alignment: .center) {
|
||||
Text(context.state.index + context.state.title)
|
||||
.lineLimit(1)
|
||||
.font(.body)
|
||||
.bold()
|
||||
|
||||
Text(context.state.subtitle)
|
||||
.lineLimit(1)
|
||||
.font(.subheadline)
|
||||
Spacer()
|
||||
|
||||
Text(context.state.description)
|
||||
.lineLimit(2)
|
||||
.font(.caption)
|
||||
}.padding(EdgeInsets(top: 0.0, leading: 5.0, bottom: 0.0, trailing: 0.0))
|
||||
}
|
||||
DynamicIslandExpandedRegion(.center) {
|
||||
VStack(alignment: .center) {
|
||||
// Első óra előtti expanded DynamicIsland
|
||||
if(context.state.title.contains("Az első órádig")) {
|
||||
Text("Az első órád:")
|
||||
.font(.body)
|
||||
.bold()
|
||||
.padding(.trailing, -15)
|
||||
MultilineTextView(text: "\(context.state.nextSubject)", limit: 25)
|
||||
.font(.body)
|
||||
.padding(.trailing, -25)
|
||||
|
||||
Text("Ebben a teremben:")
|
||||
.font(.body)
|
||||
.bold()
|
||||
.padding(.leading, 15)
|
||||
Text(context.state.nextRoom)
|
||||
.font(.body)
|
||||
.padding(.leading, 15)
|
||||
} else if(context.state.title == "Szünet") {
|
||||
// Amikor szünet van, expanded DynamicIsland
|
||||
Text(context.state.title)
|
||||
.lineLimit(1)
|
||||
.font(.body)
|
||||
.bold()
|
||||
.padding(.leading, 15)
|
||||
|
||||
Spacer(minLength: 5)
|
||||
Text("Következő óra és terem:")
|
||||
.font(.system(size: 13))
|
||||
.padding(.leading, 25)
|
||||
Text(context.state.nextSubject)
|
||||
.font(.caption)
|
||||
.padding(.leading, 15)
|
||||
Text(context.state.nextRoom)
|
||||
.font(.caption2)
|
||||
.padding(.leading, 15)
|
||||
|
||||
} else {
|
||||
// Amikor óra van, expanded DynamicIsland
|
||||
MultilineTextView(text: "\(context.state.index) \(context.state.title) - \(context.state.subtitle)", limit: 25)
|
||||
.lineLimit(1)
|
||||
.font(.body)
|
||||
.bold()
|
||||
.padding(.trailing, -35)
|
||||
|
||||
Spacer(minLength: 2)
|
||||
|
||||
if(context.state.nextRoom != "" && context.state.nextSubject != "") {
|
||||
Text("Következő óra és terem:")
|
||||
.font(.system(size: 14))
|
||||
.padding(.trailing, -45)
|
||||
Spacer(minLength: 2)
|
||||
|
||||
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))
|
||||
.padding(.trailing, -30)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}.padding(EdgeInsets(top: 0.0, leading: 5.0, bottom: 0.0, trailing: 0.0))
|
||||
|
||||
}
|
||||
|
||||
/// Compact
|
||||
} compactLeading: {
|
||||
Label {
|
||||
Text(context.state.title)
|
||||
} icon: {
|
||||
Image(systemName: context.state.icon)
|
||||
}
|
||||
.font(.caption2)
|
||||
Image(systemName: context.state.icon)
|
||||
}
|
||||
compactTrailing: {
|
||||
Text(timerInterval: context.state.date, countsDown: true)
|
||||
.multilineTextAlignment(.center)
|
||||
.frame(width: 40)
|
||||
.font(.caption2)
|
||||
|
||||
|
||||
/// Collapsed
|
||||
} minimal: {
|
||||
VStack(alignment: .center, content: {
|
||||
@@ -191,7 +251,122 @@ struct LiveCardWidget: Widget {
|
||||
context.state.color != "#676767"
|
||||
? Color(hex: context.state.color)
|
||||
: Color.clear
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MultilineTextView: View {
|
||||
var text: String
|
||||
var limit: Int = 20 // default is 20 character
|
||||
|
||||
var body: some View {
|
||||
let words = text.split(separator: " ")
|
||||
var currentLine = ""
|
||||
var lines: [String] = []
|
||||
|
||||
for word in words {
|
||||
if (currentLine.count + word.count + 1) > limit {
|
||||
lines.append(currentLine)
|
||||
currentLine = ""
|
||||
}
|
||||
if !currentLine.isEmpty {
|
||||
currentLine += " "
|
||||
}
|
||||
currentLine += word
|
||||
}
|
||||
if !currentLine.isEmpty {
|
||||
lines.append(currentLine)
|
||||
}
|
||||
|
||||
return VStack(alignment: .center) {
|
||||
ForEach(lines, id: \.self) { line in
|
||||
Text(line)
|
||||
}
|
||||
Spacer(minLength: 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DynamicFontSizeModifier: ViewModifier {
|
||||
var text: String
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.font(.system(size: fontSize(for: text)))
|
||||
}
|
||||
|
||||
private func fontSize(for text: String) -> CGFloat {
|
||||
let length = text.count
|
||||
if length < 10 {
|
||||
return 12
|
||||
} else if length < 20 {
|
||||
return 12
|
||||
} else {
|
||||
return 11
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +354,8 @@ class FilcAPI {
|
||||
|
||||
if (res.statusCode == 200) {
|
||||
return (jsonDecode(res.body) as Map);
|
||||
} else if (res.statusCode == 404) {
|
||||
return {"public_id": ""};
|
||||
} else {
|
||||
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||
}
|
||||
@@ -373,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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,7 @@ class DatabaseProvider {
|
||||
Future<void> init() async {
|
||||
Database db;
|
||||
|
||||
if (Platform.isLinux || Platform.isWindows) {
|
||||
db = await databaseFactoryFfi.openDatabase("app.db");
|
||||
} else {
|
||||
db = await openDatabase("app.db");
|
||||
}
|
||||
db = await openDatabase("app.db");
|
||||
|
||||
query = DatabaseQuery(db: db);
|
||||
store = DatabaseStore(db: db);
|
||||
|
||||
@@ -88,24 +88,24 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
case LiveCardState.morning:
|
||||
return {
|
||||
"color":
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
"icon": nextLesson != null
|
||||
? SubjectIcon.resolveName(subject: nextLesson?.subject)
|
||||
: "book",
|
||||
"title": "Első órádig:",
|
||||
"title": "Jó reggelt! Az első órádig:",
|
||||
"subtitle": "",
|
||||
"description": "",
|
||||
"startDate": storeFirstRunDate != null
|
||||
? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) -
|
||||
(_delay.inMilliseconds))
|
||||
.toString()
|
||||
(_delay.inMilliseconds))
|
||||
.toString()
|
||||
: "",
|
||||
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||
_delay.inMilliseconds)
|
||||
_delay.inMilliseconds)
|
||||
.toString(),
|
||||
"nextSubject": nextLesson != null
|
||||
? nextLesson?.subject.renamedTo ??
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
: "",
|
||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||
};
|
||||
@@ -113,24 +113,24 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
case LiveCardState.afternoon:
|
||||
return {
|
||||
"color":
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
"icon": nextLesson != null
|
||||
? SubjectIcon.resolveName(subject: nextLesson?.subject)
|
||||
: "book",
|
||||
"title": "Első órádig:",
|
||||
"title": "Jó napot! Az első órádig:",
|
||||
"subtitle": "",
|
||||
"description": "",
|
||||
"startDate": storeFirstRunDate != null
|
||||
? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) -
|
||||
(_delay.inMilliseconds))
|
||||
.toString()
|
||||
(_delay.inMilliseconds))
|
||||
.toString()
|
||||
: "",
|
||||
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||
_delay.inMilliseconds)
|
||||
_delay.inMilliseconds)
|
||||
.toString(),
|
||||
"nextSubject": nextLesson != null
|
||||
? nextLesson?.subject.renamedTo ??
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
: "",
|
||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||
};
|
||||
@@ -138,24 +138,24 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
case LiveCardState.night:
|
||||
return {
|
||||
"color":
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
"icon": nextLesson != null
|
||||
? SubjectIcon.resolveName(subject: nextLesson?.subject)
|
||||
: "book",
|
||||
"title": "Első órádig:",
|
||||
"title": "Jó estét! Az első órádig:",
|
||||
"subtitle": "",
|
||||
"description": "",
|
||||
"startDate": storeFirstRunDate != null
|
||||
? ((storeFirstRunDate?.millisecondsSinceEpoch ?? 0) -
|
||||
(_delay.inMilliseconds))
|
||||
.toString()
|
||||
(_delay.inMilliseconds))
|
||||
.toString()
|
||||
: "",
|
||||
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||
_delay.inMilliseconds)
|
||||
_delay.inMilliseconds)
|
||||
.toString(),
|
||||
"nextSubject": nextLesson != null
|
||||
? nextLesson?.subject.renamedTo ??
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
: "",
|
||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||
};
|
||||
@@ -163,28 +163,28 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
case LiveCardState.duringLesson:
|
||||
return {
|
||||
"color":
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
"icon": currentLesson != null
|
||||
? SubjectIcon.resolveName(subject: currentLesson?.subject)
|
||||
: "book",
|
||||
"index":
|
||||
currentLesson != null ? '${currentLesson!.lessonIndex}. ' : "",
|
||||
currentLesson != null ? '${currentLesson!.lessonIndex}. ' : "",
|
||||
"title": currentLesson != null
|
||||
? currentLesson?.subject.renamedTo ??
|
||||
ShortSubject.resolve(subject: currentLesson?.subject)
|
||||
.capital()
|
||||
ShortSubject.resolve(subject: currentLesson?.subject)
|
||||
.capital()
|
||||
: "",
|
||||
"subtitle": currentLesson?.room.replaceAll("_", " ") ?? "",
|
||||
"subtitle": "Terem: ${currentLesson?.room.replaceAll("_", " ") ?? ""}",
|
||||
"description": currentLesson?.description ?? "",
|
||||
"startDate": ((currentLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||
_delay.inMilliseconds)
|
||||
_delay.inMilliseconds)
|
||||
.toString(),
|
||||
"endDate": ((currentLesson?.end.millisecondsSinceEpoch ?? 0) -
|
||||
_delay.inMilliseconds)
|
||||
_delay.inMilliseconds)
|
||||
.toString(),
|
||||
"nextSubject": nextLesson != null
|
||||
? nextLesson?.subject.renamedTo ??
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
ShortSubject.resolve(subject: nextLesson?.subject).capital()
|
||||
: "",
|
||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||
};
|
||||
@@ -200,23 +200,23 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
|
||||
return {
|
||||
"color":
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
'#${_settings.liveActivityColor.toString().substring(10, 16)}',
|
||||
"icon": iconFloorMap[diff] ?? "cup.and.saucer",
|
||||
"title": "Szünet",
|
||||
"description": "go $diff".i18n.fill([
|
||||
diff != "to room" ? (nextLesson!.getFloor() ?? 0) : nextLesson!.room
|
||||
]),
|
||||
"startDate": ((prevLesson?.end.millisecondsSinceEpoch ?? 0) -
|
||||
_delay.inMilliseconds)
|
||||
_delay.inMilliseconds)
|
||||
.toString(),
|
||||
"endDate": ((nextLesson?.start.millisecondsSinceEpoch ?? 0) -
|
||||
_delay.inMilliseconds)
|
||||
_delay.inMilliseconds)
|
||||
.toString(),
|
||||
"nextSubject": (nextLesson != null
|
||||
? nextLesson?.subject.renamedTo ??
|
||||
ShortSubject.resolve(subject: nextLesson?.subject)
|
||||
.capital()
|
||||
: "")
|
||||
? nextLesson?.subject.renamedTo ??
|
||||
ShortSubject.resolve(subject: nextLesson?.subject)
|
||||
.capital()
|
||||
: "")
|
||||
.capital(),
|
||||
"nextRoom": nextLesson?.room.replaceAll("_", " ") ?? "",
|
||||
"index": "",
|
||||
@@ -243,8 +243,8 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
DateTime now = _now().add(_delay);
|
||||
|
||||
if ((currentState == LiveCardState.morning ||
|
||||
currentState == LiveCardState.afternoon ||
|
||||
currentState == LiveCardState.night) &&
|
||||
currentState == LiveCardState.afternoon ||
|
||||
currentState == LiveCardState.night) &&
|
||||
storeFirstRunDate == null) {
|
||||
storeFirstRunDate = now;
|
||||
}
|
||||
@@ -253,9 +253,9 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
// Filter label lessons #128
|
||||
today = today
|
||||
.where((lesson) =>
|
||||
lesson.status?.name != "Elmaradt" &&
|
||||
lesson.subject.id != '' &&
|
||||
!lesson.isEmpty)
|
||||
lesson.status?.name != "Elmaradt" &&
|
||||
lesson.subject.id != '' &&
|
||||
!lesson.isEmpty)
|
||||
.toList();
|
||||
|
||||
if (today.isNotEmpty) {
|
||||
@@ -263,7 +263,7 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
today.sort((a, b) => a.start.compareTo(b.start));
|
||||
|
||||
final _lesson = today.firstWhere(
|
||||
(l) => l.start.isBefore(now) && l.end.isAfter(now),
|
||||
(l) => l.start.isBefore(now) && l.end.isAfter(now),
|
||||
orElse: () => Lesson.fromJson({}));
|
||||
|
||||
if (_lesson.start.year != 0) {
|
||||
@@ -328,7 +328,7 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
hasActivityStarted = true;
|
||||
} else if (!hasActivityStarted &&
|
||||
((currentState == LiveCardState.duringLesson &&
|
||||
currentLesson != null) ||
|
||||
currentLesson != null) ||
|
||||
currentState == LiveCardState.duringBreak)) {
|
||||
debugPrint("Óra van, vagy szünet, de nincs LiveActivity. létrehozás...");
|
||||
PlatformChannel.createLiveActivity(toMap());
|
||||
@@ -362,7 +362,12 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
//END
|
||||
if (hasActivityStarted &&
|
||||
if ((currentState == LiveCardState.afternoon || currentState == LiveCardState.morning || currentState == LiveCardState.night) && hasActivityStarted && nextLesson != null &&
|
||||
nextLesson!.start.difference(now).inMinutes > 60) {
|
||||
debugPrint("Több, mint 1 óra van az első óráig. Befejezés...");
|
||||
PlatformChannel.endLiveActivity();
|
||||
hasActivityStarted = false;
|
||||
} else if (hasActivityStarted &&
|
||||
!hasDayEnd &&
|
||||
nextLesson == null &&
|
||||
now.isAfter(prevLesson!.end)) {
|
||||
@@ -384,4 +389,4 @@ class LiveCardProvider extends ChangeNotifier {
|
||||
List<Lesson> _today(TimetableProvider p) => (p.getWeek(Week.current()) ?? [])
|
||||
.where((l) => _sameDate(l.date, _now()))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,23 @@ import 'package:provider/provider.dart';
|
||||
|
||||
class SelfNoteProvider with ChangeNotifier {
|
||||
late List<SelfNote> _notes;
|
||||
late List<TodoItem> _todoItems;
|
||||
late BuildContext _context;
|
||||
|
||||
List<SelfNote> get notes => _notes;
|
||||
List<TodoItem> get todos => _todoItems;
|
||||
|
||||
SelfNoteProvider({
|
||||
List<SelfNote> initialNotes = const [],
|
||||
List<TodoItem> initialTodoItems = const [],
|
||||
required BuildContext context,
|
||||
}) {
|
||||
_notes = List.castFrom(initialNotes);
|
||||
_todoItems = List.castFrom(initialTodoItems);
|
||||
_context = context;
|
||||
|
||||
if (_notes.isEmpty) restore();
|
||||
if (_todoItems.isEmpty) restoreTodo();
|
||||
}
|
||||
|
||||
// restore self notes from db
|
||||
@@ -38,6 +44,24 @@ class SelfNoteProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
// restore todo items from db
|
||||
Future<void> restoreTodo() async {
|
||||
String? userId = Provider.of<UserProvider>(_context, listen: false).id;
|
||||
|
||||
// await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
// .userStore
|
||||
// .storeSelfNotes([], userId: userId!);
|
||||
|
||||
// load self notes from db
|
||||
if (userId != null) {
|
||||
var dbTodo = await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
.userQuery
|
||||
.getTodoItems(userId: userId);
|
||||
_todoItems = dbTodo;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// fetches fresh data from api (not needed, cuz no api for that)
|
||||
// Future<void> fetch() async {
|
||||
// }
|
||||
@@ -54,4 +78,17 @@ class SelfNoteProvider with ChangeNotifier {
|
||||
_notes = notes;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// store todo items in db
|
||||
Future<void> storeTodo(List<TodoItem> todos) async {
|
||||
User? user = Provider.of<UserProvider>(_context, listen: false).user;
|
||||
if (user == null) throw "Cannot store Self Notes for User null";
|
||||
String userId = user.id;
|
||||
|
||||
await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
.userStore
|
||||
.storeSelfTodoItems(todos, userId: userId);
|
||||
_todoItems = todos;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class UserProvider with ChangeNotifier {
|
||||
String? get nickname => user?.nickname;
|
||||
String get picture => user?.picture ?? "";
|
||||
String? get displayName => user?.displayName;
|
||||
int? get gradeStreak => user?.gradeStreak;
|
||||
|
||||
final SettingsProvider _settings;
|
||||
|
||||
|
||||
@@ -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'
|
||||
@@ -38,11 +39,11 @@ import 'package:refilc_mobile_ui/screens/settings/settings_route.dart'
|
||||
import 'package:refilc_mobile_ui/screens/settings/settings_screen.dart'
|
||||
as mobile;
|
||||
|
||||
// Desktop UI
|
||||
import 'package:refilc_desktop_ui/screens/navigation/navigation_screen.dart'
|
||||
as desktop;
|
||||
import 'package:refilc_desktop_ui/screens/login/login_screen.dart' as desktop;
|
||||
import 'package:refilc_desktop_ui/screens/login/login_route.dart' as desktop;
|
||||
// Desktop UI (no more desktop ui)
|
||||
// import 'package:refilc_desktop_ui/screens/navigation/navigation_screen.dart'
|
||||
// as desktop;
|
||||
// import 'package:refilc_desktop_ui/screens/login/login_screen.dart' as desktop;
|
||||
// import 'package:refilc_desktop_ui/screens/login/login_route.dart' as desktop;
|
||||
|
||||
// Providers
|
||||
import 'package:refilc/models/settings.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",
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -246,17 +248,18 @@ class App extends StatelessWidget {
|
||||
|
||||
Route? rootNavigator(RouteSettings route) {
|
||||
if (kIsWeb) {
|
||||
switch (route.name) {
|
||||
case "login_back":
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) => const desktop.LoginScreen(back: true));
|
||||
case "login":
|
||||
return _rootRoute(const desktop.LoginScreen());
|
||||
case "navigation":
|
||||
return _rootRoute(const desktop.NavigationScreen());
|
||||
case "login_to_navigation":
|
||||
return desktop.loginRoute(const desktop.NavigationScreen());
|
||||
}
|
||||
return null;
|
||||
// switch (route.name) {
|
||||
// case "login_back":
|
||||
// return CupertinoPageRoute(
|
||||
// builder: (context) => const desktop.LoginScreen(back: true));
|
||||
// case "login":
|
||||
// return _rootRoute(const desktop.LoginScreen());
|
||||
// case "navigation":
|
||||
// return _rootRoute(const desktop.NavigationScreen());
|
||||
// case "login_to_navigation":
|
||||
// return desktop.loginRoute(const desktop.NavigationScreen());
|
||||
// }
|
||||
} else if (Platform.isAndroid || Platform.isIOS) {
|
||||
switch (route.name) {
|
||||
case "login_back":
|
||||
@@ -272,17 +275,18 @@ class App extends StatelessWidget {
|
||||
return mobile.settingsRoute(const mobile.SettingsScreen());
|
||||
}
|
||||
} else if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
|
||||
switch (route.name) {
|
||||
case "login_back":
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) => const desktop.LoginScreen(back: true));
|
||||
case "login":
|
||||
return _rootRoute(const desktop.LoginScreen());
|
||||
case "navigation":
|
||||
return _rootRoute(const desktop.NavigationScreen());
|
||||
case "login_to_navigation":
|
||||
return desktop.loginRoute(const desktop.NavigationScreen());
|
||||
}
|
||||
return null;
|
||||
// switch (route.name) {
|
||||
// case "login_back":
|
||||
// return CupertinoPageRoute(
|
||||
// builder: (context) => const desktop.LoginScreen(back: true));
|
||||
// case "login":
|
||||
// return _rootRoute(const desktop.LoginScreen());
|
||||
// case "navigation":
|
||||
// return _rootRoute(const desktop.NavigationScreen());
|
||||
// case "login_to_navigation":
|
||||
// return desktop.loginRoute(const desktop.NavigationScreen());
|
||||
// }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:refilc/models/settings.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart';
|
||||
// import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart';
|
||||
|
||||
const settingsDB = DatabaseStruct("settings", {
|
||||
"language": String, "start_page": int, "rounding": int, "theme": int,
|
||||
@@ -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,
|
||||
@@ -45,6 +46,7 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
// more
|
||||
"show_breaks": int,
|
||||
"font_family": String,
|
||||
"title_only_font": int,
|
||||
"plus_session_id": String,
|
||||
"cal_sync_room_location": String, "cal_sync_show_exams": int,
|
||||
"cal_sync_show_teacher": int, "cal_sync_renamed": int,
|
||||
@@ -52,6 +54,11 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
"nav_shadow": int,
|
||||
"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,
|
||||
@@ -61,7 +68,10 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
const usersDB = DatabaseStruct("users", {
|
||||
"id": String, "name": String, "username": String, "password": String,
|
||||
"institute_code": String, "student": String, "role": int,
|
||||
"nickname": String, "picture": String // premium only
|
||||
"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,
|
||||
@@ -84,12 +94,13 @@ const userDataDB = DatabaseStruct("user_data", {
|
||||
"goal_befores": String,
|
||||
"goal_pin_dates": String,
|
||||
// todo and notes
|
||||
"todo_items": String, "self_notes": String,
|
||||
"todo_items": String, "self_notes": String, "self_todo": String,
|
||||
// v5 shit
|
||||
"roundings": String,
|
||||
"grade_rarities": String,
|
||||
"linked_accounts": String,
|
||||
"custom_lesson_desc": String,
|
||||
"watch_data": String,
|
||||
});
|
||||
|
||||
Future<void> createTable(Database db, DatabaseStruct struct) =>
|
||||
@@ -99,7 +110,8 @@ Future<Database> initDB(DatabaseProvider database) async {
|
||||
Database db;
|
||||
|
||||
if (kIsWeb) {
|
||||
db = await databaseFactoryFfiWeb.openDatabase("app.db");
|
||||
// db = await databaseFactoryFfiWeb.openDatabase("app.db");
|
||||
throw "web is not supported";
|
||||
} else if (Platform.isLinux || Platform.isWindows) {
|
||||
sqfliteFfiInit();
|
||||
db = await databaseFactoryFfi.openDatabase("app.db");
|
||||
@@ -129,7 +141,15 @@ Future<Database> initDB(DatabaseProvider database) async {
|
||||
await migrateDB(
|
||||
db,
|
||||
struct: usersDB,
|
||||
defaultValues: {"role": 0, "nickname": "", "picture": ""},
|
||||
defaultValues: {
|
||||
"role": 0,
|
||||
"nickname": "",
|
||||
"picture": "",
|
||||
"grade_streak": 0,
|
||||
"access_token": "",
|
||||
"access_token_expire": "",
|
||||
"refresh_token": "",
|
||||
},
|
||||
);
|
||||
await migrateDB(db, struct: userDataDB, defaultValues: {
|
||||
"grades": "[]", "timetable": "[]", "exams": "[]", "homework": "[]",
|
||||
@@ -152,12 +172,13 @@ Future<Database> initDB(DatabaseProvider database) async {
|
||||
"goal_befores": "{}",
|
||||
"goal_pin_dates": "{}",
|
||||
// todo and notes
|
||||
"todo_items": "{}", "self_notes": "[]",
|
||||
"todo_items": "{}", "self_notes": "[]", "self_todo": "[]",
|
||||
// v5 shit
|
||||
"roundings": "{}",
|
||||
"grade_rarities": "{}",
|
||||
"linked_accounts": "[]",
|
||||
"custom_lesson_desc": "{}",
|
||||
"watch_data": "{}",
|
||||
});
|
||||
} catch (error) {
|
||||
print("ERROR: migrateDB: $error");
|
||||
|
||||
@@ -317,6 +317,18 @@ class UserDatabaseQuery {
|
||||
return selfNotes;
|
||||
}
|
||||
|
||||
Future<List<TodoItem>> getTodoItems({required String userId}) async {
|
||||
List<Map> userData =
|
||||
await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||
if (userData.isEmpty) return [];
|
||||
String? todoItemsJson = userData.elementAt(0)["self_todo"] as String?;
|
||||
if (todoItemsJson == null) return [];
|
||||
List<TodoItem> todoItems = (jsonDecode(todoItemsJson) as List)
|
||||
.map((e) => TodoItem.fromJson(e))
|
||||
.toList();
|
||||
return todoItems;
|
||||
}
|
||||
|
||||
// v5
|
||||
Future<Map<String, String>> getRoundings({required String userId}) async {
|
||||
List<Map> userData =
|
||||
|
||||
@@ -196,6 +196,13 @@ class UserDatabaseStore {
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future<void> storeSelfTodoItems(List<TodoItem> todoItems,
|
||||
{required String userId}) async {
|
||||
String todoItemsJson = jsonEncode(todoItems.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"self_todo": todoItemsJson},
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
// v5
|
||||
Future<void> storeRoundings(Map<String, String> roundings,
|
||||
{required String userId}) async {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -292,3 +292,105 @@ class ShortSubject {
|
||||
return subject?.name.capital() ?? subjectName?.capital() ?? "?";
|
||||
}
|
||||
}
|
||||
|
||||
// new v5 thingie
|
||||
class SubjectBooklet {
|
||||
// static String resolveName({GradeSubject? subject, String? subjectName}) =>
|
||||
// _resolve(subject: subject, subjectName: subjectName).name;
|
||||
static String resolveVariant(
|
||||
{GradeSubject? subject,
|
||||
String? subjectName,
|
||||
required BuildContext context}) =>
|
||||
_resolve(subject: subject, subjectName: subjectName);
|
||||
|
||||
static String _resolve({GradeSubject? subject, String? subjectName}) {
|
||||
assert(!(subject == null && subjectName == null));
|
||||
|
||||
String name = (subject?.name ?? subjectName ?? "")
|
||||
.toLowerCase()
|
||||
.specialChars()
|
||||
.trim();
|
||||
String category =
|
||||
subject?.category.description.toLowerCase().specialChars() ?? "";
|
||||
|
||||
String basePath = "assets/svg/cover_arts";
|
||||
|
||||
// todo: check for categories
|
||||
if (RegExp("mate(k|matika)").hasMatch(name) || category == "matematika") {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("magyar nyelv|nyelvtan").hasMatch(name)) {
|
||||
return "$basePath/line.svg";
|
||||
} else if (RegExp("irodalom").hasMatch(name)) {
|
||||
return "$basePath/line.svg";
|
||||
} else if (RegExp("tor(i|tenelem)").hasMatch(name)) {
|
||||
return "$basePath/line.svg";
|
||||
} else if (RegExp("foldrajz").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("rajz|muvtori|muveszet|vizualis").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("fizika").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("^enek|zene|szolfezs|zongora|korus").hasMatch(name)) {
|
||||
return "$basePath/vocal.svg";
|
||||
} else if (RegExp("^tes(i|tneveles)|sport|edzeselmelet").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("kemia").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("biologia").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp(
|
||||
"kornyezet|termeszet ?(tudomany|ismeret)|hon( es nep)?ismeret")
|
||||
.hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("(hit|erkolcs)tan|vallas|etika|bibliaismeret")
|
||||
.hasMatch(name)) {
|
||||
return "$basePath/line.svg";
|
||||
} else if (RegExp("penzugy").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("informatika|szoftver|iroda|digitalis").hasMatch(name)) {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("prog").hasMatch(name)) {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("halozat").hasMatch(name)) {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("szinhaz").hasMatch(name)) {
|
||||
return "$basePath/vocal.svg";
|
||||
} else if (RegExp("film|media").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("elektro(tech)?nika").hasMatch(name)) {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("gepesz|mernok|ipar").hasMatch(name)) {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("technika").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("tanc").hasMatch(name)) {
|
||||
return "$basePath/vocal.svg";
|
||||
} else if (RegExp("filozofia").hasMatch(name)) {
|
||||
return "$basePath/line.svg";
|
||||
} else if (RegExp("osztaly(fonoki|kozosseg)|kozossegi|neveles")
|
||||
.hasMatch(name) ||
|
||||
name == "ofo") {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("gazdasag").hasMatch(name)) {
|
||||
return "$basePath/line.svg";
|
||||
} else if (RegExp("szorgalom").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("magatartas").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp(
|
||||
"angol|nemet|francia|olasz|orosz|spanyol|latin|kinai|nyelv")
|
||||
.hasMatch(name)) {
|
||||
return "$basePath/line.svg";
|
||||
} else if (RegExp("linux").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
} else if (RegExp("adatbazis").hasMatch(name)) {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("asztali alkalmazasok").hasMatch(name)) {
|
||||
return "$basePath/grid.svg";
|
||||
} else if (RegExp("projekt").hasMatch(name)) {
|
||||
return "$basePath/plain.svg";
|
||||
}
|
||||
|
||||
return "$basePath/plain.svg";
|
||||
}
|
||||
}
|
||||
|
||||
130
refilc/lib/helpers/uwu_helper.dart
Normal file
@@ -0,0 +1,130 @@
|
||||
import 'dart:math';
|
||||
|
||||
class Uwuifier {
|
||||
final Map<String, double> _spacesModifier;
|
||||
final double _wordsModifier;
|
||||
|
||||
final List<String> faces = [
|
||||
"OwO",
|
||||
"UwU",
|
||||
">w<",
|
||||
"^w^",
|
||||
"^-^",
|
||||
":3",
|
||||
];
|
||||
|
||||
final List<List<String>> uwuMap = [
|
||||
['(?:r|l)', 'w'],
|
||||
['(?:R|L)', 'W'],
|
||||
['na', 'nya'],
|
||||
['ne', 'nye'],
|
||||
['NA', 'NYA'],
|
||||
['NE', 'NYE'],
|
||||
['Na', 'Nya'],
|
||||
['Ne', 'Nye'],
|
||||
['no', 'nyo'],
|
||||
['NO', 'NYO'],
|
||||
['No', 'Nyo'],
|
||||
['nO', 'NYo'],
|
||||
['ove', 'uv'],
|
||||
['no', 'nwo'],
|
||||
];
|
||||
|
||||
final Map<String, String> _uwuCache = {};
|
||||
|
||||
Uwuifier({
|
||||
Map<String, double>? spaces,
|
||||
double? words,
|
||||
}) : _spacesModifier = spaces ?? {
|
||||
'faces': 0.05,
|
||||
'actions': 0.0,
|
||||
'stutters': 0.1,
|
||||
},
|
||||
_wordsModifier = words ?? 1.0;
|
||||
|
||||
String uwuifyWords(String sentence) {
|
||||
final words = sentence.split(' ');
|
||||
|
||||
final uwuifiedSentence = words.map((word) {
|
||||
if (isAt(word) || isUri(word)) return word;
|
||||
|
||||
var seed = Random().nextDouble();
|
||||
for (final uwuMapEntry in uwuMap) {
|
||||
final oldWord = RegExp(uwuMapEntry[0], caseSensitive: false);
|
||||
final newWord = uwuMapEntry[1];
|
||||
if (seed > _wordsModifier) continue;
|
||||
word = word.replaceAll(oldWord, newWord);
|
||||
}
|
||||
|
||||
return word;
|
||||
}).join(' ');
|
||||
|
||||
return uwuifiedSentence;
|
||||
}
|
||||
|
||||
String uwuifySpaces(String sentence) {
|
||||
final words = sentence.split(' ');
|
||||
|
||||
final faceThreshold = _spacesModifier['faces']!;
|
||||
final actionThreshold = _spacesModifier['actions']! + faceThreshold;
|
||||
final stutterThreshold = _spacesModifier['stutters']! + actionThreshold;
|
||||
|
||||
final uwuifiedSentence = words.map((word) {
|
||||
final seed = Random().nextDouble();
|
||||
final firstCharacter = word[0];
|
||||
|
||||
if (seed <= faceThreshold && faces.isNotEmpty) {
|
||||
word += ' ${faces[Random().nextInt(faces.length)]}';
|
||||
} else if (seed <= actionThreshold) {
|
||||
// Skip actions
|
||||
} else if (seed <= stutterThreshold && !isUri(word)) {
|
||||
if (Random().nextInt(10) == 0) {
|
||||
final stutter = Random().nextInt(3);
|
||||
return '${firstCharacter * (stutter + 1)}-$word';
|
||||
}
|
||||
}
|
||||
|
||||
return word;
|
||||
}).join(' ');
|
||||
|
||||
return uwuifiedSentence;
|
||||
}
|
||||
|
||||
String uwuifySentence(String sentence) {
|
||||
if (_uwuCache.containsKey(sentence)) {
|
||||
return _uwuCache[sentence]!;
|
||||
}
|
||||
|
||||
var uwuifiedSentence = uwuifyWords(sentence);
|
||||
uwuifiedSentence = uwuifySpaces(uwuifiedSentence);
|
||||
|
||||
_uwuCache[sentence] = uwuifiedSentence;
|
||||
return uwuifiedSentence;
|
||||
}
|
||||
|
||||
bool isAt(String value) {
|
||||
return value.startsWith('@');
|
||||
}
|
||||
|
||||
bool isUri(String? value) {
|
||||
if (value == null) return false;
|
||||
final split = RegExp(
|
||||
r'''(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?''')
|
||||
.firstMatch(value);
|
||||
if (split == null) return false;
|
||||
final scheme = split.group(1);
|
||||
final authority = split.group(2);
|
||||
final path = split.group(3);
|
||||
if (!(scheme?.isNotEmpty == true && path?.isNotEmpty == true)) return false;
|
||||
if (authority != null && authority.isNotEmpty) {
|
||||
if (!(path?.isEmpty == true || path!.startsWith('/'))) return false;
|
||||
} else if (path?.startsWith('//') == true) {
|
||||
return false;
|
||||
}
|
||||
if (!RegExp(r'''^[a-z][a-z0-9+\-\.]*$''', caseSensitive: false)
|
||||
.hasMatch(scheme!.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/api/providers/database_provider.dart';
|
||||
import 'package:refilc/database/init.dart';
|
||||
import 'package:refilc/helpers/notification_helper.dart';
|
||||
// import 'package:refilc/helpers/notification_helper.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -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');
|
||||
@@ -80,7 +104,7 @@ class Startup {
|
||||
user = await database.query.getUsers(settings);
|
||||
|
||||
// Set all notification categories to seen to avoid having notifications that the user has already seen in the app
|
||||
NotificationsHelper().setAllCategoriesSeen(user);
|
||||
// NotificationsHelper().setAllCategoriesSeen(user);
|
||||
|
||||
late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
||||
// Notifications setup
|
||||
@@ -122,30 +146,30 @@ class Startup {
|
||||
|
||||
// Platform specific settings
|
||||
if (!kIsWeb) {
|
||||
const DarwinInitializationSettings initializationSettingsDarwin =
|
||||
DarwinInitializationSettings(
|
||||
requestSoundPermission: true,
|
||||
requestBadgePermission: true,
|
||||
requestAlertPermission: false,
|
||||
);
|
||||
const AndroidInitializationSettings initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('ic_notification');
|
||||
const LinuxInitializationSettings initializationSettingsLinux =
|
||||
LinuxInitializationSettings(defaultActionName: 'Open notification');
|
||||
const InitializationSettings initializationSettings =
|
||||
InitializationSettings(
|
||||
android: initializationSettingsAndroid,
|
||||
iOS: initializationSettingsDarwin,
|
||||
macOS: initializationSettingsDarwin,
|
||||
linux: initializationSettingsLinux,
|
||||
);
|
||||
// const DarwinInitializationSettings initializationSettingsDarwin =
|
||||
// DarwinInitializationSettings(
|
||||
// requestSoundPermission: true,
|
||||
// requestBadgePermission: true,
|
||||
// requestAlertPermission: false,
|
||||
// );
|
||||
// const AndroidInitializationSettings initializationSettingsAndroid =
|
||||
// AndroidInitializationSettings('ic_notification');
|
||||
// const LinuxInitializationSettings initializationSettingsLinux =
|
||||
// LinuxInitializationSettings(defaultActionName: 'Open notification');
|
||||
// const InitializationSettings initializationSettings =
|
||||
// InitializationSettings(
|
||||
// android: initializationSettingsAndroid,
|
||||
// iOS: initializationSettingsDarwin,
|
||||
// macOS: initializationSettingsDarwin,
|
||||
// linux: initializationSettingsLinux,
|
||||
// );
|
||||
|
||||
// Initialize notifications
|
||||
await flutterLocalNotificationsPlugin.initialize(
|
||||
initializationSettings,
|
||||
onDidReceiveNotificationResponse:
|
||||
NotificationsHelper().onDidReceiveNotificationResponse,
|
||||
);
|
||||
// await flutterLocalNotificationsPlugin.initialize(
|
||||
// initializationSettings,
|
||||
// onDidReceiveNotificationResponse:
|
||||
// NotificationsHelper().onDidReceiveNotificationResponse,
|
||||
// );
|
||||
}
|
||||
|
||||
// if (Platform.isAndroid || Platform.isIOS) {
|
||||
@@ -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);
|
||||
@@ -203,7 +239,7 @@ Future<void> initPlatformState() async {
|
||||
if (!Platform.isIOS) return;
|
||||
LiveActivityHelper().backgroundJob();
|
||||
} else {
|
||||
NotificationsHelper().backgroundJob();
|
||||
// NotificationsHelper().backgroundJob();
|
||||
}
|
||||
BackgroundFetch.finish(taskId);
|
||||
}, (String taskId) async {
|
||||
@@ -243,8 +279,9 @@ void backgroundHeadlessTask(HeadlessTask task) {
|
||||
if (!Platform.isIOS) return;
|
||||
LiveActivityHelper().backgroundJob();
|
||||
} else {
|
||||
NotificationsHelper().backgroundJob();
|
||||
} BackgroundFetch.finish(task.taskId);
|
||||
// NotificationsHelper().backgroundJob();
|
||||
}
|
||||
BackgroundFetch.finish(task.taskId);
|
||||
}
|
||||
|
||||
Future<void> initAdditionalBackgroundFetch() async {
|
||||
|
||||
22
refilc/lib/models/cloud_sync_data.dart
Normal 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,3 +33,37 @@ class SelfNote {
|
||||
'note_type': noteType == NoteType.image ? 'image' : 'text',
|
||||
};
|
||||
}
|
||||
|
||||
class TodoItem {
|
||||
String id;
|
||||
String title;
|
||||
String content;
|
||||
bool done;
|
||||
|
||||
Map? json;
|
||||
|
||||
TodoItem({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.content,
|
||||
required this.done,
|
||||
this.json,
|
||||
});
|
||||
|
||||
factory TodoItem.fromJson(Map json) {
|
||||
return TodoItem(
|
||||
id: json['id'],
|
||||
title: json['title'],
|
||||
content: json['content'],
|
||||
done: json['done'],
|
||||
json: json,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> get toJson => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'content': content,
|
||||
'done': done,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
UpdateChannel _updateChannel;
|
||||
Config _config;
|
||||
String _xFilcId;
|
||||
bool _analyticsEnabled;
|
||||
bool _graphClassAvg;
|
||||
bool _goodStudent;
|
||||
bool _presentationMode;
|
||||
@@ -96,6 +97,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
// more
|
||||
bool _showBreaks;
|
||||
String _fontFamily;
|
||||
bool _titleOnlyFont;
|
||||
String _plusSessionId;
|
||||
String _calSyncRoomLocation;
|
||||
bool _calSyncShowExams;
|
||||
@@ -105,6 +107,11 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool _navShadow;
|
||||
bool _newColors;
|
||||
bool _uwuMode;
|
||||
bool _newPopups;
|
||||
List<String> _unseenNewFeatures;
|
||||
bool _cloudSyncEnabled;
|
||||
String _cloudSyncToken;
|
||||
DateTime _updatedAt;
|
||||
// quick settings
|
||||
bool _qTimetableLessonNum;
|
||||
bool _qTimetableSubTiles;
|
||||
@@ -134,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,
|
||||
@@ -167,6 +175,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
required String pinSetNotify,
|
||||
required String pinSetExtras,
|
||||
required String fontFamily,
|
||||
required bool titleOnlyFont,
|
||||
required String plusSessionId,
|
||||
required String calSyncRoomLocation,
|
||||
required bool calSyncShowExams,
|
||||
@@ -176,6 +185,11 @@ class SettingsProvider extends ChangeNotifier {
|
||||
required bool navShadow,
|
||||
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,
|
||||
@@ -202,6 +216,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_updateChannel = updateChannel,
|
||||
_config = config,
|
||||
_xFilcId = xFilcId,
|
||||
_analyticsEnabled = analyticsEnabled,
|
||||
_graphClassAvg = graphClassAvg,
|
||||
_goodStudent = goodStudent,
|
||||
_presentationMode = presentationMode,
|
||||
@@ -235,6 +250,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_pinSetNotify = pinSetNotify,
|
||||
_pinSetExtras = pinSetExtras,
|
||||
_fontFamily = fontFamily,
|
||||
_titleOnlyFont = titleOnlyFont,
|
||||
_plusSessionId = plusSessionId,
|
||||
_calSyncRoomLocation = calSyncRoomLocation,
|
||||
_calSyncShowExams = calSyncShowExams,
|
||||
@@ -244,6 +260,11 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_navShadow = navShadow,
|
||||
_newColors = newColors,
|
||||
_uwuMode = uwuMode,
|
||||
_newPopups = newPopups,
|
||||
_unseenNewFeatures = unseenNewFeatures,
|
||||
_cloudSyncEnabled = cloudSyncEnabled,
|
||||
_cloudSyncToken = cloudSyncToken,
|
||||
_updatedAt = updatedAt,
|
||||
_qTimetableLessonNum = qTimetableLessonNum,
|
||||
_qTimetableSubTiles = qTimetableSubTiles,
|
||||
_qSubjectsSubTiles = qSubjectsSubTiles;
|
||||
@@ -288,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,
|
||||
@@ -322,6 +344,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
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,
|
||||
@@ -331,6 +354,11 @@ class SettingsProvider extends ChangeNotifier {
|
||||
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'],
|
||||
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,
|
||||
@@ -365,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,
|
||||
@@ -397,6 +426,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
"notify_s_pin": _pinSetNotify,
|
||||
"extras_s_pin": _pinSetExtras,
|
||||
"font_family": _fontFamily,
|
||||
"title_only_font": _titleOnlyFont ? 1 : 0,
|
||||
"plus_session_id": _plusSessionId,
|
||||
"cal_sync_room_location": _calSyncRoomLocation,
|
||||
"cal_sync_show_exams": _calSyncShowExams ? 1 : 0,
|
||||
@@ -406,6 +436,11 @@ class SettingsProvider extends ChangeNotifier {
|
||||
"nav_shadow": _navShadow ? 1 : 0,
|
||||
"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,
|
||||
@@ -443,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,
|
||||
@@ -476,6 +512,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
pinSetNotify: '',
|
||||
pinSetExtras: '',
|
||||
fontFamily: '',
|
||||
titleOnlyFont: false,
|
||||
plusSessionId: '',
|
||||
calSyncRoomLocation: 'location',
|
||||
calSyncShowExams: true,
|
||||
@@ -485,6 +522,11 @@ class SettingsProvider extends ChangeNotifier {
|
||||
navShadow: true,
|
||||
newColors: true,
|
||||
uwuMode: false,
|
||||
newPopups: true,
|
||||
unseenNewFeatures: ['grade_exporting'],
|
||||
cloudSyncEnabled: false,
|
||||
cloudSyncToken: '',
|
||||
updatedAt: DateTime.now(),
|
||||
qTimetableLessonNum: true,
|
||||
qTimetableSubTiles: true,
|
||||
qSubjectsSubTiles: true,
|
||||
@@ -514,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;
|
||||
@@ -546,6 +589,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
String get currentThemeCreator => _currentThemeCreator;
|
||||
bool get showBreaks => _showBreaks;
|
||||
String get fontFamily => _fontFamily;
|
||||
bool get titleOnlyFont => _titleOnlyFont;
|
||||
String get plusSessionId => _plusSessionId;
|
||||
String get calSyncRoomLocation => _calSyncRoomLocation;
|
||||
bool get calSyncShowExams => _calSyncShowExams;
|
||||
@@ -555,6 +599,11 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool get navShadow => _navShadow;
|
||||
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;
|
||||
@@ -569,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,
|
||||
@@ -583,6 +633,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
UpdateChannel? updateChannel,
|
||||
Config? config,
|
||||
String? xFilcId,
|
||||
bool? analyticsEnabled,
|
||||
bool? graphClassAvg,
|
||||
bool? goodStudent,
|
||||
bool? presentationMode,
|
||||
@@ -612,6 +663,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
String? currentThemeCreator,
|
||||
bool? showBreaks,
|
||||
String? fontFamily,
|
||||
bool? titleOnlyFont,
|
||||
String? plusSessionId,
|
||||
String? calSyncRoomLocation,
|
||||
bool? calSyncShowExams,
|
||||
@@ -621,6 +673,10 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool? navShadow,
|
||||
bool? newColors,
|
||||
bool? uwuMode,
|
||||
bool? newPopups,
|
||||
List<String>? unseenNewFeatures,
|
||||
bool? cloudSyncEnabled,
|
||||
String? cloudSyncToken,
|
||||
bool? qTimetableLessonNum,
|
||||
bool? qTimetableSubTiles,
|
||||
bool? qSubjectsSubTiles,
|
||||
@@ -643,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;
|
||||
@@ -684,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;
|
||||
}
|
||||
@@ -777,6 +837,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
if (fontFamily != null && fontFamily != _fontFamily) {
|
||||
_fontFamily = fontFamily;
|
||||
}
|
||||
if (titleOnlyFont != null && titleOnlyFont != _titleOnlyFont) {
|
||||
_titleOnlyFont = titleOnlyFont;
|
||||
}
|
||||
if (plusSessionId != null && plusSessionId != _plusSessionId) {
|
||||
_plusSessionId = plusSessionId;
|
||||
}
|
||||
@@ -806,6 +869,18 @@ class SettingsProvider extends ChangeNotifier {
|
||||
if (uwuMode != null && uwuMode != _uwuMode) {
|
||||
_uwuMode = uwuMode;
|
||||
}
|
||||
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;
|
||||
@@ -817,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));
|
||||
|
||||
@@ -16,8 +16,18 @@ class User {
|
||||
Role role;
|
||||
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;
|
||||
|
||||
User({
|
||||
String? id,
|
||||
@@ -29,6 +39,13 @@ class User {
|
||||
required this.role,
|
||||
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;
|
||||
@@ -53,10 +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"] ?? "",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:refilc/theme/colors/dark_desktop.dart';
|
||||
// import 'package:refilc/theme/colors/dark_desktop.dart';
|
||||
import 'package:refilc/theme/colors/dark_mobile.dart';
|
||||
import 'package:refilc/theme/colors/light_desktop.dart';
|
||||
// import 'package:refilc/theme/colors/light_desktop.dart';
|
||||
import 'package:refilc/theme/colors/light_mobile.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -21,10 +21,16 @@ class AppColors {
|
||||
} else {
|
||||
switch (brightness) {
|
||||
case Brightness.light:
|
||||
return LightDesktopAppColors();
|
||||
return LightMobileAppColors();
|
||||
case Brightness.dark:
|
||||
return DarkDesktopAppColors();
|
||||
return DarkMobileAppColors();
|
||||
}
|
||||
// switch (brightness) {
|
||||
// case Brightness.light:
|
||||
// return LightDesktopAppColors();
|
||||
// case Brightness.dark:
|
||||
// return DarkDesktopAppColors();
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +104,10 @@ class AppTheme {
|
||||
brightness: Brightness.light,
|
||||
useMaterial3: true,
|
||||
fontFamily: _defaultFontFamily,
|
||||
textTheme:
|
||||
googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor) ??
|
||||
const TextTheme().apply(bodyColor: textColor),
|
||||
textTheme: !settings.titleOnlyFont
|
||||
? (googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor) ??
|
||||
const TextTheme().apply(bodyColor: textColor))
|
||||
: null,
|
||||
scaffoldBackgroundColor: backgroundColor,
|
||||
primaryColor: lightColors.filc,
|
||||
dividerColor: const Color(0x00000000),
|
||||
@@ -124,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),
|
||||
@@ -140,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),
|
||||
@@ -229,8 +228,9 @@ class AppTheme {
|
||||
brightness: Brightness.dark,
|
||||
useMaterial3: true,
|
||||
fontFamily: _defaultFontFamily,
|
||||
textTheme:
|
||||
googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor),
|
||||
textTheme: !settings.titleOnlyFont
|
||||
? (googleFontsMap[settings.fontFamily]?.apply(bodyColor: textColor))
|
||||
: null,
|
||||
scaffoldBackgroundColor: backgroundColor,
|
||||
primaryColor: darkColors.filc,
|
||||
dividerColor: const Color(0x00000000),
|
||||
@@ -248,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),
|
||||
@@ -264,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),
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,7 +8,9 @@ List<DateWidget> getWidgets(List<Grade> providerGrades) {
|
||||
List<DateWidget> items = [];
|
||||
for (var gradeType in GradeType.values) {
|
||||
if ([GradeType.midYear, GradeType.unknown, GradeType.levelExam]
|
||||
.contains(gradeType)) continue;
|
||||
.contains(gradeType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Grade> grades =
|
||||
providerGrades.where((grade) => grade.type == gradeType).toList();
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import 'package:refilc/ui/date_widget.dart';
|
||||
import 'package:refilc/utils/platform.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/grade/grade_viewable.dart'
|
||||
as mobile;
|
||||
import 'package:refilc_mobile_ui/common/widgets/grade/new_grades.dart'
|
||||
as mobile;
|
||||
import 'package:refilc_desktop_ui/common/widgets/grade/grade_viewable.dart'
|
||||
as desktop;
|
||||
|
||||
List<DateWidget> getWidgets(
|
||||
List<Grade> providerGrades, DateTime? lastSeenDate) {
|
||||
@@ -19,9 +16,7 @@ List<DateWidget> getWidgets(
|
||||
items.add(DateWidget(
|
||||
key: grade.id,
|
||||
date: grade.date,
|
||||
widget: PlatformUtils.isMobile
|
||||
? mobile.GradeViewable(grade)
|
||||
: desktop.GradeViewable(grade),
|
||||
widget: mobile.GradeViewable(grade),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/// Blocky Color Picker
|
||||
|
||||
library block_colorpicker;
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc/theme/colors/accent.dart';
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
library hsv_picker;
|
||||
library;
|
||||
|
||||
import 'package:refilc/models/shared_theme.dart';
|
||||
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
|
||||
@@ -192,6 +192,8 @@ class FilcColorPickerState extends State<FilcColorPicker> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool advOverride = widget.colorMode == CustomColorMode.grade ? true : false;
|
||||
|
||||
if (MediaQuery.of(context).orientation == Orientation.portrait ||
|
||||
widget.portraitOnly) {
|
||||
return Column(
|
||||
@@ -218,7 +220,7 @@ class FilcColorPickerState extends State<FilcColorPicker> {
|
||||
child: colorPickerSlider(TrackType.saturation),
|
||||
),
|
||||
),
|
||||
if (isAdvancedView)
|
||||
if (isAdvancedView || advOverride)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
|
||||
child: SizedBox(
|
||||
@@ -230,7 +232,7 @@ class FilcColorPickerState extends State<FilcColorPicker> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (isAdvancedView &&
|
||||
if ((isAdvancedView || advOverride) &&
|
||||
widget.colorMode != CustomColorMode.theme &&
|
||||
widget.colorMode != CustomColorMode.enterId)
|
||||
Padding(
|
||||
@@ -295,7 +297,8 @@ class FilcColorPickerState extends State<FilcColorPicker> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (widget.colorMode != CustomColorMode.enterId)
|
||||
if (widget.colorMode != CustomColorMode.enterId &&
|
||||
widget.colorMode != CustomColorMode.grade)
|
||||
SizedBox(
|
||||
height: 70 * (widget.colorMode == CustomColorMode.theme ? 2 : 1),
|
||||
child: BlockPicker(
|
||||
@@ -347,7 +350,8 @@ class FilcColorPickerState extends State<FilcColorPicker> {
|
||||
),
|
||||
),
|
||||
if (widget.colorMode != CustomColorMode.theme &&
|
||||
widget.colorMode != CustomColorMode.enterId)
|
||||
widget.colorMode != CustomColorMode.enterId &&
|
||||
!advOverride)
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc_kreta_api/providers/exam_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/homework_provider.dart';
|
||||
@@ -8,7 +9,8 @@ import 'package:refilc_kreta_api/models/lesson.dart';
|
||||
import 'package:refilc/utils/format.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/exam/exam_view.dart';
|
||||
// import 'package:refilc_mobile_ui/common/widgets/exam/exam_view.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/exam/exam_viewable.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/homework/homework_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
@@ -109,7 +111,8 @@ class LessonTile extends StatelessWidget {
|
||||
title: exam.description != ""
|
||||
? exam.description
|
||||
: exam.mode?.description ?? "exam".i18n,
|
||||
onPressed: () => ExamView.show(exam, context: context),
|
||||
// onPressed: () => ExamView.show(exam, context: context),
|
||||
onPressed: () => ExamPopup.show(context: context, exam: exam),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -190,7 +193,7 @@ class LessonTile extends StatelessWidget {
|
||||
: Transform.translate(
|
||||
offset: const Offset(0, -2.0),
|
||||
child: Text(
|
||||
"${DateFormat("H:mm").format(lesson.start)}-${DateFormat("H:mm").format(lesson.end)}",
|
||||
"${DateFormat("E, H:mm", I18n.of(context).locale.toString()).format(lesson.start)}-${DateFormat("H:mm").format(lesson.end)}",
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
|
||||
@@ -58,7 +58,9 @@ extension DateFormatUtils on DateTime {
|
||||
}
|
||||
if (now.year == year &&
|
||||
now.month == month &&
|
||||
now.add(const Duration(days: 1)).day == day) return "Tomorrow".i18n;
|
||||
now.add(const Duration(days: 1)).day == day) {
|
||||
return "Tomorrow".i18n;
|
||||
}
|
||||
|
||||
String formatString;
|
||||
|
||||
|
||||
@@ -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"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.0+257
|
||||
version: 5.1.0+282
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.0 <=3.3.2"
|
||||
sdk: ^3.6.0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -16,8 +16,8 @@ dependencies:
|
||||
# reFilc packages
|
||||
refilc_mobile_ui:
|
||||
path: "../refilc_mobile_ui/"
|
||||
refilc_desktop_ui:
|
||||
path: "../refilc_desktop_ui/"
|
||||
# refilc_desktop_ui:
|
||||
# path: "../refilc_desktop_ui/"
|
||||
refilc_kreta_api:
|
||||
path: "../refilc_kreta_api/"
|
||||
refilc_plus:
|
||||
@@ -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,57 @@ 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
|
||||
# sqflite_common_ffi_web: ^0.4.0
|
||||
image_crop_plus: ^1.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
|
||||
maps_launcher: ^3.0.0+1
|
||||
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
|
||||
|
||||
@@ -104,6 +108,7 @@ flutter:
|
||||
- assets/svg/menu_icons/
|
||||
- assets/other/dirtywords.xml
|
||||
- assets/svg/
|
||||
- assets/svg/cover_arts/
|
||||
|
||||
fonts:
|
||||
- family: FilcIcons
|
||||
|
||||
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,28 +0,0 @@
|
||||
# This file configures the analyzer, which statically analyzes Dart code to
|
||||
# check for errors, warnings, and lints.
|
||||
#
|
||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
||||
# invoked from the command line by running `flutter analyze`.
|
||||
|
||||
# The following line activates a set of recommended lints for Flutter apps,
|
||||
# packages, and plugins designed to encourage good coding practices.
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
linter:
|
||||
# The lint rules applied to this project can be customized in the
|
||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
||||
# included above or to enable additional rules. A list of all available lints
|
||||
# and their documentation is published at
|
||||
# https://dart-lang.github.io/linter/lints/index.html.
|
||||
#
|
||||
# Instead of disabling a lint rule for the entire project in the
|
||||
# section below, it can also be suppressed for a single line of code
|
||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
||||
# producing the lint.
|
||||
rules:
|
||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
@@ -1,91 +0,0 @@
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FilterBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const FilterBar({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.controller,
|
||||
this.onTap,
|
||||
this.padding = const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
this.disableFading = false,
|
||||
this.scrollable = true,
|
||||
}) : assert(items.length == controller.length);
|
||||
|
||||
final List<Widget> items;
|
||||
final TabController controller;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final Function(int)? onTap;
|
||||
@override
|
||||
final Size preferredSize = const Size.fromHeight(42.0);
|
||||
final bool disableFading;
|
||||
final bool scrollable;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tabbar = TabBar(
|
||||
controller: controller,
|
||||
isScrollable: scrollable,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
// Label
|
||||
labelStyle: Theme.of(context).textTheme.titleMedium!.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 15.0,
|
||||
),
|
||||
labelPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
|
||||
labelColor: Theme.of(context).colorScheme.secondary,
|
||||
unselectedLabelColor: AppColors.of(context).text.withOpacity(0.65),
|
||||
// Indicator
|
||||
indicatorPadding: const EdgeInsets.symmetric(vertical: 8),
|
||||
indicator: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondary.withOpacity(0.25),
|
||||
borderRadius: BorderRadius.circular(45.0),
|
||||
),
|
||||
overlayColor: MaterialStateProperty.all(const Color(0x00000000)),
|
||||
// Tabs
|
||||
padding: EdgeInsets.zero,
|
||||
tabs: items,
|
||||
onTap: onTap,
|
||||
);
|
||||
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: 48.0,
|
||||
padding: padding,
|
||||
child: disableFading
|
||||
? tabbar
|
||||
: AnimatedBuilder(
|
||||
animation: controller.animation!,
|
||||
builder: (ctx, child) {
|
||||
// avoid fading over selected tab
|
||||
return ShaderMask(
|
||||
shaderCallback: (Rect bounds) {
|
||||
final Color bg =
|
||||
Theme.of(context).scaffoldBackgroundColor;
|
||||
final double index = controller.animation!.value;
|
||||
return LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
index < 0.2 ? Colors.transparent : bg,
|
||||
Colors.transparent,
|
||||
Colors.transparent,
|
||||
index > controller.length - 1.2
|
||||
? Colors.transparent
|
||||
: bg
|
||||
],
|
||||
stops: const [
|
||||
0,
|
||||
0.1,
|
||||
0.9,
|
||||
1
|
||||
]).createShader(bounds);
|
||||
},
|
||||
blendMode: BlendMode.dstOut,
|
||||
child: child);
|
||||
},
|
||||
child: tabbar,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PanelButton extends StatelessWidget {
|
||||
const PanelButton({
|
||||
super.key,
|
||||
this.onPressed,
|
||||
this.padding = const EdgeInsets.symmetric(horizontal: 14.0),
|
||||
this.leading,
|
||||
this.title,
|
||||
this.trailing,
|
||||
this.trailingDivider = false,
|
||||
});
|
||||
|
||||
final void Function()? onPressed;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final Widget? leading;
|
||||
final Widget? title;
|
||||
final Widget? trailing;
|
||||
final bool trailingDivider;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: RawMaterialButton(
|
||||
onPressed: onPressed,
|
||||
padding: padding,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
|
||||
child: ListTile(
|
||||
leading: leading != null
|
||||
? Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
iconTheme: IconThemeData(
|
||||
color: Theme.of(context).colorScheme.secondary)),
|
||||
child: leading!,
|
||||
)
|
||||
: null,
|
||||
trailing: trailingDivider
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(right: 6.0),
|
||||
width: 2.0,
|
||||
height: 32.0,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.of(context).text.withOpacity(.15),
|
||||
borderRadius: BorderRadius.circular(45.0),
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing!,
|
||||
],
|
||||
)
|
||||
: trailing,
|
||||
title: title != null
|
||||
? DefaultTextStyle(
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(fontWeight: FontWeight.w600, fontSize: 14.0),
|
||||
child: title!,
|
||||
)
|
||||
: null,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import 'package:refilc/models/user.dart';
|
||||
import 'package:refilc/utils/color.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
|
||||
class ProfileImage extends StatelessWidget {
|
||||
const ProfileImage({
|
||||
super.key,
|
||||
this.name,
|
||||
this.radius = 20.0,
|
||||
this.role = Role.student,
|
||||
this.backgroundColor,
|
||||
});
|
||||
|
||||
final String? name;
|
||||
final double radius;
|
||||
final Role? role;
|
||||
final Color? backgroundColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color color = ColorUtils.foregroundColor(
|
||||
backgroundColor ?? Theme.of(context).scaffoldBackgroundColor);
|
||||
Color roleColor;
|
||||
|
||||
if (Theme.of(context).brightness == Brightness.light) {
|
||||
roleColor = const Color(0xFF444444);
|
||||
} else {
|
||||
roleColor = const Color(0xFF555555);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Material(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
shape: const CircleBorder(),
|
||||
color: backgroundColor ?? AppColors.of(context).text.withOpacity(.15),
|
||||
child: InkWell(
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
height: radius * 2,
|
||||
width: radius * 2,
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: name != null && (name?.trim().length ?? 0) > 0
|
||||
? Center(
|
||||
child: Text(
|
||||
(name?.trim().length ?? 0) > 0
|
||||
? (name ?? "?").trim()[0]
|
||||
: "?",
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 18.0 * (radius / 20.0),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Role indicator
|
||||
if (role == Role.parent)
|
||||
SizedBox(
|
||||
height: radius * 2,
|
||||
width: radius * 2,
|
||||
child: Container(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Icon(Icons.shield, color: roleColor, size: radius / 1.3),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:refilc/ui/widgets/grade/grade_tile.dart';
|
||||
|
||||
class GradeViewable extends StatelessWidget {
|
||||
const GradeViewable(this.grade, {super.key});
|
||||
|
||||
final Grade grade;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GradeTile(grade);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||
import 'package:refilc/ui/widgets/lesson/lesson_tile.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LessonViewable extends StatelessWidget {
|
||||
const LessonViewable(this.lesson, {super.key, this.swapDesc = false});
|
||||
|
||||
final Lesson lesson;
|
||||
final bool swapDesc;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tile = LessonTile(lesson, swapDesc: swapDesc);
|
||||
|
||||
if (lesson.subject.id == '' || tile.lesson.isEmpty) return tile;
|
||||
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
@@ -1,408 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:refilc/api/providers/update_provider.dart';
|
||||
import 'package:refilc/ui/date_widget.dart';
|
||||
import 'package:refilc_kreta_api/models/absence.dart';
|
||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||
import 'package:refilc_kreta_api/models/subject.dart';
|
||||
import 'package:refilc_kreta_api/models/week.dart';
|
||||
import 'package:refilc_kreta_api/providers/absence_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/note_provider.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc_kreta_api/providers/timetable_provider.dart';
|
||||
import 'package:refilc_mobile_ui/common/action_button.dart';
|
||||
import 'package:refilc_mobile_ui/common/empty.dart';
|
||||
import 'package:refilc_mobile_ui/common/filter_bar.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/absence/absence_subject_tile.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/absence/absence_viewable.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/statistics_tile.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/miss_tile.dart';
|
||||
import 'package:refilc_mobile_ui/pages/absences/absence_subject_view.dart';
|
||||
import 'package:refilc/ui/filter/sort.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'absences_page.i18n.dart';
|
||||
|
||||
enum AbsenceFilter { absences, delays, misses }
|
||||
|
||||
class SubjectAbsence {
|
||||
GradeSubject subject;
|
||||
List<Absence> absences;
|
||||
double percentage;
|
||||
|
||||
SubjectAbsence(
|
||||
{required this.subject, this.absences = const [], this.percentage = 0.0});
|
||||
}
|
||||
|
||||
class AbsencesPage extends StatefulWidget {
|
||||
const AbsencesPage({super.key});
|
||||
|
||||
@override
|
||||
AbsencesPageState createState() => AbsencesPageState();
|
||||
}
|
||||
|
||||
class AbsencesPageState extends State<AbsencesPage>
|
||||
with TickerProviderStateMixin {
|
||||
late UserProvider user;
|
||||
late AbsenceProvider absenceProvider;
|
||||
late TimetableProvider timetableProvider;
|
||||
late NoteProvider noteProvider;
|
||||
late UpdateProvider updateProvider;
|
||||
late String firstName;
|
||||
late TabController _tabController;
|
||||
late List<SubjectAbsence> absences = [];
|
||||
final Map<GradeSubject, Lesson> _lessonCount = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_tabController = TabController(length: 3, vsync: this);
|
||||
timetableProvider = Provider.of<TimetableProvider>(context, listen: false);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
for (final lesson in timetableProvider.getWeek(Week.current()) ?? []) {
|
||||
if (!lesson.isEmpty &&
|
||||
lesson.subject.id != '' &&
|
||||
lesson.lessonYearIndex != null) {
|
||||
_lessonCount.update(
|
||||
lesson.subject,
|
||||
(value) {
|
||||
if (lesson.lessonYearIndex! > value.lessonYearIndex!) {
|
||||
return lesson;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
ifAbsent: () => lesson,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void buildSubjectAbsences() {
|
||||
// ignore: no_leading_underscores_for_local_identifiers
|
||||
Map<GradeSubject, SubjectAbsence> _absences = {};
|
||||
|
||||
for (final absence in absenceProvider.absences) {
|
||||
if (absence.delay != 0) continue;
|
||||
|
||||
if (!_absences.containsKey(absence.subject)) {
|
||||
_absences[absence.subject] =
|
||||
SubjectAbsence(subject: absence.subject, absences: [absence]);
|
||||
} else {
|
||||
_absences[absence.subject]?.absences.add(absence);
|
||||
}
|
||||
}
|
||||
|
||||
_absences.forEach((subject, absence) {
|
||||
final absentLessonsOfSubject = absenceProvider.absences
|
||||
.where((e) => e.subject == subject && e.delay == 0)
|
||||
.length;
|
||||
final totalLessonsOfSubject = _lessonCount[subject]?.lessonYearIndex ?? 0;
|
||||
|
||||
double absentLessonsOfSubjectPercentage;
|
||||
|
||||
if (absentLessonsOfSubject <= totalLessonsOfSubject) {
|
||||
absentLessonsOfSubjectPercentage =
|
||||
absentLessonsOfSubject / totalLessonsOfSubject * 100;
|
||||
} else {
|
||||
absentLessonsOfSubjectPercentage = -1;
|
||||
}
|
||||
|
||||
_absences[subject]?.percentage =
|
||||
absentLessonsOfSubjectPercentage.clamp(-1, 100.0);
|
||||
});
|
||||
|
||||
absences = _absences.values.toList();
|
||||
absences.sort((a, b) => -a.percentage.compareTo(b.percentage));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = Provider.of<UserProvider>(context);
|
||||
absenceProvider = Provider.of<AbsenceProvider>(context);
|
||||
noteProvider = Provider.of<NoteProvider>(context);
|
||||
updateProvider = Provider.of<UpdateProvider>(context);
|
||||
timetableProvider = Provider.of<TimetableProvider>(context);
|
||||
|
||||
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
|
||||
buildSubjectAbsences();
|
||||
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: NestedScrollView(
|
||||
physics: const BouncingScrollPhysics(
|
||||
parent: AlwaysScrollableScrollPhysics()),
|
||||
headerSliverBuilder: (context, _) => [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
floating: false,
|
||||
snap: false,
|
||||
centerTitle: false,
|
||||
automaticallyImplyLeading: false,
|
||||
shadowColor: Theme.of(context).shadowColor,
|
||||
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Text(
|
||||
"Absences".i18n,
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context).text,
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
bottom: FilterBar(items: [
|
||||
Tab(text: "Absences".i18n),
|
||||
Tab(text: "Delays".i18n),
|
||||
Tab(text: "Misses".i18n),
|
||||
], controller: _tabController, disableFading: true),
|
||||
),
|
||||
],
|
||||
body: TabBarView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
controller: _tabController,
|
||||
children: List.generate(
|
||||
3, (index) => filterViewBuilder(context, index))),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<DateWidget> getFilterWidgets(AbsenceFilter activeData) {
|
||||
List<DateWidget> items = [];
|
||||
switch (activeData) {
|
||||
case AbsenceFilter.absences:
|
||||
for (var a in absences) {
|
||||
items.add(DateWidget(
|
||||
date: DateTime.fromMillisecondsSinceEpoch(0),
|
||||
widget: AbsenceSubjectTile(
|
||||
a.subject,
|
||||
percentage: a.percentage,
|
||||
excused: a.absences
|
||||
.where((a) => a.state == Justification.excused)
|
||||
.length,
|
||||
unexcused: a.absences
|
||||
.where((a) => a.state == Justification.unexcused)
|
||||
.length,
|
||||
pending: a.absences
|
||||
.where((a) => a.state == Justification.pending)
|
||||
.length,
|
||||
onTap: () => AbsenceSubjectView.show(a.subject, a.absences,
|
||||
context: context),
|
||||
),
|
||||
));
|
||||
}
|
||||
break;
|
||||
case AbsenceFilter.delays:
|
||||
for (var absence in absenceProvider.absences) {
|
||||
if (absence.delay != 0) {
|
||||
items.add(DateWidget(
|
||||
date: absence.date,
|
||||
widget: AbsenceViewable(
|
||||
absence,
|
||||
padding: EdgeInsets.zero,
|
||||
)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AbsenceFilter.misses:
|
||||
for (var note in noteProvider.notes) {
|
||||
if (note.type?.name == "HaziFeladatHiany" ||
|
||||
note.type?.name == "Felszereleshiany") {
|
||||
items.add(DateWidget(
|
||||
date: note.date,
|
||||
widget: MissTile(note),
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
Widget filterViewBuilder(context, int activeData) {
|
||||
List<Widget> filterWidgets = [];
|
||||
|
||||
if (activeData > 0) {
|
||||
filterWidgets = sortDateWidgets(
|
||||
context,
|
||||
dateWidgets: getFilterWidgets(AbsenceFilter.values[activeData]),
|
||||
padding: EdgeInsets.zero,
|
||||
hasShadow: true,
|
||||
);
|
||||
} else {
|
||||
filterWidgets = [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: Panel(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Subjects".i18n),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 4.0),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.0)),
|
||||
title: Text("attention".i18n),
|
||||
content: Text("attention_body".i18n),
|
||||
actions: [
|
||||
ActionButton(
|
||||
label: "Ok",
|
||||
onTap: () => Navigator.of(context).pop())
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
padding: EdgeInsets.zero,
|
||||
splashRadius: 24.0,
|
||||
visualDensity: VisualDensity.compact,
|
||||
constraints: BoxConstraints.tight(const Size(42.0, 42.0)),
|
||||
icon: const Icon(FeatherIcons.info),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: PageTransitionSwitcher(
|
||||
transitionBuilder: (
|
||||
Widget child,
|
||||
Animation<double> primaryAnimation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return FadeThroughTransition(
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
fillColor: Theme.of(context).colorScheme.background,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: getFilterWidgets(AbsenceFilter.values[activeData])
|
||||
.map((e) => e.widget)
|
||||
.cast<Widget>()
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: RefreshIndicator(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
onRefresh: () async {
|
||||
await absenceProvider.fetch();
|
||||
await noteProvider.fetch();
|
||||
},
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: max(filterWidgets.length + (activeData <= 1 ? 1 : 0), 1),
|
||||
itemBuilder: (context, index) {
|
||||
if (filterWidgets.isNotEmpty) {
|
||||
if ((index == 0 && activeData == 1) ||
|
||||
(index == 0 && activeData == 0)) {
|
||||
int value1 = 0;
|
||||
int value2 = 0;
|
||||
String title1 = "";
|
||||
String title2 = "";
|
||||
String suffix = "";
|
||||
|
||||
if (activeData == AbsenceFilter.absences.index) {
|
||||
value1 = absenceProvider.absences
|
||||
.where((e) =>
|
||||
e.delay == 0 && e.state == Justification.excused)
|
||||
.length;
|
||||
value2 = absenceProvider.absences
|
||||
.where((e) =>
|
||||
e.delay == 0 && e.state == Justification.unexcused)
|
||||
.length;
|
||||
title1 = "stat_1".i18n;
|
||||
title2 = "stat_2".i18n;
|
||||
suffix = " ${"hr".i18n}";
|
||||
} else if (activeData == AbsenceFilter.delays.index) {
|
||||
value1 = absenceProvider.absences
|
||||
.where((e) =>
|
||||
e.delay != 0 && e.state == Justification.excused)
|
||||
.map((e) => e.delay)
|
||||
.fold(0, (a, b) => a + b);
|
||||
value2 = absenceProvider.absences
|
||||
.where((e) =>
|
||||
e.delay != 0 && e.state == Justification.unexcused)
|
||||
.map((e) => e.delay)
|
||||
.fold(0, (a, b) => a + b);
|
||||
title1 = "stat_3".i18n;
|
||||
title2 = "stat_4".i18n;
|
||||
suffix = " ${"min".i18n}";
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 24.0, left: 24.0, right: 24.0),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: StatisticsTile(
|
||||
title: AutoSizeText(
|
||||
title1,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
valueSuffix: suffix,
|
||||
value: value1.toDouble(),
|
||||
decimal: false,
|
||||
color: AppColors.of(context).green,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 24.0),
|
||||
Expanded(
|
||||
child: StatisticsTile(
|
||||
title: AutoSizeText(
|
||||
title2,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
valueSuffix: suffix,
|
||||
value: value2.toDouble(),
|
||||
decimal: false,
|
||||
color: AppColors.of(context).red,
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 6.0),
|
||||
child: filterWidgets[index - (activeData <= 1 ? 1 : 0)],
|
||||
);
|
||||
} else {
|
||||
return activeData == 1
|
||||
? Empty(subtitle: "emptyDelays".i18n)
|
||||
: Empty(subtitle: "emptyMisses".i18n);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension ScreensLocalization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"Absences": "Absences",
|
||||
"Delays": "Delays",
|
||||
"Misses": "Misses",
|
||||
"emptyDelays": "You have no delays.",
|
||||
"emptyMisses": "You have no missing homeworks or equipments.",
|
||||
"stat_1": "Excused Absences",
|
||||
"stat_2": "Unexcused Absences",
|
||||
"stat_3": "Excused Delay",
|
||||
"stat_4": "Unexcused Delay",
|
||||
"min": "min",
|
||||
"hr": "hrs",
|
||||
"Subjects": "Subjects",
|
||||
"attention": "Attention!",
|
||||
"attention_body": "Percentage calculations are only an approximation so they may not be accurate.",
|
||||
},
|
||||
"hu_hu": {
|
||||
"Absences": "Hiányzások",
|
||||
"Delays": "Késések",
|
||||
"Misses": "Hiányok",
|
||||
"emptyDelays": "Nincsenek késéseid.",
|
||||
"emptyMisses": "Nincsenek hiányzó házi feladataid, felszereléseid.",
|
||||
"stat_1": "Igazolt hiányzások",
|
||||
"stat_2": "Igazolatlan hiányzások",
|
||||
"stat_3": "Igazolt Késés",
|
||||
"stat_4": "Igazolatlan Késés",
|
||||
"min": "perc",
|
||||
"hr": "óra",
|
||||
"Subjects": "Tantárgyak",
|
||||
"attention": "Figyelem!",
|
||||
"attention_body": "A százalékos számítások csak közelítések, ezért előfordulhat, hogy nem pontosak.",
|
||||
},
|
||||
"de_de": {
|
||||
"Absences": "Fehlen",
|
||||
"Delays": "Verspätung",
|
||||
"Misses": "Fehlt",
|
||||
"emptyDelays": "Sie haben keine Abwesenheiten.",
|
||||
"emptyMisses": "Sie haben noch keine fehlende Hausaufgaben oder Austattung.",
|
||||
"stat_1": "Entschuldigte Fehlen",
|
||||
"stat_2": "Unentschuldigte Fehlen",
|
||||
"stat_3": "Entschuldigte Verspätung",
|
||||
"stat_4": "Unentschuldigte Verspätung",
|
||||
"min": "min",
|
||||
"hr": "hrs",
|
||||
"Subjects": "Fächer",
|
||||
"attention": "Achtung!",
|
||||
"attention_body": "Prozentberechnungen sind nur eine Annäherung und können daher ungenau sein.",
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/utils/format.dart';
|
||||
import 'package:refilc_kreta_api/providers/grade_provider.dart';
|
||||
import 'package:refilc/helpers/average_helper.dart';
|
||||
import 'package:refilc/helpers/subject.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:refilc_kreta_api/models/subject.dart';
|
||||
import 'package:refilc_mobile_ui/common/average_display.dart';
|
||||
import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_mobile_ui/common/trend_display.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/cretification/certification_tile.dart';
|
||||
import 'package:refilc/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/grade/grade_viewable.dart';
|
||||
import 'package:refilc_mobile_ui/common/hero_scrollview.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/calculator/grade_calculator.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/calculator/grade_calculator_provider.dart';
|
||||
import 'package:refilc_desktop_ui/pages/grades/grades_count.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/graph.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/subject_grades_container.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'grades_page.i18n.dart';
|
||||
//import 'package:refilc_plus/ui/mobile/goal_planner/new_goal.dart';
|
||||
|
||||
class GradeSubjectView extends StatefulWidget {
|
||||
const GradeSubjectView(this.subject, {super.key, this.groupAverage = 0.0});
|
||||
|
||||
final GradeSubject subject;
|
||||
final double groupAverage;
|
||||
|
||||
void push(BuildContext context, {bool root = false}) {
|
||||
Navigator.of(context, rootNavigator: root)
|
||||
.push(CupertinoPageRoute(builder: (context) => this));
|
||||
}
|
||||
|
||||
@override
|
||||
State<GradeSubjectView> createState() => _GradeSubjectViewState();
|
||||
}
|
||||
|
||||
class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
// Controllers
|
||||
PersistentBottomSheetController? _sheetController;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
List<Widget> gradeTiles = [];
|
||||
|
||||
// Providers
|
||||
late GradeProvider gradeProvider;
|
||||
late GradeCalculatorProvider calculatorProvider;
|
||||
late SettingsProvider settingsProvider;
|
||||
|
||||
late double average;
|
||||
late Widget gradeGraph;
|
||||
|
||||
bool gradeCalcMode = false;
|
||||
|
||||
List<Grade> getSubjectGrades(GradeSubject subject) => !gradeCalcMode
|
||||
? gradeProvider.grades.where((e) => e.subject == subject).toList()
|
||||
: calculatorProvider.grades.where((e) => e.subject == subject).toList();
|
||||
|
||||
bool showGraph(List<Grade> subjectGrades) {
|
||||
if (gradeCalcMode) return true;
|
||||
|
||||
final gradeDates = subjectGrades.map((e) => e.date.millisecondsSinceEpoch);
|
||||
final maxGradeDate = gradeDates.fold(0, max);
|
||||
final minGradeDate = gradeDates.fold(0, min);
|
||||
if (maxGradeDate - minGradeDate < const Duration(days: 5).inMilliseconds) {
|
||||
return false; // naplo/#78
|
||||
}
|
||||
|
||||
return subjectGrades.where((e) => e.type == GradeType.midYear).length > 1;
|
||||
}
|
||||
|
||||
void buildTiles(List<Grade> subjectGrades) {
|
||||
List<Widget> tiles = [];
|
||||
|
||||
if (showGraph(subjectGrades)) {
|
||||
tiles.add(gradeGraph);
|
||||
} else {
|
||||
tiles.add(Container(height: 24.0));
|
||||
}
|
||||
|
||||
// ignore: no_leading_underscores_for_local_identifiers
|
||||
List<Widget> _gradeTiles = [];
|
||||
|
||||
if (!gradeCalcMode) {
|
||||
subjectGrades.sort((a, b) => -a.date.compareTo(b.date));
|
||||
for (var grade in subjectGrades) {
|
||||
if (grade.type == GradeType.midYear) {
|
||||
_gradeTiles.add(GradeViewable(grade));
|
||||
} else {
|
||||
_gradeTiles.add(CertificationTile(grade, padding: EdgeInsets.zero));
|
||||
}
|
||||
}
|
||||
} else if (subjectGrades.isNotEmpty) {
|
||||
subjectGrades.sort((a, b) => -a.date.compareTo(b.date));
|
||||
for (var grade in subjectGrades) {
|
||||
_gradeTiles.add(GradeTile(grade));
|
||||
}
|
||||
}
|
||||
tiles.add(
|
||||
PageTransitionSwitcher(
|
||||
transitionBuilder: (
|
||||
Widget child,
|
||||
Animation<double> primaryAnimation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return SharedAxisTransition(
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
transitionType: SharedAxisTransitionType.vertical,
|
||||
fillColor: Colors.transparent,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _gradeTiles.isNotEmpty
|
||||
? Panel(
|
||||
key: ValueKey(gradeCalcMode),
|
||||
title: Text(
|
||||
gradeCalcMode ? "Ghost Grades".i18n : "Grades".i18n,
|
||||
),
|
||||
child: Column(
|
||||
children: _gradeTiles,
|
||||
))
|
||||
: const SizedBox(),
|
||||
),
|
||||
);
|
||||
|
||||
tiles.add(Padding(
|
||||
padding: EdgeInsets.only(bottom: !gradeCalcMode ? 24.0 : 250.0)));
|
||||
gradeTiles = List.castFrom(tiles);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
gradeProvider = Provider.of<GradeProvider>(context);
|
||||
calculatorProvider = Provider.of<GradeCalculatorProvider>(context);
|
||||
settingsProvider = Provider.of<SettingsProvider>(context);
|
||||
|
||||
List<Grade> subjectGrades = getSubjectGrades(widget.subject).toList();
|
||||
average = AverageHelper.averageEvals(subjectGrades);
|
||||
final prevAvg = subjectGrades.isNotEmpty
|
||||
? AverageHelper.averageEvals(subjectGrades
|
||||
.where((e) => e.date.isBefore(subjectGrades
|
||||
.reduce((v, e) => e.date.isAfter(v.date) ? e : v)
|
||||
.date
|
||||
.subtract(const Duration(days: 30))))
|
||||
.toList())
|
||||
: 0.0;
|
||||
|
||||
gradeGraph = Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0, bottom: 8.0),
|
||||
child: Panel(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("annual_average".i18n),
|
||||
if (average != prevAvg)
|
||||
TrendDisplay(current: average, previous: prevAvg),
|
||||
],
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 12.0, right: 12.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GradeGraph(subjectGrades,
|
||||
dayThreshold: 5, classAvg: widget.groupAverage)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: GradesCount(grades: subjectGrades),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!gradeCalcMode) {
|
||||
buildTiles(subjectGrades);
|
||||
} else {
|
||||
List<Grade> ghostGrades = calculatorProvider.ghosts
|
||||
.where((e) => e.subject == widget.subject)
|
||||
.toList();
|
||||
buildTiles(ghostGrades);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
floatingActionButtonLocation: ExpandableFab.location,
|
||||
floatingActionButton: Visibility(
|
||||
visible: !gradeCalcMode &&
|
||||
subjectGrades
|
||||
.where((e) => e.type == GradeType.midYear)
|
||||
.isNotEmpty,
|
||||
child: ExpandableFab(
|
||||
type: ExpandableFabType.up,
|
||||
distance: 50,
|
||||
children: [
|
||||
FloatingActionButton.small(
|
||||
child: const Icon(FeatherIcons.plus),
|
||||
onPressed: () {
|
||||
gradeCalc(context);
|
||||
},
|
||||
),
|
||||
// FloatingActionButton.small(
|
||||
// child: const Icon(FeatherIcons.flag, size: 20.0),
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).push(CupertinoPageRoute(builder: (context) => PremiumGoalplannerNewGoalScreen(subject: widget.subject)));
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {},
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
child: HeroScrollView(
|
||||
onClose: () {
|
||||
if (_sheetController != null && gradeCalcMode) {
|
||||
_sheetController!.close();
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
navBarItems: [
|
||||
const SizedBox(width: 6.0),
|
||||
if (widget.groupAverage != 0)
|
||||
Center(
|
||||
child: AverageDisplay(
|
||||
average: widget.groupAverage, border: true)),
|
||||
const SizedBox(width: 6.0),
|
||||
if (average != 0)
|
||||
Center(child: AverageDisplay(average: average)),
|
||||
const SizedBox(width: 12.0),
|
||||
],
|
||||
icon: SubjectIcon.resolveVariant(
|
||||
subject: widget.subject, context: context),
|
||||
scrollController: _scrollController,
|
||||
title: widget.subject.renamedTo ?? widget.subject.name.capital(),
|
||||
italic: widget.subject.isRenamed &&
|
||||
settingsProvider.renamedSubjectsItalics,
|
||||
child: SubjectGradesContainer(
|
||||
child: CupertinoScrollbar(
|
||||
child: ListView.builder(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) => gradeTiles[index],
|
||||
itemCount: gradeTiles.length,
|
||||
),
|
||||
),
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
void gradeCalc(BuildContext context) {
|
||||
// Scroll to the top of the page
|
||||
_scrollController.animateTo(75,
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.ease);
|
||||
|
||||
calculatorProvider.clear();
|
||||
calculatorProvider.addAllGrades(gradeProvider.grades);
|
||||
|
||||
_sheetController = _scaffoldKey.currentState?.showBottomSheet(
|
||||
(context) => RoundedBottomSheet(
|
||||
borderRadius: 14.0,
|
||||
child: GradeCalculator(widget.subject)),
|
||||
backgroundColor: const Color(0x00000000),
|
||||
elevation: 12.0,
|
||||
);
|
||||
|
||||
// Hide the fab and grades
|
||||
setState(() {
|
||||
gradeCalcMode = true;
|
||||
});
|
||||
|
||||
_sheetController!.closed.then((value) {
|
||||
// Show fab and grades
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
gradeCalcMode = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:refilc_desktop_ui/pages/grades/grades_count_item.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class GradesCount extends StatelessWidget {
|
||||
const GradesCount({super.key, required this.grades});
|
||||
|
||||
final List<Grade> grades;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<int> gradesCount = List.generate(5,
|
||||
(int index) => grades.where((e) => e.value.value == index + 1).length);
|
||||
|
||||
return Container(
|
||||
width: 75,
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 6.0, top: 6.0, left: 12.0, right: 0.0),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: gradesCount
|
||||
.mapIndexed(
|
||||
(index, e) => GradesCountItem(count: e, value: index + 1))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import 'package:refilc/ui/widgets/grade/grade_tile.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradesCountItem extends StatelessWidget {
|
||||
const GradesCountItem({super.key, required this.count, required this.value});
|
||||
|
||||
final int count;
|
||||
final int value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(children: [
|
||||
TextSpan(
|
||||
text: count.toString(),
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const TextSpan(
|
||||
text: "x",
|
||||
style: TextStyle(fontSize: 13.0),
|
||||
),
|
||||
]),
|
||||
style: const TextStyle(fontSize: 15.0),
|
||||
),
|
||||
const SizedBox(width: 5.0),
|
||||
GradeValueWidget(GradeValue(value, "Value", "Value", 100),
|
||||
size: 19.0, fill: true, shadow: false),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,314 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:refilc/api/providers/update_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/grade_provider.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc_kreta_api/models/grade.dart';
|
||||
import 'package:refilc_kreta_api/models/subject.dart';
|
||||
import 'package:refilc_kreta_api/models/group_average.dart';
|
||||
import 'package:refilc_mobile_ui/common/average_display.dart';
|
||||
import 'package:refilc_mobile_ui/common/empty.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/statistics_tile.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/grade/grade_subject_tile.dart';
|
||||
import 'package:refilc_mobile_ui/common/trend_display.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/fail_warning.dart';
|
||||
import 'package:refilc_desktop_ui/pages/grades/grades_count.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/graph.dart';
|
||||
import 'package:refilc_desktop_ui/pages/grades/grade_subject_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc/helpers/average_helper.dart';
|
||||
import 'package:refilc_mobile_ui/pages/grades/average_selector.dart';
|
||||
import 'grades_page.i18n.dart';
|
||||
|
||||
class GradesPage extends StatefulWidget {
|
||||
const GradesPage({super.key});
|
||||
|
||||
@override
|
||||
GradesPageState createState() => GradesPageState();
|
||||
}
|
||||
|
||||
class GradesPageState extends State<GradesPage> {
|
||||
late UserProvider user;
|
||||
late GradeProvider gradeProvider;
|
||||
late UpdateProvider updateProvider;
|
||||
late String firstName;
|
||||
late Widget yearlyGraph;
|
||||
List<Widget> subjectTiles = [];
|
||||
|
||||
int avgDropValue = 0;
|
||||
|
||||
List<Grade> getSubjectGrades(GradeSubject subject, {int days = 0}) =>
|
||||
gradeProvider.grades
|
||||
.where((e) =>
|
||||
e.subject == subject &&
|
||||
e.type == GradeType.midYear &&
|
||||
(days == 0 ||
|
||||
e.date
|
||||
.isBefore(DateTime.now().subtract(Duration(days: days)))))
|
||||
.toList();
|
||||
|
||||
void generateTiles() {
|
||||
List<GradeSubject> subjects = gradeProvider.grades
|
||||
.map((e) => e.subject)
|
||||
.toSet()
|
||||
.toList()
|
||||
..sort((a, b) => a.name.compareTo(b.name));
|
||||
List<Widget> tiles = [];
|
||||
|
||||
Map<GradeSubject, double> subjectAvgs = {};
|
||||
|
||||
tiles.addAll(subjects.map((subject) {
|
||||
List<Grade> subjectGrades = getSubjectGrades(subject);
|
||||
|
||||
double avg = AverageHelper.averageEvals(subjectGrades);
|
||||
double averageBefore = 0.0;
|
||||
|
||||
if (avgDropValue != 0) {
|
||||
List<Grade> gradesBefore =
|
||||
getSubjectGrades(subject, days: avgDropValue);
|
||||
averageBefore =
|
||||
avgDropValue == 0 ? 0.0 : AverageHelper.averageEvals(gradesBefore);
|
||||
}
|
||||
var nullavg = GroupAverage(average: 0.0, subject: subject, uid: "0");
|
||||
double groupAverage = gradeProvider.groupAverages
|
||||
.firstWhere((e) => e.subject == subject, orElse: () => nullavg)
|
||||
.average;
|
||||
|
||||
if (avg != 0) subjectAvgs[subject] = avg;
|
||||
|
||||
return GradeSubjectTile(
|
||||
subject,
|
||||
averageBefore: averageBefore,
|
||||
average: avg,
|
||||
groupAverage: avgDropValue == 0 ? groupAverage : 0.0,
|
||||
onTap: () {
|
||||
GradeSubjectView(subject, groupAverage: groupAverage)
|
||||
.push(context, root: true);
|
||||
},
|
||||
);
|
||||
}));
|
||||
|
||||
if (tiles.isNotEmpty) {
|
||||
tiles.insert(0, yearlyGraph);
|
||||
tiles.insert(1, FailWarning(subjectAvgs: subjectAvgs));
|
||||
tiles.insert(
|
||||
2,
|
||||
PanelTitle(
|
||||
title: Text(avgDropValue == 0
|
||||
? "Subjects".i18n
|
||||
: "Subjects_changes".i18n)));
|
||||
tiles.insert(3, const PanelHeader(padding: EdgeInsets.only(top: 12.0)));
|
||||
tiles.add(const PanelFooter(padding: EdgeInsets.only(bottom: 12.0)));
|
||||
tiles.add(const Padding(padding: EdgeInsets.only(bottom: 24.0)));
|
||||
} else {
|
||||
tiles.insert(
|
||||
0,
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0),
|
||||
child: Empty(subtitle: "empty".i18n),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
double subjectAvg = subjectAvgs.isNotEmpty
|
||||
? subjectAvgs.values.fold(0.0, (double a, double b) => a + b) /
|
||||
subjectAvgs.length
|
||||
: 0.0;
|
||||
final double classAvg = gradeProvider.groupAverages.isNotEmpty
|
||||
? gradeProvider.groupAverages
|
||||
.map((e) => e.average)
|
||||
.fold(0.0, (double a, double b) => a + b) /
|
||||
gradeProvider.groupAverages.length
|
||||
: 0.0;
|
||||
|
||||
if (subjectAvg > 0) {
|
||||
tiles.add(Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: StatisticsTile(
|
||||
fill: true,
|
||||
title: AutoSizeText(
|
||||
"subjectavg".i18n,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
value: subjectAvg,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 24.0),
|
||||
Expanded(
|
||||
child: StatisticsTile(
|
||||
outline: true,
|
||||
title: AutoSizeText(
|
||||
// https://discord.com/channels/1111649116020285532/1153397476578050130
|
||||
"classavg".i18n,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
wrapWords: false,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
value: classAvg,
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
// padding
|
||||
tiles.add(const SizedBox(height: 32.0));
|
||||
|
||||
subjectTiles = List.castFrom(tiles);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = Provider.of<UserProvider>(context);
|
||||
gradeProvider = Provider.of<GradeProvider>(context);
|
||||
updateProvider = Provider.of<UpdateProvider>(context);
|
||||
|
||||
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
|
||||
final double totalClassAvg = gradeProvider.groupAverages.isEmpty
|
||||
? 0.0
|
||||
: gradeProvider.groupAverages
|
||||
.map((e) => e.average)
|
||||
.fold(0.0, (double a, double b) => a + b) /
|
||||
gradeProvider.groupAverages.length;
|
||||
|
||||
final now = gradeProvider.grades.isNotEmpty
|
||||
? gradeProvider.grades
|
||||
.reduce((v, e) => e.date.isAfter(v.date) ? e : v)
|
||||
.date
|
||||
: DateTime.now();
|
||||
|
||||
final currentStudentAvg = AverageHelper.averageEvals(gradeProvider.grades
|
||||
.where((e) => e.type == GradeType.midYear)
|
||||
.toList());
|
||||
final prevStudentAvg = AverageHelper.averageEvals(gradeProvider.grades
|
||||
.where((e) => e.type == GradeType.midYear)
|
||||
.where((e) => e.date.isBefore(now.subtract(const Duration(days: 30))))
|
||||
.toList());
|
||||
|
||||
List<Grade> graphGrades = gradeProvider.grades
|
||||
.where((e) =>
|
||||
e.type == GradeType.midYear &&
|
||||
(avgDropValue == 0 ||
|
||||
e.date.isAfter(
|
||||
DateTime.now().subtract(Duration(days: avgDropValue)))))
|
||||
.toList();
|
||||
|
||||
yearlyGraph = Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
child: Panel(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
AverageSelector(
|
||||
value: avgDropValue,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
avgDropValue = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
// if (totalClassAvg >= 1.0) AverageDisplay(average: totalClassAvg, border: true),
|
||||
// const SizedBox(width: 4.0),
|
||||
TrendDisplay(
|
||||
previous: prevStudentAvg, current: currentStudentAvg),
|
||||
if (gradeProvider.grades
|
||||
.where((e) => e.type == GradeType.midYear)
|
||||
.isNotEmpty)
|
||||
AverageDisplay(average: currentStudentAvg),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 12.0, right: 12.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GradeGraph(graphGrades,
|
||||
dayThreshold: 2, classAvg: totalClassAvg)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: GradesCount(grades: graphGrades),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
generateTiles();
|
||||
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(top: 9.0),
|
||||
child: NestedScrollView(
|
||||
physics: const BouncingScrollPhysics(
|
||||
parent: AlwaysScrollableScrollPhysics()),
|
||||
headerSliverBuilder: (context, _) => [
|
||||
SliverAppBar(
|
||||
centerTitle: false,
|
||||
pinned: true,
|
||||
floating: false,
|
||||
snap: false,
|
||||
automaticallyImplyLeading: false,
|
||||
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Text(
|
||||
"Grades".i18n,
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context).text,
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
shadowColor: Theme.of(context).shadowColor,
|
||||
),
|
||||
],
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () => gradeProvider.fetch(),
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: max(subjectTiles.length, 1),
|
||||
itemBuilder: (context, index) {
|
||||
if (subjectTiles.isNotEmpty) {
|
||||
EdgeInsetsGeometry panelPadding =
|
||||
const EdgeInsets.symmetric(horizontal: 24.0);
|
||||
|
||||
if (subjectTiles[index].runtimeType == GradeSubjectTile) {
|
||||
return Padding(
|
||||
padding: panelPadding,
|
||||
child: PanelBody(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: subjectTiles[index],
|
||||
));
|
||||
} else {
|
||||
return Padding(
|
||||
padding: panelPadding, child: subjectTiles[index]);
|
||||
}
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"Grades": "Grades",
|
||||
"Ghost Grades": "Grades",
|
||||
"Subjects": "Subjects",
|
||||
"Subjects_changes": "Subject Differences",
|
||||
"empty": "You don't have any subjects.",
|
||||
"annual_average": "Annual average",
|
||||
"3_months_average": "3 Monthly Average",
|
||||
"30_days_average": "Monthly Average",
|
||||
"14_days_average": "2 Weekly Average",
|
||||
"7_days_average": "Weekly Average",
|
||||
"subjectavg": "Subject Average",
|
||||
"classavg": "Class Average",
|
||||
"fail_warning": "Failure warning",
|
||||
"fail_warning_description": "You are failing %d subjects!"
|
||||
.one("You are failing a subject!"),
|
||||
},
|
||||
"hu_hu": {
|
||||
"Grades": "Jegyek",
|
||||
"Ghost Grades": "Szellem jegyek",
|
||||
"Subjects": "Tantárgyak",
|
||||
"Subjects_changes": "Tantárgyi változások",
|
||||
"empty": "Még nincs egy tárgyad sem.",
|
||||
"annual_average": "Éves átlag",
|
||||
"3_months_average": "Háromhavi átlag",
|
||||
"30_days_average": "Havi átlag",
|
||||
"14_days_average": "Kétheti átlag",
|
||||
"7_days_average": "Heti átlag",
|
||||
"subjectavg": "Tantárgyi átlag",
|
||||
"classavg": "Osztályátlag",
|
||||
"fail_warning": "Bukás figyelmeztető",
|
||||
"fail_warning_description": "Bukásra állsz %d tantárgyból",
|
||||
},
|
||||
"de_de": {
|
||||
"Grades": "Noten",
|
||||
"Ghost Grades": "Geist Noten",
|
||||
"Subjects": "Fächer",
|
||||
"Subjects_changes": "Betreff Änderungen",
|
||||
"empty": "Sie haben keine Fächer.",
|
||||
"annual_average": "Jahresdurchschnitt",
|
||||
"3_months_average": "Drei-Monats-Durchschnitt",
|
||||
"30_days_average": "Monatsdurchschnitt",
|
||||
"14_days_average": "Vierzehntägiger Durchschnitt",
|
||||
"7_days_average": "Wöchentlicher Durchschnitt",
|
||||
"subjectavg": "Fächer Durchschnitt",
|
||||
"classavg": "Klassendurchschnitt",
|
||||
"fail_warning": "Ausfallwarnung",
|
||||
"fail_warning_description": "Sie werden in %d des Fachs durchfallen",
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/ui/date_widget.dart';
|
||||
import 'package:refilc_mobile_ui/common/filter_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:animated_list_plus/animated_list_plus.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc/ui/filter/widgets.dart';
|
||||
import 'package:refilc/ui/filter/sort.dart';
|
||||
import 'home_page.i18n.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late UserProvider user;
|
||||
late SettingsProvider settings;
|
||||
|
||||
late TabController _tabController;
|
||||
late PageController _pageController;
|
||||
|
||||
late String greeting;
|
||||
late String firstName;
|
||||
|
||||
late List<String> listOrder;
|
||||
static const pageCount = 4;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_tabController = TabController(length: pageCount, vsync: this);
|
||||
_pageController = PageController();
|
||||
|
||||
listOrder = List.generate(pageCount, (index) => "$index");
|
||||
|
||||
user = Provider.of<UserProvider>(context, listen: false);
|
||||
|
||||
DateTime now = DateTime.now();
|
||||
if (now.isBefore(DateTime(now.year, DateTime.august, 31)) &&
|
||||
now.isAfter(DateTime(now.year, DateTime.june, 14))) {
|
||||
greeting = "goodrest";
|
||||
} else if (now.month == user.student?.birth.month &&
|
||||
now.day == user.student?.birth.day) {
|
||||
greeting = "happybirthday";
|
||||
} else if (now.month == DateTime.december &&
|
||||
now.day >= 24 &&
|
||||
now.day <= 26) {
|
||||
greeting = "merryxmas";
|
||||
} else if (now.month == DateTime.january && now.day == 1) {
|
||||
greeting = "happynewyear";
|
||||
} else if (now.hour >= 18) {
|
||||
greeting = "goodevening";
|
||||
} else if (now.hour >= 12) {
|
||||
greeting = "goodafternoon";
|
||||
} else if (now.hour >= 4) {
|
||||
greeting = "goodmorning";
|
||||
} else {
|
||||
greeting = "goodevening";
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = Provider.of<UserProvider>(context);
|
||||
settings = Provider.of<SettingsProvider>(context);
|
||||
|
||||
List<String> nameParts = user.name?.split(" ") ?? ["?"];
|
||||
if (!settings.presentationMode) {
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
} else {
|
||||
firstName = "Béla";
|
||||
}
|
||||
|
||||
return SafeArea(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Greeting
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 32.0, top: 24.0, bottom: 12.0),
|
||||
child: Text(
|
||||
greeting.i18n.fill([firstName]),
|
||||
overflow: TextOverflow.fade,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 24.0,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: FilterBar(
|
||||
items: [
|
||||
Tab(text: "All".i18n),
|
||||
Tab(text: "Grades".i18n),
|
||||
Tab(text: "Messages".i18n),
|
||||
Tab(text: "Absences".i18n),
|
||||
],
|
||||
controller: _tabController,
|
||||
onTap: (i) async {
|
||||
int selectedPage = _pageController.page!.round();
|
||||
|
||||
if (i == selectedPage) return;
|
||||
if (_pageController.page?.roundToDouble() !=
|
||||
_pageController.page) {
|
||||
_pageController.animateToPage(i,
|
||||
curve: Curves.easeIn, duration: kTabScrollDuration);
|
||||
return;
|
||||
}
|
||||
|
||||
// swap current page with target page
|
||||
setState(() {
|
||||
_pageController.jumpToPage(i);
|
||||
String currentList = listOrder[selectedPage];
|
||||
listOrder[selectedPage] = listOrder[i];
|
||||
listOrder[i] = currentList;
|
||||
});
|
||||
},
|
||||
disableFading: true,
|
||||
),
|
||||
),
|
||||
|
||||
// Data filters
|
||||
Expanded(
|
||||
child: PageView.custom(
|
||||
controller: _pageController,
|
||||
childrenDelegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
return FutureBuilder<List<DateWidget>>(
|
||||
key: ValueKey<String>(listOrder[index]),
|
||||
future: getFilterWidgets(homeFilters[index],
|
||||
context: context),
|
||||
builder: (context, dateWidgets) => dateWidgets.data !=
|
||||
null
|
||||
? ImplicitlyAnimatedList<Widget>(
|
||||
items: sortDateWidgets(context,
|
||||
dateWidgets: dateWidgets.data!),
|
||||
itemBuilder: filterItemBuilder,
|
||||
spawnIsolate: false,
|
||||
areItemsTheSame: (a, b) => a.key == b.key,
|
||||
physics: const BouncingScrollPhysics(
|
||||
parent: AlwaysScrollableScrollPhysics()),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24.0),
|
||||
)
|
||||
: Container(),
|
||||
);
|
||||
},
|
||||
childCount: 4,
|
||||
findChildIndexCallback: (Key key) {
|
||||
final ValueKey<String> valueKey =
|
||||
key as ValueKey<String>;
|
||||
final String data = valueKey.value;
|
||||
return listOrder.indexOf(data);
|
||||
},
|
||||
),
|
||||
physics: const PageScrollPhysics()
|
||||
.applyTo(const BouncingScrollPhysics()),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"goodmorning": "Good morning, %s!",
|
||||
"goodafternoon": "Good afternoon, %s!",
|
||||
"goodevening": "Good evening, %s!",
|
||||
"goodrest": "⛱️ Have a nice holiday, %s!",
|
||||
"happybirthday": "🎂 Happy birthday, %s!",
|
||||
"merryxmas": "🎄 Merry Christmas, %s!",
|
||||
"happynewyear": "🎉 Happy New Year, %s!",
|
||||
"empty": "Nothing to see here.",
|
||||
"All": "All",
|
||||
"Grades": "Grades",
|
||||
"Messages": "Messages",
|
||||
"Absences": "Absences",
|
||||
"update_available": "Update Available",
|
||||
"missed_exams": "You missed %s exams this week.".one("You missed an exam this week."),
|
||||
"missed_exam_contact": "Contact %s, to resolve it!",
|
||||
},
|
||||
"hu_hu": {
|
||||
"goodmorning": "Jó reggelt, %s!",
|
||||
"goodafternoon": "Szép napot, %s!",
|
||||
"goodevening": "Szép estét, %s!",
|
||||
"goodrest": "⛱️ Jó szünetet, %s!",
|
||||
"happybirthday": "🎂 Boldog születésnapot, %s!",
|
||||
"merryxmas": "🎄 Boldog Karácsonyt, %s!",
|
||||
"happynewyear": "🎉 Boldog új évet, %s!",
|
||||
"empty": "Nincs itt semmi látnivaló.",
|
||||
"All": "Összes",
|
||||
"Grades": "Jegyek",
|
||||
"Messages": "Üzenetek",
|
||||
"Absences": "Hiányok",
|
||||
"update_available": "Frissítés elérhető",
|
||||
"missed_exams": "Ezen a héten hiányoztál %s dolgozatról.".one("Ezen a héten hiányoztál egy dolgozatról."),
|
||||
"missed_exam_contact": "Keresd %s-t, ha pótolni szeretnéd!",
|
||||
},
|
||||
"de_de": {
|
||||
"goodmorning": "Guten morgen, %s!",
|
||||
"goodafternoon": "Guten Tag, %s!",
|
||||
"goodevening": "Guten Abend, %s!",
|
||||
"goodrest": "⛱️ Schöne Ferien, %s!",
|
||||
"happybirthday": "🎂 Alles Gute zum Geburtstag, %s!",
|
||||
"merryxmas": "🎄 Frohe Weihnachten, %s!",
|
||||
"happynewyear": "🎉 Frohes neues Jahr, %s!",
|
||||
"empty": "Hier gibt es nichts zu sehen.",
|
||||
"All": "Alles",
|
||||
"Grades": "Noten",
|
||||
"Messages": "Nachrichten",
|
||||
"Absences": "Fehlen",
|
||||
"update_available": "Update verfügbar",
|
||||
"missed_exams": "Diese Woche haben Sie %s Prüfungen verpasst.".one("Diese Woche haben Sie eine Prüfung verpasst."),
|
||||
"missed_exam_contact": "Wenden Sie sich an %s, um sie zu erneuern!",
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:refilc/api/providers/update_provider.dart';
|
||||
import 'package:refilc/ui/date_widget.dart';
|
||||
import 'package:refilc_kreta_api/providers/message_provider.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc_kreta_api/models/message.dart';
|
||||
import 'package:refilc_mobile_ui/common/empty.dart';
|
||||
import 'package:refilc_mobile_ui/common/filter_bar.dart';
|
||||
import 'package:refilc/ui/filter/sort.dart';
|
||||
import 'package:refilc_mobile_ui/common/widgets/message/message_viewable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'messages_page.i18n.dart';
|
||||
|
||||
class MessagesPage extends StatefulWidget {
|
||||
const MessagesPage({super.key});
|
||||
|
||||
@override
|
||||
MessagesPageState createState() => MessagesPageState();
|
||||
}
|
||||
|
||||
class MessagesPageState extends State<MessagesPage>
|
||||
with TickerProviderStateMixin {
|
||||
late UserProvider user;
|
||||
late MessageProvider messageProvider;
|
||||
late UpdateProvider updateProvider;
|
||||
late String firstName;
|
||||
late TabController tabController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
tabController = TabController(length: 4, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = Provider.of<UserProvider>(context);
|
||||
messageProvider = Provider.of<MessageProvider>(context);
|
||||
updateProvider = Provider.of<UpdateProvider>(context);
|
||||
|
||||
List<String> nameParts = user.displayName?.split(" ") ?? ["?"];
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: NestedScrollView(
|
||||
physics: const BouncingScrollPhysics(
|
||||
parent: AlwaysScrollableScrollPhysics()),
|
||||
headerSliverBuilder: (context, _) => [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
floating: false,
|
||||
snap: false,
|
||||
centerTitle: false,
|
||||
automaticallyImplyLeading: false,
|
||||
shadowColor: Theme.of(context).shadowColor,
|
||||
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Text(
|
||||
"Messages".i18n,
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context).text,
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
bottom: FilterBar(
|
||||
items: [
|
||||
Tab(text: "Inbox".i18n),
|
||||
Tab(text: "Sent".i18n),
|
||||
Tab(text: "Trash".i18n),
|
||||
Tab(text: "Draft".i18n),
|
||||
],
|
||||
controller: tabController,
|
||||
disableFading: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
body: TabBarView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
controller: tabController,
|
||||
children: List.generate(
|
||||
4, (index) => filterViewBuilder(context, index))),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<DateWidget> getFilterWidgets(MessageType activeData) {
|
||||
List<DateWidget> items = [];
|
||||
switch (activeData) {
|
||||
case MessageType.inbox:
|
||||
for (var message in messageProvider.messages) {
|
||||
if (message.type == MessageType.inbox) {
|
||||
items.add(DateWidget(
|
||||
date: message.date,
|
||||
widget: MessageViewable(message),
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MessageType.sent:
|
||||
for (var message in messageProvider.messages) {
|
||||
if (message.type == MessageType.sent) {
|
||||
items.add(DateWidget(
|
||||
date: message.date,
|
||||
widget: MessageViewable(message),
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MessageType.trash:
|
||||
for (var message in messageProvider.messages) {
|
||||
if (message.type == MessageType.trash) {
|
||||
items.add(DateWidget(
|
||||
date: message.date,
|
||||
widget: MessageViewable(message),
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MessageType.draft:
|
||||
for (var message in messageProvider.messages) {
|
||||
if (message.type == MessageType.draft) {
|
||||
items.add(DateWidget(
|
||||
date: message.date,
|
||||
widget: MessageViewable(message),
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
Widget filterViewBuilder(context, int activeData) {
|
||||
List<Widget> filterWidgets = sortDateWidgets(context,
|
||||
dateWidgets: getFilterWidgets(MessageType.values[activeData]),
|
||||
hasShadow: true);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: RefreshIndicator(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
onRefresh: () {
|
||||
return Future.wait([
|
||||
messageProvider.fetch(type: MessageType.inbox),
|
||||
messageProvider.fetch(type: MessageType.sent),
|
||||
messageProvider.fetch(type: MessageType.trash),
|
||||
]);
|
||||
},
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemBuilder: (context, index) => filterWidgets.isNotEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24.0, vertical: 6.0),
|
||||
child: filterWidgets[index],
|
||||
)
|
||||
: Empty(subtitle: "empty".i18n),
|
||||
itemCount: max(filterWidgets.length, 1),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"Messages": "Messages",
|
||||
"Inbox": "Inbox",
|
||||
"Sent": "Sent",
|
||||
"Trash": "Trash",
|
||||
"Draft": "Draft",
|
||||
"empty": "You have no messages.",
|
||||
},
|
||||
"hu_hu": {
|
||||
"Messages": "Üzenetek",
|
||||
"Inbox": "Beérkezett",
|
||||
"Sent": "Elküldött",
|
||||
"Trash": "Kuka",
|
||||
"Draft": "Piszkozat",
|
||||
"empty": "Nincsenek üzeneteid.",
|
||||
},
|
||||
"de_de": {
|
||||
"Messages": "Nachrichten",
|
||||
"Inbox": "Posteingang",
|
||||
"Sent": "Gesendet",
|
||||
"Trash": "Müll",
|
||||
"Draft": "Entwurf",
|
||||
"empty": "Sie haben keine Nachrichten.",
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,378 +0,0 @@
|
||||
import 'dart:math';
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:refilc/api/providers/update_provider.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc_kreta_api/client/client.dart';
|
||||
import 'package:refilc_kreta_api/models/week.dart';
|
||||
import 'package:refilc_kreta_api/providers/timetable_provider.dart';
|
||||
import 'package:refilc/api/providers/user_provider.dart';
|
||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||
import 'package:refilc_mobile_ui/common/empty.dart';
|
||||
import 'package:refilc_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:refilc_kreta_api/controllers/timetable_controller.dart';
|
||||
import 'package:refilc_desktop_ui/common/widgets/lesson/lesson_viewable.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc/utils/format.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
import 'timetable_page.i18n.dart';
|
||||
|
||||
// todo: "fix" overflow (priority: -1)
|
||||
|
||||
class TimetablePage extends StatefulWidget {
|
||||
const TimetablePage({super.key, this.initialDay, this.initialWeek});
|
||||
|
||||
final DateTime? initialDay;
|
||||
final Week? initialWeek;
|
||||
|
||||
static void jump(BuildContext context,
|
||||
{Week? week, DateTime? day, Lesson? lesson}) {
|
||||
// Go to timetable page with arguments
|
||||
// NavigationScreen.of(context)?.customRoute(navigationPageRoute((context) => TimetablePage(
|
||||
// initialDay: lesson?.date ?? day,
|
||||
// initialWeek: lesson?.date != null
|
||||
// ? Week.fromDate(lesson!.date)
|
||||
// : day != null
|
||||
// ? Week.fromDate(day)
|
||||
// : week,
|
||||
// )));
|
||||
|
||||
// NavigationScreen.of(context)?.setPage("timetable");
|
||||
|
||||
// Show initial Lesson
|
||||
// if (lesson != null) LessonView.show(lesson, context: context);
|
||||
}
|
||||
|
||||
@override
|
||||
TimetablePageState createState() => TimetablePageState();
|
||||
}
|
||||
|
||||
class TimetablePageState extends State<TimetablePage>
|
||||
with TickerProviderStateMixin {
|
||||
late UserProvider user;
|
||||
late TimetableProvider timetableProvider;
|
||||
late UpdateProvider updateProvider;
|
||||
late String firstName;
|
||||
late TimetableController _controller;
|
||||
late TabController _tabController;
|
||||
late Widget empty;
|
||||
|
||||
int _getDayIndex(DateTime date) {
|
||||
int index = 0;
|
||||
if (_controller.days == null || (_controller.days?.isEmpty ?? true)) {
|
||||
return index;
|
||||
}
|
||||
|
||||
// find the first day with upcoming lessons
|
||||
index = _controller.days!.indexWhere((day) => day.last.end.isAfter(date));
|
||||
if (index == -1) index = 0; // fallback
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
// Update timetable on user change
|
||||
Future<void> _userListener() async {
|
||||
await Provider.of<KretaClient>(context, listen: false).refreshLogin();
|
||||
if (mounted) _controller.jump(_controller.currentWeek, context: context);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Initalize controllers
|
||||
_controller = TimetableController();
|
||||
_tabController = TabController(length: 0, vsync: this, initialIndex: 0);
|
||||
|
||||
empty = Empty(subtitle: "empty".i18n);
|
||||
|
||||
bool initial = true;
|
||||
|
||||
// Only update the TabController on week changes
|
||||
_controller.addListener(() {
|
||||
if (_controller.days == null) return;
|
||||
setState(() {
|
||||
_tabController = TabController(
|
||||
length: _controller.days!.length,
|
||||
vsync: this,
|
||||
initialIndex:
|
||||
min(_tabController.index, max(_controller.days!.length - 1, 0)),
|
||||
);
|
||||
|
||||
if (initial ||
|
||||
_controller.previousWeekId != _controller.currentWeekId) {
|
||||
_tabController
|
||||
.animateTo(_getDayIndex(widget.initialDay ?? DateTime.now()));
|
||||
}
|
||||
initial = false;
|
||||
|
||||
// Empty is updated once every week change
|
||||
empty = Empty(subtitle: "empty".i18n);
|
||||
});
|
||||
});
|
||||
|
||||
if (mounted) {
|
||||
if (widget.initialWeek != null) {
|
||||
_controller.jump(widget.initialWeek!, context: context, initial: true);
|
||||
} else {
|
||||
_controller.jump(_controller.currentWeek,
|
||||
context: context, initial: true, skip: true);
|
||||
}
|
||||
}
|
||||
// Listen for user changes
|
||||
user = Provider.of<UserProvider>(context, listen: false);
|
||||
user.addListener(_userListener);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
_controller.dispose();
|
||||
user.removeListener(_userListener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
String dayTitle(int index) {
|
||||
// Sometimes when changing weeks really fast,
|
||||
// controller.days might be null or won't include index
|
||||
try {
|
||||
return DateFormat("EEEE", I18n.of(context).locale.languageCode)
|
||||
.format(_controller.days![index].first.date);
|
||||
} catch (e) {
|
||||
return "timetable".i18n;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = Provider.of<UserProvider>(context);
|
||||
timetableProvider = Provider.of<TimetableProvider>(context);
|
||||
updateProvider = Provider.of<UpdateProvider>(context);
|
||||
|
||||
// First name
|
||||
List<String> nameParts = user.name?.split(" ") ?? ["?"];
|
||||
firstName = nameParts.length > 1 ? nameParts[1] : nameParts[0];
|
||||
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(top: 18.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PageTransitionSwitcher(
|
||||
transitionBuilder: (
|
||||
Widget child,
|
||||
Animation<double> primaryAnimation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return FadeThroughTransition(
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _controller.days != null
|
||||
?
|
||||
// Week view
|
||||
_tabController.length > 0
|
||||
? CupertinoScrollbar(
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _controller.days!.length,
|
||||
itemBuilder: (context, tab) => SizedBox(
|
||||
width: 400,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Day Title
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 24.0,
|
||||
right: 28.0,
|
||||
top: 18.0,
|
||||
bottom: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
dayTitle(tab).capital(),
|
||||
style: const TextStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"${"${_controller.days![tab].first.date.day}"
|
||||
.padLeft(2, '0')}.",
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context)
|
||||
.text
|
||||
.withOpacity(.5),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Lessons
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount:
|
||||
_controller.days![tab].length + 2,
|
||||
itemBuilder: (context, index) {
|
||||
if (_controller.days == null) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// Header
|
||||
if (index == 0) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 8.0,
|
||||
left: 24.0,
|
||||
right: 24.0),
|
||||
child: PanelHeader(
|
||||
padding: EdgeInsets.only(
|
||||
top: 12.0)),
|
||||
);
|
||||
}
|
||||
|
||||
// Footer
|
||||
if (index ==
|
||||
_controller.days![tab].length +
|
||||
1) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: 8.0,
|
||||
left: 24.0,
|
||||
right: 24.0),
|
||||
child: PanelFooter(
|
||||
padding: EdgeInsets.only(
|
||||
top: 12.0)),
|
||||
);
|
||||
}
|
||||
|
||||
// Body
|
||||
final Lesson lesson =
|
||||
_controller.days![tab][index - 1];
|
||||
final bool swapDescDay = _controller
|
||||
.days![tab]
|
||||
.map(
|
||||
(l) => l.swapDesc ? 1 : 0)
|
||||
.reduce((a, b) => a + b) >=
|
||||
_controller.days![tab].length *
|
||||
.5;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24.0),
|
||||
child: PanelBody(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 10.0),
|
||||
child: LessonViewable(
|
||||
lesson,
|
||||
swapDesc: swapDescDay,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
// Empty week
|
||||
: Expanded(
|
||||
child: Center(child: empty),
|
||||
)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Previous week
|
||||
IconButton(
|
||||
onPressed: _controller.currentWeekId == 0
|
||||
? null
|
||||
: () => setState(() {
|
||||
_controller.previous(context);
|
||||
}),
|
||||
splashRadius: 24.0,
|
||||
icon: const Icon(FeatherIcons.chevronLeft),
|
||||
color: Theme.of(context).colorScheme.secondary),
|
||||
|
||||
// Week selector
|
||||
InkWell(
|
||||
borderRadius: BorderRadius.circular(6.0),
|
||||
onTap: () => setState(() {
|
||||
_controller.current();
|
||||
if (mounted) {
|
||||
_controller.jump(_controller.currentWeek,
|
||||
context: context,
|
||||
loader: _controller.currentWeekId !=
|
||||
_controller.previousWeekId);
|
||||
}
|
||||
}),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"${_controller.currentWeekId + 1}. ${"week".i18n} (${DateFormat(
|
||||
"${_controller.currentWeek.start.year !=
|
||||
DateTime.now().year
|
||||
? "yy. "
|
||||
: ""}MMM d.",
|
||||
I18n.of(context).locale.languageCode)
|
||||
.format(_controller.currentWeek.start)} - ${DateFormat(
|
||||
"${_controller.currentWeek.start.year !=
|
||||
DateTime.now().year
|
||||
? "yy. "
|
||||
: ""}MMM d.",
|
||||
I18n.of(context).locale.languageCode)
|
||||
.format(_controller.currentWeek.end)})",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Next week
|
||||
IconButton(
|
||||
onPressed: _controller.currentWeekId == 51
|
||||
? null
|
||||
: () => setState(() {
|
||||
_controller.next(context);
|
||||
}),
|
||||
splashRadius: 24.0,
|
||||
icon: const Icon(FeatherIcons.chevronRight),
|
||||
color: Theme.of(context).colorScheme.secondary),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"timetable": "Timetable",
|
||||
"empty": "No school this week!",
|
||||
"week": "Week",
|
||||
"error": "Failed to fetch timetable!",
|
||||
},
|
||||
"hu_hu": {
|
||||
"timetable": "Órarend",
|
||||
"empty": "Ezen a héten nincs iskola.",
|
||||
"week": "Hét",
|
||||
"error": "Nem sikerült lekérni az órarendet!",
|
||||
},
|
||||
"de_de": {
|
||||
"timetable": "Zeitplan",
|
||||
"empty": "Keine Schule diese Woche.",
|
||||
"week": "Woche",
|
||||
"error": "Der Fahrplan konnte nicht abgerufen werden!",
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Route loginRoute(Widget widget) {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) => widget,
|
||||
transitionDuration: const Duration(milliseconds: 650),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return FadeThroughTransition(
|
||||
fillColor: Colors.transparent,
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:elegant_notification/elegant_notification.dart';
|
||||
import 'package:elegant_notification/resources/arrays.dart';
|
||||
import 'package:refilc/api/client.dart';
|
||||
import 'package:refilc/api/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_desktop_ui/screens/login/school_input/school_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
||||
import 'login_screen.i18n.dart';
|
||||
|
||||
const LinearGradient _backgroundGradient = LinearGradient(
|
||||
colors: [
|
||||
Color.fromARGB(255, 61, 122, 244),
|
||||
Color.fromARGB(255, 23, 77, 185),
|
||||
Color.fromARGB(255, 7, 42, 112),
|
||||
],
|
||||
begin: Alignment(-0.8, -2.0),
|
||||
end: Alignment(0.8, 1.0),
|
||||
stops: [-1.0, 0.0, 1.0],
|
||||
);
|
||||
|
||||
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;
|
||||
double topInset = 12.0;
|
||||
|
||||
@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 {
|
||||
ElegantNotification.error(
|
||||
background: Colors.white,
|
||||
description: Text(
|
||||
"schools_error".i18n,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
onActionPressed: () {},
|
||||
onCloseButtonPressed: () {},
|
||||
onDismiss: () {},
|
||||
onProgressFinished: () {},
|
||||
displayCloseButton: false,
|
||||
showProgressIndicator: false,
|
||||
autoDismiss: true,
|
||||
animation: AnimationType.fromTop,
|
||||
).show(context);
|
||||
}
|
||||
});
|
||||
|
||||
if (Platform.isMacOS) {
|
||||
Window.getTitlebarHeight()
|
||||
.then((value) => setState(() => topInset = value));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: _backgroundGradient,
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// App logo
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: ClipRect(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12.0, right: 12.0, bottom: 32.0),
|
||||
child: SizedBox(
|
||||
width: 100.0,
|
||||
height: 100.0,
|
||||
// Png shadow *hack*
|
||||
child: Stack(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Opacity(
|
||||
opacity: 0.3,
|
||||
child: Image.asset(
|
||||
"assets/icons/ic_splash.png",
|
||||
color: Colors.black)),
|
||||
),
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(
|
||||
sigmaX: 6.0, sigmaY: 6.0),
|
||||
child: Image.asset(
|
||||
"assets/icons/ic_splash.png"),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Inputs
|
||||
SizedBox(
|
||||
width: 400.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: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"usernameHint".i18n,
|
||||
maxLines: 1,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
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: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"passwordHint".i18n,
|
||||
maxLines: 1,
|
||||
textAlign: TextAlign.right,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
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: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
SchoolInput(
|
||||
scroll: _scrollController,
|
||||
controller: schoolController,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Log in button
|
||||
SizedBox(
|
||||
width: 400.0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 42.0),
|
||||
child: Visibility(
|
||||
visible: _loginState != LoginState.inProgress,
|
||||
replacement: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: LoginButton(
|
||||
child: Text("login".i18n,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 15.0,
|
||||
)),
|
||||
onPressed: () => _loginAPI(context: context),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_loginState == LoginState.missingFields ||
|
||||
_loginState == LoginState.invalidGrant ||
|
||||
_loginState == LoginState.failed)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(
|
||||
[
|
||||
"missing_fields",
|
||||
"invalid_grant",
|
||||
"error"
|
||||
][_loginState.index]
|
||||
.i18n,
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (showBack)
|
||||
Container(
|
||||
alignment: Alignment.topLeft,
|
||||
padding: EdgeInsets.only(left: 16.0, top: topInset),
|
||||
child: const ClipOval(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: BackButton(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _loginAPI({required BuildContext context}) {
|
||||
String username = usernameController.text;
|
||||
String password = passwordController.text;
|
||||
|
||||
if (username == "" ||
|
||||
password == "" ||
|
||||
schoolController.selectedSchool == null) {
|
||||
return setState(() => _loginState = LoginState.missingFields);
|
||||
}
|
||||
|
||||
setState(() => _loginState = LoginState.inProgress);
|
||||
|
||||
loginAPI(
|
||||
username: username,
|
||||
password: password,
|
||||
instituteCode: schoolController.selectedSchool!.instituteCode,
|
||||
context: context,
|
||||
onLogin: (user) {
|
||||
ElegantNotification.success(
|
||||
background: Colors.white,
|
||||
description: Text(
|
||||
"welcome".i18n.fill([user.name]),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
onActionPressed: () {},
|
||||
onCloseButtonPressed: () {},
|
||||
onDismiss: () {},
|
||||
onProgressFinished: () {},
|
||||
displayCloseButton: false,
|
||||
showProgressIndicator: false,
|
||||
autoDismiss: true,
|
||||
animation: AnimationType.fromTop,
|
||||
).show(context);
|
||||
},
|
||||
onSuccess: () {
|
||||
Navigator.of(context)
|
||||
.pushNamedAndRemoveUntil("login_to_navigation", (_) => false);
|
||||
}).then((res) => setState(() => _loginState = res));
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import 'package:i18n_extension/i18n_extension.dart';
|
||||
|
||||
extension Localization on String {
|
||||
static final _t = Translations.byLocale("hu_hu") +
|
||||
{
|
||||
"en_en": {
|
||||
"username": "Username",
|
||||
"usernameHint": "Student ID number",
|
||||
"password": "Password",
|
||||
"passwordHint": "Date of birth",
|
||||
"school": "School",
|
||||
"login": "Log in",
|
||||
"welcome": "Welcome, %s!",
|
||||
"missing_fields": "Missing Fields!",
|
||||
"invalid_grant": "Invalid Username/Password!",
|
||||
"error": "Failed to log in.",
|
||||
"schools_error": "Failed to get schools."
|
||||
},
|
||||
"hu_hu": {
|
||||
"username": "Felhasználónév",
|
||||
"usernameHint": "Oktatási azonosító",
|
||||
"password": "Jelszó",
|
||||
"passwordHint": "Születési dátum",
|
||||
"school": "Iskola",
|
||||
"login": "Belépés",
|
||||
"welcome": "Üdv, %s!",
|
||||
"missing_fields": "Hiányzó adatok!",
|
||||
"invalid_grant": "Helytelen Felhasználónév/Jelszó!",
|
||||
"error": "Sikertelen bejelentkezés.",
|
||||
"schools_error": "Nem sikerült lekérni az iskolákat."
|
||||
},
|
||||
"de_de": {
|
||||
"username": "Benutzername",
|
||||
"usernameHint": "Ausbildung ID",
|
||||
"password": "Passwort",
|
||||
"passwordHint": "Geburtsdatum",
|
||||
"school": "Schule",
|
||||
"login": "Einloggen",
|
||||
"welcome": "Wilkommen, %s!",
|
||||
"missing_fields": "Fehlende Felder!",
|
||||
"invalid_grant": "Ungültiger Benutzername/Passwort!",
|
||||
"error": "Anmeldung fehlgeschlagen.",
|
||||
"schools_error": "Keine Schulen gefunden."
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
import 'package:refilc_mobile_ui/screens/login/login_input.dart';
|
||||
import 'package:refilc_mobile_ui/screens/login/school_input/school_input_overlay.dart';
|
||||
import 'package:refilc_desktop_ui/screens/login/school_input/school_input_tile.dart';
|
||||
import 'package:refilc_mobile_ui/screens/login/school_input/school_search.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc_kreta_api/models/school.dart';
|
||||
|
||||
class SchoolInput extends StatefulWidget {
|
||||
const SchoolInput({super.key, required this.controller, required this.scroll});
|
||||
|
||||
final SchoolInputController controller;
|
||||
final ScrollController scroll;
|
||||
|
||||
@override
|
||||
SchoolInputState createState() => SchoolInputState();
|
||||
}
|
||||
|
||||
class SchoolInputState extends State<SchoolInput> {
|
||||
final _focusNode = FocusNode();
|
||||
final _layerLink = LayerLink();
|
||||
late SchoolInputOverlay overlay;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
widget.controller.update = (fn) {
|
||||
if (mounted) setState(fn);
|
||||
};
|
||||
|
||||
overlay = SchoolInputOverlay(layerLink: _layerLink);
|
||||
|
||||
// Show school list when focused
|
||||
_focusNode.addListener(() {
|
||||
if (_focusNode.hasFocus) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => overlay.createOverlayEntry(context));
|
||||
Future.delayed(const Duration(milliseconds: 100)).then((value) {
|
||||
if (mounted && widget.scroll.hasClients) {
|
||||
widget.scroll.animateTo(widget.scroll.offset + 500,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.ease);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
overlay.entry?.remove();
|
||||
}
|
||||
});
|
||||
|
||||
// LoginInput TextField listener
|
||||
widget.controller.textController.addListener(() {
|
||||
String text = widget.controller.textController.text;
|
||||
if (text.isEmpty) {
|
||||
overlay.children = null;
|
||||
return;
|
||||
}
|
||||
|
||||
List<School> results =
|
||||
searchSchools(widget.controller.schools ?? [], text);
|
||||
setState(() {
|
||||
overlay.children = results
|
||||
.map((School e) => SchoolInputTile(
|
||||
school: e,
|
||||
onTap: () => _selectSchool(e),
|
||||
))
|
||||
.toList();
|
||||
});
|
||||
Overlay.of(context).setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _selectSchool(School school) {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
|
||||
setState(() {
|
||||
widget.controller.selectedSchool = school;
|
||||
widget.controller.textController.text = school.name;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CompositedTransformTarget(
|
||||
link: _layerLink,
|
||||
child: widget.controller.schools == null
|
||||
? Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
child: const Center(
|
||||
child: SizedBox(
|
||||
height: 28.0,
|
||||
width: 28.0,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: LoginInput(
|
||||
style: LoginInputStyle.school,
|
||||
focusNode: _focusNode,
|
||||
onClear: () {
|
||||
widget.controller.selectedSchool = null;
|
||||
FocusScope.of(context).requestFocus(_focusNode);
|
||||
},
|
||||
controller: widget.controller.textController,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SchoolInputController {
|
||||
final textController = TextEditingController();
|
||||
School? selectedSchool;
|
||||
List<School>? schools;
|
||||
late void Function(void Function()) update;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import 'package:refilc_kreta_api/models/school.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SchoolInputTile extends StatelessWidget {
|
||||
const SchoolInputTile({super.key, required this.school, this.onTap});
|
||||
|
||||
final School school;
|
||||
final Function()? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: GestureDetector(
|
||||
onPanDown: (e) {
|
||||
onTap!();
|
||||
},
|
||||
child: InkWell(
|
||||
onTapDown: (e) {},
|
||||
borderRadius: BorderRadius.circular(6.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// School name
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
child: Text(
|
||||
school.name,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
// School id
|
||||
Expanded(
|
||||
child: Text(
|
||||
school.instituteCode,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
// School city
|
||||
Expanded(
|
||||
child: Text(
|
||||
school.city,
|
||||
textAlign: TextAlign.right,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
class NavigationRoute {
|
||||
late String _name;
|
||||
late int _index;
|
||||
|
||||
final List<String> _internalPageMap = [
|
||||
"home",
|
||||
"grades",
|
||||
"timetable",
|
||||
"messages",
|
||||
"absences",
|
||||
];
|
||||
|
||||
String get name => _name;
|
||||
int get index => _index;
|
||||
|
||||
set name(String n) {
|
||||
_name = n;
|
||||
_index = _internalPageMap.indexOf(n);
|
||||
}
|
||||
|
||||
set index(int i) {
|
||||
_index = i;
|
||||
_name = _internalPageMap.elementAt(i);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:refilc_desktop_ui/pages/absences/absences_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/grades/grades_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/home/home_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/messages/messages_page.dart';
|
||||
import 'package:refilc_desktop_ui/pages/timetable/timetable_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Route navigationRouteHandler(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
case "grades":
|
||||
return navigationPageRoute((context) => const GradesPage());
|
||||
case "timetable":
|
||||
return navigationPageRoute((context) => const TimetablePage());
|
||||
case "messages":
|
||||
return navigationPageRoute((context) => const MessagesPage());
|
||||
case "absences":
|
||||
return navigationPageRoute((context) => const AbsencesPage());
|
||||
case "home":
|
||||
default:
|
||||
return navigationPageRoute((context) => const HomePage());
|
||||
}
|
||||
}
|
||||
|
||||
Route navigationPageRoute(Widget Function(BuildContext) builder) {
|
||||
return PageRouteBuilder(
|
||||
pageBuilder: (context, _, __) => builder(context),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return FadeThroughTransition(
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:refilc/api/providers/news_provider.dart';
|
||||
import 'package:refilc/api/providers/sync.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc/theme/observer.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/navigation_route.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/navigation_route_handler.dart';
|
||||
import 'package:refilc_desktop_ui/screens/navigation/sidebar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc_kreta_api/client/client.dart';
|
||||
import 'package:refilc_plus/providers/goal_provider.dart';
|
||||
|
||||
class NavigationScreen extends StatefulWidget {
|
||||
const NavigationScreen({super.key});
|
||||
|
||||
static NavigationScreenState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<NavigationScreenState>();
|
||||
|
||||
@override
|
||||
State<NavigationScreen> createState() => NavigationScreenState();
|
||||
}
|
||||
|
||||
class NavigationScreenState extends State<NavigationScreen>
|
||||
with WidgetsBindingObserver {
|
||||
final _navigatorState = GlobalKey<NavigatorState>();
|
||||
late NavigationRoute selected;
|
||||
late SettingsProvider settings;
|
||||
late NewsProvider newsProvider;
|
||||
late GoalProvider goalProvider;
|
||||
double topInset = 0.0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||
selected = NavigationRoute();
|
||||
selected.index = 0;
|
||||
|
||||
// add brightness observer
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
// set client User-Agent
|
||||
Provider.of<KretaClient>(context, listen: false).userAgent =
|
||||
settings.config.userAgent;
|
||||
|
||||
// get news
|
||||
newsProvider = Provider.of<NewsProvider>(context, listen: false);
|
||||
newsProvider.restore().then((value) => newsProvider.fetch());
|
||||
|
||||
// get goals
|
||||
// goalProvider = Provider.of<GoalProvider>(context, listen: false);
|
||||
// goalProvider.fetchDone();
|
||||
|
||||
// Initial sync
|
||||
syncAll(context);
|
||||
|
||||
// platform specific shit
|
||||
() async {
|
||||
try {
|
||||
await Window.initialize();
|
||||
} catch (_) {}
|
||||
// Transparent sidebar
|
||||
if (Platform.isLinux) return;
|
||||
|
||||
await Window.setEffect(
|
||||
effect: Platform.isLinux
|
||||
? WindowEffect.transparent
|
||||
: WindowEffect.acrylic,
|
||||
color: Platform.isMacOS
|
||||
? Colors.transparent
|
||||
: const Color.fromARGB(27, 27, 27, 27));
|
||||
|
||||
// todo: do for windows
|
||||
if (Platform.isMacOS) {
|
||||
topInset = await Window.getTitlebarHeight();
|
||||
await Window.enableFullSizeContentView();
|
||||
await Window.hideTitle();
|
||||
await Window.makeTitlebarTransparent();
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangePlatformBrightness() {
|
||||
if (settings.theme == ThemeMode.system) {
|
||||
// ignore: deprecated_member_use
|
||||
Brightness? brightness =
|
||||
// ignore: deprecated_member_use
|
||||
WidgetsBinding.instance.window.platformBrightness;
|
||||
Provider.of<ThemeModeObserver>(context, listen: false).changeTheme(
|
||||
brightness == Brightness.light ? ThemeMode.light : ThemeMode.dark);
|
||||
}
|
||||
super.didChangePlatformBrightness();
|
||||
}
|
||||
|
||||
void setPage(String page) => setState(() => selected.name = page);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
settings = Provider.of<SettingsProvider>(context);
|
||||
newsProvider = Provider.of<NewsProvider>(context);
|
||||
goalProvider = Provider.of<GoalProvider>(context);
|
||||
|
||||
// show news / complete goals
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (newsProvider.show) {
|
||||
newsProvider.lock();
|
||||
// NewsView.show(newsProvider.news[newsProvider.state], context: context).then((value) => newsProvider.release());
|
||||
}
|
||||
if (goalProvider.hasDoneGoals) {
|
||||
// to-do
|
||||
}
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: Row(
|
||||
children: [
|
||||
if (_navigatorState.currentState != null)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Theme.of(context).scaffoldBackgroundColor.withOpacity(.5),
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: AppColors.of(context).shadow.withOpacity(.7),
|
||||
width: 1.0)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: topInset),
|
||||
child: Sidebar(
|
||||
navigator: _navigatorState.currentState!,
|
||||
selected: selected.name,
|
||||
onRouteChange: (name) => setPage(name),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
padding: EdgeInsets.only(top: topInset),
|
||||
),
|
||||
child: Navigator(
|
||||
key: _navigatorState,
|
||||
initialRoute: selected.name,
|
||||
onGenerateRoute: (settings) =>
|
||||
navigationRouteHandler(settings),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||