kasy-cli 1.10.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/kasy.js +25 -4
- package/lib/commands/check.js +40 -50
- package/lib/commands/deploy.js +25 -25
- package/lib/commands/splash.js +220 -0
- package/lib/scaffold/CHANGELOG.json +9 -0
- package/lib/scaffold/backends/api/patch/lib/main.dart +29 -10
- package/lib/scaffold/backends/supabase/patch/lib/main.dart +29 -10
- package/lib/scaffold/features/README.md +15 -139
- package/lib/scaffold/shared/generator-utils.js +16 -15
- package/lib/utils/i18n.js +292 -43
- package/package.json +2 -2
- package/templates/firebase/android/app/src/main/res/drawable-hdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-hdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-mdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-mdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night/background.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night/launch_background.xml +9 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-hdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-hdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-mdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-mdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-v21/background.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-v21/launch_background.xml +9 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-xhdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-xhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-xxhdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-xxhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-xxxhdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-night-xxxhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xhdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xxhdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xxhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xxxhdpi/android12splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/drawable-xxxhdpi/splash.png +0 -0
- package/templates/firebase/android/app/src/main/res/values-night-v31/styles.xml +2 -1
- package/templates/firebase/android/app/src/main/res/values-v31/styles.xml +1 -0
- package/templates/firebase/assets/images/splash_logo_dark.png +0 -0
- package/templates/firebase/assets/images/splash_logo_light.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json +9 -8
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchBackground.imageset/darkbackground.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +33 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImageDark.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImageDark@2x.png +0 -0
- package/templates/firebase/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImageDark@3x.png +0 -0
- package/templates/firebase/ios/Runner/Base.lproj/LaunchScreen.storyboard +1 -1
- package/templates/firebase/lib/core/initializer/onstart_widget.dart +7 -1
- package/templates/firebase/lib/core/theme/providers/theme_provider.dart +48 -24
- package/templates/firebase/lib/features/onboarding/ui/components/onboarding_features.dart +4 -0
- package/templates/firebase/lib/features/onboarding/ui/onboarding_page.dart +1 -0
- package/templates/firebase/lib/features/onboarding/ui/widgets/onboarding_feature.dart +13 -0
- package/templates/firebase/lib/features/settings/settings_page.dart +158 -18
- package/templates/firebase/lib/i18n/en.i18n.json +6 -2
- package/templates/firebase/lib/i18n/es.i18n.json +6 -2
- package/templates/firebase/lib/i18n/pt.i18n.json +6 -2
- package/templates/firebase/lib/main.dart +29 -10
- package/templates/firebase/pubspec.yaml +4 -5
- package/templates/firebase/test/core/data/repositories/user_repository_test.dart +1 -1
- package/templates/firebase/web/index.html +47 -39
- package/templates/firebase/web/splash/img/dark-1x.png +0 -0
- package/templates/firebase/web/splash/img/dark-2x.png +0 -0
- package/templates/firebase/web/splash/img/dark-3x.png +0 -0
- package/templates/firebase/web/splash/img/dark-4x.png +0 -0
- package/templates/firebase/web/splash/img/light-1x.png +0 -0
- package/templates/firebase/web/splash/img/light-2x.png +0 -0
- package/templates/firebase/web/splash/img/light-3x.png +0 -0
- package/templates/firebase/web/splash/img/light-4x.png +0 -0
- package/lib/scaffold/features/analytics/lib/core/data/api/analytics_api.dart +0 -124
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/BUG.es.md +0 -35
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/BUG.md +0 -35
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/BUG.pt.md +0 -35
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/feature_request.es.md +0 -12
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/feature_request.md +0 -12
- package/lib/scaffold/features/ci/.github/ISSUE_TEMPLATE/feature_request.pt.md +0 -12
- package/lib/scaffold/features/ci/.github/PULL_REQUEST_TEMPLATE.es.md +0 -17
- package/lib/scaffold/features/ci/.github/PULL_REQUEST_TEMPLATE.md +0 -17
- package/lib/scaffold/features/ci/.github/PULL_REQUEST_TEMPLATE.pt.md +0 -17
- package/lib/scaffold/features/ci/.github/dependabot.yml +0 -16
- package/lib/scaffold/features/ci/.github/workflows/app.yml +0 -20
- package/lib/scaffold/features/ci/.gitlab/templates/deploy.yaml +0 -14
- package/lib/scaffold/features/ci/.gitlab/templates/dropbox.yaml +0 -19
- package/lib/scaffold/features/ci/.gitlab/templates/flutter.yaml +0 -163
- package/lib/scaffold/features/ci/.gitlab/templates/mailgun.yaml +0 -28
- package/lib/scaffold/features/ci/.gitlab-ci.yml +0 -37
- package/lib/scaffold/features/ci/codemagic.yaml +0 -157
- package/lib/scaffold/features/facebook/lib/core/data/api/tracking_api.dart +0 -111
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/entities/feature_request_entity.dart +0 -27
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/entities/feature_vote_entity.dart +0 -27
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/feature_request_api.dart +0 -50
- package/lib/scaffold/features/feedback/lib/features/feedbacks/api/feature_vote_api.dart +0 -79
- package/lib/scaffold/features/feedback/lib/features/feedbacks/models/feature_requests.dart +0 -48
- package/lib/scaffold/features/feedback/lib/features/feedbacks/models/feedback_state.dart +0 -42
- package/lib/scaffold/features/feedback/lib/features/feedbacks/providers/feedback_page_notifier.dart +0 -147
- package/lib/scaffold/features/feedback/lib/features/feedbacks/repositories/feature_request_repository.dart +0 -95
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/component/add_feature_form.dart +0 -199
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/feedback_page.dart +0 -175
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/widgets/add_feature_button.dart +0 -76
- package/lib/scaffold/features/feedback/lib/features/feedbacks/ui/widgets/feature_card.dart +0 -279
- package/lib/scaffold/features/ios-release/.kasy/apple.env.example +0 -8
- package/lib/scaffold/features/ios-release/.kasy/codemagic.env.example +0 -7
- package/lib/scaffold/features/ios-release/docs/codemagic-release.en.md +0 -50
- package/lib/scaffold/features/ios-release/docs/codemagic-release.es.md +0 -50
- package/lib/scaffold/features/ios-release/docs/codemagic-release.pt.md +0 -50
- package/lib/scaffold/features/ios-release/docs/ios-release.en.md +0 -41
- package/lib/scaffold/features/ios-release/docs/ios-release.es.md +0 -41
- package/lib/scaffold/features/ios-release/docs/ios-release.pt.md +0 -41
- package/lib/scaffold/features/ios-release/scripts/bump-ios-version.js +0 -38
- package/lib/scaffold/features/ios-release/scripts/release-ios.sh +0 -137
- package/lib/scaffold/features/llm_chat/lib/features/llm_chat/llm_chat_page.dart +0 -301
- package/lib/scaffold/features/local_notifications/lib/features/local_reminder/providers/reminder_notifier.dart +0 -81
- package/lib/scaffold/features/local_notifications/lib/features/local_reminder/repositories/reminder_preferences.dart +0 -76
- package/lib/scaffold/features/local_notifications/lib/features/local_reminder/ui/reminder_page.dart +0 -282
- package/lib/scaffold/features/onboarding/lib/features/onboarding/api/entities/user_info_entity.dart +0 -24
- package/lib/scaffold/features/onboarding/lib/features/onboarding/api/user_infos_api.dart +0 -71
- package/lib/scaffold/features/onboarding/lib/features/onboarding/models/user_info.dart +0 -92
- package/lib/scaffold/features/onboarding/lib/features/onboarding/providers/onboarding_model.dart +0 -15
- package/lib/scaffold/features/onboarding/lib/features/onboarding/providers/onboarding_provider.dart +0 -78
- package/lib/scaffold/features/onboarding/lib/features/onboarding/repositories/user_infos_repository.dart +0 -29
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/animations/page_transitions.dart +0 -30
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_att_setup.dart +0 -66
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_features.dart +0 -72
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_loader.dart +0 -92
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_notifications_setup.dart +0 -73
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/components/onboarding_questions.dart +0 -89
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/onboarding_page.dart +0 -94
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_background.dart +0 -80
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_feature.dart +0 -139
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_illustration_scaffold.dart +0 -110
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_progress.dart +0 -84
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_radio_question.dart +0 -173
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_reassurance.dart +0 -45
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/onboarding_sticky_footer.dart +0 -77
- package/lib/scaffold/features/onboarding/lib/features/onboarding/ui/widgets/selectable_row_tile.dart +0 -392
- package/lib/scaffold/features/revenuecat/lib/core/data/api/tracking_api.dart +0 -116
- package/lib/scaffold/features/revenuecat/lib/core/data/models/subscription.dart +0 -322
- package/lib/scaffold/features/revenuecat/lib/core/home_widgets/home_widget_background_task.dart +0 -41
- package/lib/scaffold/features/revenuecat/lib/core/states/user_state_notifier.dart +0 -305
- package/templates/firebase/assets/images/splashscreen.png +0 -0
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
###########
|
|
2
|
-
## SETUP ##
|
|
3
|
-
###########
|
|
4
|
-
.setup:
|
|
5
|
-
tags:
|
|
6
|
-
- macos
|
|
7
|
-
except:
|
|
8
|
-
- tags
|
|
9
|
-
script:
|
|
10
|
-
- flutter channel stable
|
|
11
|
-
- flutter upgrade
|
|
12
|
-
- flutter pub global activate cider
|
|
13
|
-
- flutter clean
|
|
14
|
-
- pod repo update
|
|
15
|
-
- export LC_ALL=fr_FR.UTF-8
|
|
16
|
-
- export LANG=fr_FR.UTF-8
|
|
17
|
-
- export APP_PATH=$(pwd)
|
|
18
|
-
artifacts:
|
|
19
|
-
reports:
|
|
20
|
-
dotenv:
|
|
21
|
-
- lc_all.env
|
|
22
|
-
- lang.env
|
|
23
|
-
- app_path.env
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.build-android-release:
|
|
27
|
-
tags:
|
|
28
|
-
- macos
|
|
29
|
-
variables:
|
|
30
|
-
FLAVOR: ""
|
|
31
|
-
PATH_TO_RUNNER: ""
|
|
32
|
-
ADDITIONAL_OPTIONS: ""
|
|
33
|
-
only:
|
|
34
|
-
- release
|
|
35
|
-
script:
|
|
36
|
-
- flutter pub get
|
|
37
|
-
- flutter build apk --flavor $FLAVOR --release -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS
|
|
38
|
-
- flutter build appbundle --flavor $FLAVOR --release -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS
|
|
39
|
-
artifacts:
|
|
40
|
-
paths:
|
|
41
|
-
- build/app/outputs/flutter-apk/app-$FLAVOR-release.apk
|
|
42
|
-
- build/app/outputs/bundle/${FLAVOR}Release/app-$FLAVOR-release.aab
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.build-android-profile:
|
|
46
|
-
tags:
|
|
47
|
-
- macos
|
|
48
|
-
variables:
|
|
49
|
-
FLAVOR: ""
|
|
50
|
-
PATH_TO_RUNNER: ""
|
|
51
|
-
ADDITIONAL_OPTIONS: ""
|
|
52
|
-
only:
|
|
53
|
-
- master
|
|
54
|
-
script:
|
|
55
|
-
- flutter pub get
|
|
56
|
-
- if [[ $FLAVOR == "" ]]; then flutter build apk -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS; else flutter build apk --flavor $FLAVOR -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS; fi
|
|
57
|
-
- if [[ $FLAVOR == "" ]]; then flutter build appbundle --profile -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS; else flutter build appbundle --profile --flavor $FLAVOR -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS; fi
|
|
58
|
-
artifacts:
|
|
59
|
-
paths:
|
|
60
|
-
- build/app/outputs/flutter-apk
|
|
61
|
-
- build/app/outputs/bundle/${FLAVOR}Profile/app-$FLAVOR-profile.aab
|
|
62
|
-
|
|
63
|
-
.build-ios-ipa:
|
|
64
|
-
tags:
|
|
65
|
-
- macos
|
|
66
|
-
only:
|
|
67
|
-
- master
|
|
68
|
-
- main
|
|
69
|
-
variables:
|
|
70
|
-
FLAVOR: ""
|
|
71
|
-
PATH_TO_RUNNER: ""
|
|
72
|
-
METHOD: "ad-hoc" # ["ad-hoc", "app-store", "development", "enterprise"]
|
|
73
|
-
ADDITIONAL_OPTIONS: ""
|
|
74
|
-
script:
|
|
75
|
-
- cd ios
|
|
76
|
-
- pod repo update
|
|
77
|
-
- cd ..
|
|
78
|
-
- flutter pub get
|
|
79
|
-
- if [[ $FLAVOR == "" ]]; then flutter build ipa -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS; else flutter build ipa --flavor $FLAVOR -t $PATH_TO_RUNNER $ADDITIONAL_OPTIONS; fi
|
|
80
|
-
# rename ipa file
|
|
81
|
-
- mv build/ios/ipa/*.ipa build/ios/ipa/app-release.ipa
|
|
82
|
-
artifacts:
|
|
83
|
-
paths:
|
|
84
|
-
- build/ios/ipa/app.ipa
|
|
85
|
-
|
|
86
|
-
.build-ios-auto:
|
|
87
|
-
tags:
|
|
88
|
-
- macos
|
|
89
|
-
only:
|
|
90
|
-
- release
|
|
91
|
-
variables:
|
|
92
|
-
FLAVOR: ""
|
|
93
|
-
PATH_TO_RUNNER: ""
|
|
94
|
-
EXPORT_OPTIONS_PLIST: "../scripts/exportOptions.plist"
|
|
95
|
-
ADDITIONAL_OPTIONS: ""
|
|
96
|
-
script:
|
|
97
|
-
- flutter clean
|
|
98
|
-
- cd ios
|
|
99
|
-
- pod repo update
|
|
100
|
-
- cd ..
|
|
101
|
-
- flutter build ios -t $PATH_TO_RUNNER --flavor $FLAVOR --release $ADDITIONAL_OPTIONS
|
|
102
|
-
- cd ios
|
|
103
|
-
- xcodebuild -quiet -workspace Runner.xcworkspace -scheme $FLAVOR archive -archivePath Runner.xcarchive -allowProvisioningUpdates -destination generic/platform=iOS
|
|
104
|
-
- xcodebuild -quiet -exportArchive -archivePath Runner.xcarchive -exportOptionsPlist $EXPORT_OPTIONS_PLIST -exportPath ../scripts -allowProvisioningUpdates
|
|
105
|
-
- cd ../scripts
|
|
106
|
-
- mv *.ipa app-$FLAVOR.ipa
|
|
107
|
-
artifacts:
|
|
108
|
-
paths:
|
|
109
|
-
- scripts/app-$FLAVOR.ipa
|
|
110
|
-
|
|
111
|
-
.tests-stable:
|
|
112
|
-
tags:
|
|
113
|
-
- macos
|
|
114
|
-
stage: test
|
|
115
|
-
image: "cirrusci/flutter:stable"
|
|
116
|
-
before_script:
|
|
117
|
-
- flutter pub global activate junitreport
|
|
118
|
-
- export PATH="$PATH":"$HOME/.pub-cache/bin"
|
|
119
|
-
script:
|
|
120
|
-
- flutter test --machine --coverage | tojunit -o report.xml
|
|
121
|
-
- lcov --summary coverage/lcov.info
|
|
122
|
-
- genhtml coverage/lcov.info --output=coverage
|
|
123
|
-
coverage: '/lines\.*: \d+\.\d+\%/'
|
|
124
|
-
artifacts:
|
|
125
|
-
name: coverage
|
|
126
|
-
paths:
|
|
127
|
-
- $CI_PROJECT_DIR/coverage
|
|
128
|
-
reports:
|
|
129
|
-
junit: report.xml
|
|
130
|
-
|
|
131
|
-
##############################################
|
|
132
|
-
## YOU MUST INSTALL CIDER BEFORE USING THIS ##
|
|
133
|
-
##############################################
|
|
134
|
-
|
|
135
|
-
.bump-build-version:
|
|
136
|
-
variables:
|
|
137
|
-
BRANCH: "master"
|
|
138
|
-
tags:
|
|
139
|
-
- macos
|
|
140
|
-
script:
|
|
141
|
-
- export PATH="$PATH":"$HOME/.pub-cache/bin"
|
|
142
|
-
# git prepare
|
|
143
|
-
- git checkout -B $BRANCH
|
|
144
|
-
- git remote set-url origin "$(echo $CI_REPOSITORY_URL | perl -pe 's#.*@(.+?(\:\d+)?)/#git@\1:#')"
|
|
145
|
-
- git branch --set-upstream-to=origin/$BRANCH $BRANCH
|
|
146
|
-
# bump project build version
|
|
147
|
-
- cider bump build
|
|
148
|
-
- export APP_PROJECT_VERSION=$(cider version)
|
|
149
|
-
- git add pubspec.yaml
|
|
150
|
-
- git commit -m "🔖 Bump build version"
|
|
151
|
-
- git tag -a "${APP_PROJECT_VERSION}-staging" -m "Version created by Gitlab CI build."
|
|
152
|
-
- git push origin HEAD:$BRANCH --follow-tags -o ci.skip
|
|
153
|
-
- git pull
|
|
154
|
-
|
|
155
|
-
.read-build-version:
|
|
156
|
-
tags:
|
|
157
|
-
- macos
|
|
158
|
-
script:
|
|
159
|
-
- export APP_PROJECT_VERSION=$(cider version)
|
|
160
|
-
- echo "APP_PROJECT_VERSION=$APP_PROJECT_VERSION" >> app_project_version.env
|
|
161
|
-
artifacts:
|
|
162
|
-
reports:
|
|
163
|
-
dotenv: app_project_version.env
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.send_email:
|
|
2
|
-
variables:
|
|
3
|
-
FILENAME: ""
|
|
4
|
-
SUBJECT: ""
|
|
5
|
-
MAILGUN_API_KEY: ""
|
|
6
|
-
MAILGUN_DOMAIN: ""
|
|
7
|
-
FROM: ""
|
|
8
|
-
HTML: ""
|
|
9
|
-
TO: ""
|
|
10
|
-
script: curl -s --user "api:$MAILGUN_API_KEY" "https://api.eu.mailgun.net/v3/$MAILGUN_DOMAIN/messages" -F from=$FROM -F to=$TO -F subject="$SUBJECT" -F html="$HTML"
|
|
11
|
-
|
|
12
|
-
.send_email_attachment:
|
|
13
|
-
variables:
|
|
14
|
-
FILENAME: ""
|
|
15
|
-
SUBJECT: ""
|
|
16
|
-
MAILGUN_API_KEY: ""
|
|
17
|
-
MAILGUN_DOMAIN: ""
|
|
18
|
-
FROM: ""
|
|
19
|
-
HTML: ""
|
|
20
|
-
TO: ""
|
|
21
|
-
script: curl -s --user "api:$MAILGUN_API_KEY"
|
|
22
|
-
"https://api.eu.mailgun.net/v3/$MAILGUN_DOMAIN/messages"
|
|
23
|
-
-F from=$FROM
|
|
24
|
-
-F to=$TO
|
|
25
|
-
-F subject="$SUBJECT"
|
|
26
|
-
-F attachment=$FILENAME
|
|
27
|
-
-F html="$HTML"
|
|
28
|
-
# -F attachment='@reports/report.html'
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
stages:
|
|
2
|
-
- test
|
|
3
|
-
- deploy
|
|
4
|
-
|
|
5
|
-
test:
|
|
6
|
-
stage: test
|
|
7
|
-
image: node:18
|
|
8
|
-
allow_failure: false
|
|
9
|
-
before_script:
|
|
10
|
-
- cd functions
|
|
11
|
-
- time npm ci
|
|
12
|
-
script:
|
|
13
|
-
- npm run test
|
|
14
|
-
cache:
|
|
15
|
-
key: build-cache
|
|
16
|
-
paths:
|
|
17
|
-
- functions/node_modules/
|
|
18
|
-
policy: push
|
|
19
|
-
coverage: '/Lines \W+: (\d+.\d+)%.*/'
|
|
20
|
-
|
|
21
|
-
deploy:production:
|
|
22
|
-
stage: deploy
|
|
23
|
-
needs: [test]
|
|
24
|
-
image: node:18
|
|
25
|
-
before_script:
|
|
26
|
-
- cd functions
|
|
27
|
-
- time npm ci
|
|
28
|
-
- npm install -g firebase-tools
|
|
29
|
-
script:
|
|
30
|
-
# - firebase use production
|
|
31
|
-
- firebase deploy --only firestore:indexes --token " $FIREBASE_CI_TOKEN " -P production
|
|
32
|
-
- firebase deploy --only firestore:rules --token " $FIREBASE_CI_TOKEN " -P production
|
|
33
|
-
- firebase deploy --only storage --token " $FIREBASE_CI_TOKEN " -P production
|
|
34
|
-
- firebase deploy --only functions --token " $FIREBASE_CI_TOKEN " -P production
|
|
35
|
-
only:
|
|
36
|
-
- main
|
|
37
|
-
when: manual
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
workflows:
|
|
2
|
-
android-workflow:
|
|
3
|
-
name: Android Workflow
|
|
4
|
-
instance_type: mac_mini_m1
|
|
5
|
-
max_build_duration: 120
|
|
6
|
-
environment:
|
|
7
|
-
android_signing:
|
|
8
|
-
- stacks-keystore
|
|
9
|
-
groups:
|
|
10
|
-
- google_play # <-- (Includes GCLOUD_SERVICE_ACCOUNT_CREDENTIALS)
|
|
11
|
-
vars:
|
|
12
|
-
PACKAGE_NAME: {{BUNDLE_ID}} # <-- Put your package name here
|
|
13
|
-
GOOGLE_PLAY_TRACK: "alpha" # <-- Put your track here (alpha, beta, production, internal)
|
|
14
|
-
flutter: stable
|
|
15
|
-
triggering:
|
|
16
|
-
cancel_previous_builds: true
|
|
17
|
-
events:
|
|
18
|
-
- push
|
|
19
|
-
branch_patterns:
|
|
20
|
-
- pattern: '*'
|
|
21
|
-
include: false
|
|
22
|
-
source: false
|
|
23
|
-
- pattern: 'main'
|
|
24
|
-
include: true
|
|
25
|
-
source: true
|
|
26
|
-
scripts:
|
|
27
|
-
- name: Set up local.properties
|
|
28
|
-
script: |
|
|
29
|
-
echo "flutter.sdk=$HOME/programs/flutter" > "$CM_BUILD_DIR/android/local.properties"
|
|
30
|
-
- name: Get Flutter packages
|
|
31
|
-
script: |
|
|
32
|
-
flutter packages pub get
|
|
33
|
-
- name: Unit tests
|
|
34
|
-
script: |
|
|
35
|
-
mkdir -p test-results
|
|
36
|
-
flutter test --machine > test-results/flutter.json
|
|
37
|
-
test_report: test-results/flutter.json
|
|
38
|
-
- name: Build AAB with Flutter
|
|
39
|
-
script: |
|
|
40
|
-
BUILD_NUMBER=$(($(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks="$GOOGLE_PLAY_TRACK") + 1))
|
|
41
|
-
flutter build appbundle --release \
|
|
42
|
-
--dart-define=ENV=prod \
|
|
43
|
-
--dart-define=BACKEND_URL=$BACKEND_URL \
|
|
44
|
-
--dart-define=SENTRY_DSN=$SENTRY_DSN \
|
|
45
|
-
--dart-define=RC_ANDROID_API_KEY=$RC_ANDROID_API_KEY \
|
|
46
|
-
--dart-define=RC_IOS_API_KEY=$RC_IOS_API_KEY \
|
|
47
|
-
--dart-define=MIXPANEL_TOKEN=$MIXPANEL_TOKEN \
|
|
48
|
-
--build-name=1.0.$BUILD_NUMBER \
|
|
49
|
-
--build-number=$BUILD_NUMBER
|
|
50
|
-
artifacts:
|
|
51
|
-
- build/**/outputs/**/*.aab
|
|
52
|
-
- build/**/outputs/**/mapping.txt
|
|
53
|
-
- flutter_drive.log
|
|
54
|
-
publishing:
|
|
55
|
-
email:
|
|
56
|
-
recipients:
|
|
57
|
-
- # <-- Put your email here or add others recipients
|
|
58
|
-
notify:
|
|
59
|
-
success: true
|
|
60
|
-
failure: true
|
|
61
|
-
google_play:
|
|
62
|
-
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
|
|
63
|
-
track: $GOOGLE_PLAY_TRACK
|
|
64
|
-
submit_as_draft: true
|
|
65
|
-
ios-workflow:
|
|
66
|
-
name: iOS Workflow
|
|
67
|
-
instance_type: mac_mini_m1
|
|
68
|
-
max_build_duration: 120
|
|
69
|
-
integrations:
|
|
70
|
-
app_store_connect: codemagic
|
|
71
|
-
environment:
|
|
72
|
-
groups:
|
|
73
|
-
- appstore_credentials
|
|
74
|
-
ios_signing:
|
|
75
|
-
distribution_type: app_store
|
|
76
|
-
bundle_identifier: {{BUNDLE_ID}} # <-- Put your bundle identifier here
|
|
77
|
-
vars:
|
|
78
|
-
# Numeric App ID from App Store Connect app URL (e.g. .../apps/1234567890/...)
|
|
79
|
-
APP_ID:
|
|
80
|
-
flutter: stable
|
|
81
|
-
xcode: latest # <-- set to specific version e.g. 14.3, 15.0 to avoid unexpected updates.
|
|
82
|
-
cocoapods: default
|
|
83
|
-
triggering:
|
|
84
|
-
cancel_previous_builds: true
|
|
85
|
-
events:
|
|
86
|
-
- push
|
|
87
|
-
branch_patterns:
|
|
88
|
-
- pattern: '*'
|
|
89
|
-
include: false
|
|
90
|
-
source: false
|
|
91
|
-
- pattern: 'main'
|
|
92
|
-
include: true
|
|
93
|
-
source: true
|
|
94
|
-
scripts:
|
|
95
|
-
- name: Set up code signing settings on Xcode project
|
|
96
|
-
script: |
|
|
97
|
-
xcode-project use-profiles
|
|
98
|
-
- name: Get Flutter packages
|
|
99
|
-
script: |
|
|
100
|
-
flutter packages pub get
|
|
101
|
-
- name: Install pods
|
|
102
|
-
script: |
|
|
103
|
-
find . -name "Podfile" -execdir pod install \;
|
|
104
|
-
- name: Validate Google Sign-In iOS URL scheme
|
|
105
|
-
script: |
|
|
106
|
-
GOOGLE_PLIST="ios/Runner/GoogleService-Info.plist"
|
|
107
|
-
INFO_PLIST="ios/Runner/Info.plist"
|
|
108
|
-
if [ -f "$GOOGLE_PLIST" ]; then
|
|
109
|
-
REVERSED_CLIENT_ID=$(/usr/libexec/PlistBuddy -c "Print :REVERSED_CLIENT_ID" "$GOOGLE_PLIST" 2>/dev/null || true)
|
|
110
|
-
if [ -z "$REVERSED_CLIENT_ID" ]; then
|
|
111
|
-
echo "REVERSED_CLIENT_ID not found in $GOOGLE_PLIST"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
if ! /usr/libexec/PlistBuddy -c "Print :CFBundleURLTypes" "$INFO_PLIST" 2>/dev/null | grep -Fq "$REVERSED_CLIENT_ID"; then
|
|
115
|
-
echo "Google Sign-In iOS URL scheme mismatch."
|
|
116
|
-
echo "Expected CFBundleURLSchemes to include: $REVERSED_CLIENT_ID"
|
|
117
|
-
echo "Run flutterfire configure/project setup before building."
|
|
118
|
-
exit 1
|
|
119
|
-
fi
|
|
120
|
-
fi
|
|
121
|
-
- name: Flutter analyze # <-- remove if you don't like flutter analyze
|
|
122
|
-
script: |
|
|
123
|
-
flutter analyze
|
|
124
|
-
- name: Flutter unit tests
|
|
125
|
-
script: |
|
|
126
|
-
flutter test
|
|
127
|
-
ignore_failure: false # You should never build an app that has failing tests.
|
|
128
|
-
- name: Flutter build ipa and automatic versioning
|
|
129
|
-
script: |
|
|
130
|
-
flutter build ipa --release \
|
|
131
|
-
--dart-define=ENV=prod \
|
|
132
|
-
--dart-define=BACKEND_URL=$BACKEND_URL \
|
|
133
|
-
--dart-define=SENTRY_DSN=$SENTRY_DSN \
|
|
134
|
-
--dart-define=RC_ANDROID_API_KEY=$RC_ANDROID_API_KEY \
|
|
135
|
-
--dart-define=RC_IOS_API_KEY=$RC_IOS_API_KEY \
|
|
136
|
-
--dart-define=MIXPANEL_TOKEN=$MIXPANEL_TOKEN \
|
|
137
|
-
--build-name=1.0.0 \
|
|
138
|
-
--build-number=$(($(app-store-connect get-latest-app-store-build-number "$APP_ID") + 1)) \
|
|
139
|
-
--export-options-plist=/Users/builder/export_options.plist
|
|
140
|
-
artifacts:
|
|
141
|
-
- build/ios/ipa/*.ipa
|
|
142
|
-
- /tmp/xcodebuild_logs/*.log
|
|
143
|
-
- flutter_drive.log
|
|
144
|
-
publishing:
|
|
145
|
-
email:
|
|
146
|
-
recipients:
|
|
147
|
-
- # <-- Put your email here or add others recipients
|
|
148
|
-
notify:
|
|
149
|
-
success: true
|
|
150
|
-
failure: true
|
|
151
|
-
app_store_connect:
|
|
152
|
-
auth: integration
|
|
153
|
-
submit_to_app_store: true
|
|
154
|
-
release_type: MANUAL
|
|
155
|
-
submit_to_testflight: true
|
|
156
|
-
beta_groups:
|
|
157
|
-
- kasy # <-- Put your beta group name here
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import 'dart:async';
|
|
2
|
-
|
|
3
|
-
import 'package:facebook_app_events/facebook_app_events.dart';
|
|
4
|
-
import 'package:flutter/foundation.dart';
|
|
5
|
-
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
6
|
-
import 'package:logger/logger.dart';
|
|
7
|
-
import 'package:permission_handler/permission_handler.dart';
|
|
8
|
-
import 'package:kasy_kit/core/initializer/onstart_service.dart';
|
|
9
|
-
import 'package:kasy_kit/core/states/models/user_state.dart';
|
|
10
|
-
import 'package:kasy_kit/core/states/user_state_notifier.dart';
|
|
11
|
-
import 'package:kasy_kit/features/notifications/repositories/device_repository.dart';
|
|
12
|
-
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
13
|
-
|
|
14
|
-
final facebookEventApiProvider = Provider(
|
|
15
|
-
(ref) => FacebookEventApi(
|
|
16
|
-
deviceRepository: ref.watch(deviceRepositoryProvider),
|
|
17
|
-
userState: ref.watch(userStateNotifierProvider),
|
|
18
|
-
),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
class FacebookEventApi implements OnStartService {
|
|
22
|
-
final DeviceRepository deviceRepository;
|
|
23
|
-
final UserState userState;
|
|
24
|
-
|
|
25
|
-
FacebookEventApi({
|
|
26
|
-
required this.deviceRepository,
|
|
27
|
-
required this.userState,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
@override
|
|
31
|
-
Future<void> init() async {
|
|
32
|
-
if (kIsWeb) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// We must init the facebook app events
|
|
36
|
-
final facebookAppEvents = FacebookAppEvents();
|
|
37
|
-
// This is required by RevenueCat
|
|
38
|
-
await facebookAppEvents.setAutoLogAppEventsEnabled(false);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Future<void> initUser(String userId) async {
|
|
42
|
-
if (kIsWeb) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
final facebookAppEvents = FacebookAppEvents();
|
|
46
|
-
await facebookAppEvents.setUserID(userId);
|
|
47
|
-
|
|
48
|
-
if (defaultTargetPlatform != TargetPlatform.iOS) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
final isGranted = await Permission.appTrackingTransparency.isGranted;
|
|
52
|
-
if (!isGranted) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
await facebookAppEvents.setAdvertiserTracking(enabled: true);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Future<void> requestIDFA() async {
|
|
59
|
-
if (kIsWeb) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
final facebookAppEvents = FacebookAppEvents();
|
|
63
|
-
if (defaultTargetPlatform == TargetPlatform.iOS) {
|
|
64
|
-
final status = await Permission.appTrackingTransparency.request();
|
|
65
|
-
// analyticsApi?.logEvent('att_request', {
|
|
66
|
-
// 'granted': true,
|
|
67
|
-
// });
|
|
68
|
-
|
|
69
|
-
debugPrint("IDFA status: $status");
|
|
70
|
-
if (status.isGranted) {
|
|
71
|
-
await facebookAppEvents.setAdvertiserTracking(enabled: true);
|
|
72
|
-
await _initMetaUser();
|
|
73
|
-
unawaited(facebookAppEvents.flush());
|
|
74
|
-
await deviceRepository.refreshExtraData();
|
|
75
|
-
} else {
|
|
76
|
-
await facebookAppEvents.setAdvertiserTracking(enabled: false);
|
|
77
|
-
}
|
|
78
|
-
} else if (defaultTargetPlatform == TargetPlatform.android) {
|
|
79
|
-
await _initMetaUser();
|
|
80
|
-
await facebookAppEvents.setAutoLogAppEventsEnabled(true);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Future<void> _initMetaUser() async {
|
|
85
|
-
final facebookAppEvents = FacebookAppEvents();
|
|
86
|
-
final userId = userState.user.idOrNull;
|
|
87
|
-
if (userId != null) {
|
|
88
|
-
await facebookAppEvents.setUserID(userId);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
Future<void> logMetaStartTrial(String orderId, double price, String currency) async {
|
|
93
|
-
try {
|
|
94
|
-
final facebookAppEvents = FacebookAppEvents();
|
|
95
|
-
await facebookAppEvents.logStartTrial(orderId: orderId, price: price, currency: currency);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
Logger().e("Error logging StartTrial (facebook): $e");
|
|
98
|
-
Sentry.captureException(e, stackTrace: StackTrace.current);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
Future<void> logMetaSubscribe(String orderId, double price, String currency) async {
|
|
103
|
-
try {
|
|
104
|
-
final facebookAppEvents = FacebookAppEvents();
|
|
105
|
-
await facebookAppEvents.logSubscribe(orderId: orderId, price: price, currency: currency);
|
|
106
|
-
} catch (e) {
|
|
107
|
-
Logger().e("Error logging Subscribe (facebook): $e");
|
|
108
|
-
Sentry.captureException(e, stackTrace: StackTrace.current);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
2
|
-
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
3
|
-
// ignore: depend_on_referenced_packages
|
|
4
|
-
// ignore_for_file: invalid_annotation_target
|
|
5
|
-
|
|
6
|
-
import 'package:kasy_kit/core/data/entities/json_converters.dart';
|
|
7
|
-
|
|
8
|
-
part 'feature_request_entity.freezed.dart';
|
|
9
|
-
part 'feature_request_entity.g.dart';
|
|
10
|
-
|
|
11
|
-
@freezed
|
|
12
|
-
sealed class FeatureRequestEntity with _$FeatureRequestEntity {
|
|
13
|
-
const factory FeatureRequestEntity({
|
|
14
|
-
@JsonKey(includeIfNull: false, toJson: Converters.id) String? id,
|
|
15
|
-
@TimestampConverter() required DateTime creationDate,
|
|
16
|
-
@TimestampConverter() required DateTime lastUpdateDate,
|
|
17
|
-
required Map<String, String> title,
|
|
18
|
-
required Map<String, String> description,
|
|
19
|
-
required int votes,
|
|
20
|
-
required bool active, // votes are enabled for this feature
|
|
21
|
-
}) = FeatureRequestEntityData;
|
|
22
|
-
|
|
23
|
-
const FeatureRequestEntity._();
|
|
24
|
-
|
|
25
|
-
factory FeatureRequestEntity.fromJson(String id, Map<String, dynamic> json) =>
|
|
26
|
-
_$FeatureRequestEntityFromJson(json..['id'] = id);
|
|
27
|
-
}
|
package/lib/scaffold/features/feedback/lib/features/feedbacks/api/entities/feature_vote_entity.dart
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
2
|
-
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
3
|
-
// ignore: depend_on_referenced_packages
|
|
4
|
-
// ignore_for_file: invalid_annotation_target
|
|
5
|
-
|
|
6
|
-
import 'package:kasy_kit/core/data/entities/json_converters.dart';
|
|
7
|
-
|
|
8
|
-
part 'feature_vote_entity.freezed.dart';
|
|
9
|
-
part 'feature_vote_entity.g.dart';
|
|
10
|
-
|
|
11
|
-
@freezed
|
|
12
|
-
abstract class UserFeatureVoteEntity with _$UserFeatureVoteEntity {
|
|
13
|
-
const factory UserFeatureVoteEntity({
|
|
14
|
-
@JsonKey(includeIfNull: false, toJson: Converters.id) String? id,
|
|
15
|
-
@JsonKey(name: 'creation_date')
|
|
16
|
-
@TimestampConverter()
|
|
17
|
-
required DateTime creationDate,
|
|
18
|
-
required String userId,
|
|
19
|
-
required String featureId,
|
|
20
|
-
}) = UserFeatureVoteEntityData;
|
|
21
|
-
|
|
22
|
-
const UserFeatureVoteEntity._();
|
|
23
|
-
|
|
24
|
-
factory UserFeatureVoteEntity.fromJson(
|
|
25
|
-
String id, Map<String, dynamic> json) =>
|
|
26
|
-
_$UserFeatureVoteEntityFromJson(json..['id'] = id);
|
|
27
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
2
|
-
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
3
|
-
import 'package:kasy_kit/features/feedbacks/api/entities/feature_request_entity.dart';
|
|
4
|
-
|
|
5
|
-
final featureRequestApiProvider = Provider<FeatureRequestApi>(
|
|
6
|
-
(ref) => FeatureRequestApi(
|
|
7
|
-
client: FirebaseFirestore.instance,
|
|
8
|
-
),
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
class FeatureRequestApi {
|
|
12
|
-
final FirebaseFirestore _client;
|
|
13
|
-
|
|
14
|
-
FeatureRequestApi({
|
|
15
|
-
required FirebaseFirestore client,
|
|
16
|
-
}) : _client = client;
|
|
17
|
-
|
|
18
|
-
CollectionReference<FeatureRequestEntity?> get _collection => _client
|
|
19
|
-
.collection('feature_requests')
|
|
20
|
-
.withConverter(
|
|
21
|
-
fromFirestore: (snapshot, _) {
|
|
22
|
-
if (snapshot.exists) {
|
|
23
|
-
return FeatureRequestEntity.fromJson(snapshot.id, snapshot.data()!);
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
},
|
|
27
|
-
toFirestore: (data, _) => data!.toJson(),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
Future<List<FeatureRequestEntity>> getAllActive() async {
|
|
31
|
-
final snapshot = await _collection.where('active', isEqualTo: true).get();
|
|
32
|
-
return snapshot.docs.map((e) => e.data()!).toList();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
Future<String> create({
|
|
36
|
-
required String title,
|
|
37
|
-
required String description,
|
|
38
|
-
}) async {
|
|
39
|
-
final now = DateTime.now().toIso8601String();
|
|
40
|
-
final docRef = await _client.collection('feature_requests').add({
|
|
41
|
-
'title': {'en': title, 'pt': title, 'es': title},
|
|
42
|
-
'description': {'en': description, 'pt': description, 'es': description},
|
|
43
|
-
'votes': 0,
|
|
44
|
-
'active': false,
|
|
45
|
-
'creation_date': now,
|
|
46
|
-
'last_update_date': now,
|
|
47
|
-
});
|
|
48
|
-
return docRef.id;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
2
|
-
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
3
|
-
import 'package:kasy_kit/features/feedbacks/api/entities/feature_vote_entity.dart';
|
|
4
|
-
|
|
5
|
-
final featureVoteApiProvider = Provider<FeatureVoteApi>(
|
|
6
|
-
(ref) => FeatureVoteApi(
|
|
7
|
-
client: FirebaseFirestore.instance,
|
|
8
|
-
),
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
class FeatureVoteApi {
|
|
12
|
-
final FirebaseFirestore _client;
|
|
13
|
-
|
|
14
|
-
FeatureVoteApi({
|
|
15
|
-
required FirebaseFirestore client,
|
|
16
|
-
}) : _client = client;
|
|
17
|
-
|
|
18
|
-
CollectionReference<UserFeatureVoteEntity?> _featureVoteCollection(
|
|
19
|
-
String featureId) =>
|
|
20
|
-
_client
|
|
21
|
-
.collection('feature_requests')
|
|
22
|
-
.doc(featureId)
|
|
23
|
-
.collection('votes')
|
|
24
|
-
.withConverter(
|
|
25
|
-
fromFirestore: (snapshot, _) {
|
|
26
|
-
if (snapshot.exists) {
|
|
27
|
-
return UserFeatureVoteEntity.fromJson(
|
|
28
|
-
snapshot.id, snapshot.data()!);
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
},
|
|
32
|
-
toFirestore: (data, _) => data!.toJson(),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
Query<UserFeatureVoteEntity?> get collectionGroup =>
|
|
36
|
-
_client.collectionGroup('votes').withConverter(
|
|
37
|
-
fromFirestore: (snapshot, _) {
|
|
38
|
-
if (snapshot.exists) {
|
|
39
|
-
return UserFeatureVoteEntity.fromJson(
|
|
40
|
-
snapshot.id, snapshot.data()!);
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
},
|
|
44
|
-
toFirestore: (data, _) => data!.toJson(),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
Future<List<UserFeatureVoteEntity>> getUserVotes(String userId) async {
|
|
48
|
-
final snapshot =
|
|
49
|
-
await collectionGroup.where('userId', isEqualTo: userId).get();
|
|
50
|
-
return snapshot.docs.map((e) => e.data()!).toList();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
Future<UserFeatureVoteEntity> create(String userId, String featureId) async {
|
|
54
|
-
final result = UserFeatureVoteEntity(
|
|
55
|
-
id: userId,
|
|
56
|
-
userId: userId,
|
|
57
|
-
creationDate: DateTime.now(),
|
|
58
|
-
featureId: featureId,
|
|
59
|
-
);
|
|
60
|
-
final batch = _client.batch();
|
|
61
|
-
batch.set(_featureVoteCollection(featureId).doc(userId), result);
|
|
62
|
-
batch.update(
|
|
63
|
-
_client.collection('feature_requests').doc(featureId),
|
|
64
|
-
{'votes': FieldValue.increment(1), 'last_update_date': FieldValue.serverTimestamp()},
|
|
65
|
-
);
|
|
66
|
-
await batch.commit();
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
Future<void> delete(String featureId, String voteId) async {
|
|
71
|
-
final batch = _client.batch();
|
|
72
|
-
batch.delete(_featureVoteCollection(featureId).doc(voteId));
|
|
73
|
-
batch.update(
|
|
74
|
-
_client.collection('feature_requests').doc(featureId),
|
|
75
|
-
{'votes': FieldValue.increment(-1), 'last_update_date': FieldValue.serverTimestamp()},
|
|
76
|
-
);
|
|
77
|
-
await batch.commit();
|
|
78
|
-
}
|
|
79
|
-
}
|