forked from eatvio/eatvio_app
Compare commits
289 Commits
notificati
...
8816b67ff5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8816b67ff5 | ||
|
|
053cf781c3 | ||
|
|
46d0e31f5f | ||
|
|
c88b010cc5 | ||
|
|
a0b29f42df | ||
|
|
96b3bd1637 | ||
|
|
fc09fa36b8 | ||
|
|
68ea8da6e3 | ||
|
|
052c4fedca | ||
|
|
ad777c695b | ||
|
|
e6df89c98a | ||
|
|
fef4451f4e | ||
|
|
c68f86eeb7 | ||
|
|
fafc2aa1f7 | ||
|
|
ca49415ef6 | ||
|
|
2600b8cc79 | ||
| e1f25a63bc | |||
|
|
087436da1c | ||
|
|
c295c06565 | ||
|
|
b146295996 | ||
|
|
41f77bd373 | ||
|
|
6ac93d42df | ||
|
|
1a6fb39d84 | ||
|
|
d4a8cbc637 | ||
|
|
2300bc4ab6 | ||
|
|
b4776c3be3 | ||
|
|
06e07a92b7 | ||
|
|
0fce3f9d30 | ||
|
|
4bc8cba941 | ||
|
|
8c348f61b1 | ||
|
|
0446e64409 | ||
|
|
74b5c6732d | ||
|
|
b840c936bf | ||
|
|
f3dbbf3537 | ||
|
|
ff49562e86 | ||
|
|
8b7180c2da | ||
|
|
5c911707a3 | ||
|
|
aa604b667b | ||
|
|
0a5d78be1f | ||
|
|
f1f5c79661 | ||
|
|
1c517807c4 | ||
|
|
cad54913d1 | ||
|
|
89f0a46192 | ||
|
|
65542020a7 | ||
|
|
b6b1c8b3c1 | ||
|
|
bf6e23e96a | ||
|
|
952cf76164 | ||
|
|
b665692779 | ||
|
|
54ac20978f | ||
|
|
b9dc5c0136 | ||
|
|
39fce4b0f9 | ||
|
|
73ff67aa13 | ||
|
|
dcf2805df7 | ||
|
|
d13eb78f0e | ||
|
|
5f21a65028 | ||
|
|
12bf9f9e5f | ||
|
|
1680bd2556 | ||
|
|
91d5118f60 | ||
|
|
d8324c1635 | ||
|
|
0f1dbe16f1 | ||
|
|
020682ae80 | ||
|
|
e54476656b | ||
|
|
dd56924076 | ||
|
|
b47da44cf2 | ||
|
|
964550a325 | ||
|
|
7ffa061f3e | ||
|
|
997da4f940 | ||
|
|
ca1777ece0 | ||
|
|
1a427d6f5d | ||
|
|
f190e70f3a | ||
|
|
bc6469a6ae | ||
|
|
e3ff359e1b | ||
|
|
b5edf13bd9 | ||
|
|
c05d027e3d | ||
|
|
bae79b60fd | ||
|
|
6061e413b2 | ||
|
|
5a8fa7089c | ||
|
|
886cfa8f1c | ||
|
|
a416912d2a | ||
|
|
f46392ec8e | ||
|
|
766d06fc4d | ||
|
|
6f4023dd0b | ||
|
|
f892dfed9f | ||
|
|
98803e56cf | ||
|
|
4391870e72 | ||
|
|
7fd24f57e3 | ||
|
|
384a25c4a6 | ||
|
|
88558d62ef | ||
|
|
09b04118aa | ||
|
|
f76b142117 | ||
|
|
13e66edd27 | ||
|
|
5b74ae45b3 | ||
|
|
3d2634b96a | ||
|
|
1281abaf24 | ||
|
|
7dfac3f792 | ||
|
|
9d4687553a | ||
|
|
442da40622 | ||
|
|
ccf586234b | ||
|
|
4f249499a9 | ||
|
|
2f74387df2 | ||
|
|
45774c3875 | ||
|
|
62c0914fe2 | ||
|
|
48f5b64223 | ||
| ed4db5b59e | |||
|
|
91bb5cf483 | ||
|
|
c4dedac3f3 | ||
|
|
8ed243f63c | ||
|
|
a10fe6d2f5 | ||
|
|
35b78bdeee | ||
|
|
ef037eb4d5 | ||
|
|
5a3385cacf | ||
|
|
ef4d91a5d8 | ||
|
|
dca4b4c471 | ||
|
|
48f433288f | ||
|
|
cfbd7597fa | ||
|
|
412ac0aeeb | ||
|
|
6211332a07 | ||
|
|
4b1d21b4af | ||
|
|
3b89a69d3b | ||
|
|
3e8c8c7e9f | ||
|
|
e73463dcf7 | ||
|
|
60d30163e7 | ||
|
|
04c1b889a0 | ||
|
|
06117ddb6a | ||
|
|
15f0538f04 | ||
|
|
3c56c59c9f | ||
|
|
038e30b198 | ||
|
|
cdb6fcb462 | ||
|
|
e93a573a72 | ||
|
|
d8378e3686 | ||
|
|
f464da6f9d | ||
|
|
73f27efadd | ||
|
|
90cac4940f | ||
|
|
2fac007675 | ||
|
|
1cafff65dc | ||
|
|
fe99890c0e | ||
|
|
15248a65fe | ||
| ee0d4d17af | |||
|
|
6fa7beb070 | ||
| 24d0d6eedc | |||
|
|
905559b1f0 | ||
| 6cb330752f | |||
|
|
69995289c5 | ||
|
|
f9b63f3401 | ||
| 3068d82b3a | |||
|
|
1305e67817 | ||
|
|
9be8ec7ac3 | ||
|
|
7ad01d3d4e | ||
|
|
832ba421e9 | ||
|
|
7e7f8bfb03 | ||
|
|
1f714b3bc2 | ||
|
|
187d60ffb9 | ||
|
|
64b158d1ff | ||
|
|
62f5cab746 | ||
|
|
0d27da3ec9 | ||
|
|
1387e20553 | ||
|
|
13fc59ff62 | ||
|
|
d3ed027c38 | ||
|
|
108e067b11 | ||
|
|
c58cc54e43 | ||
|
|
6df116ef74 | ||
|
|
b051a588e0 | ||
|
|
721430301a | ||
|
|
98d7b727a3 | ||
|
|
236abdd1d2 | ||
|
|
138a81d9d1 | ||
|
|
f43059c820 | ||
|
|
c4ff14c7b2 | ||
|
|
33151b7dae | ||
|
|
b302be66d7 | ||
|
|
4f0f146fd2 | ||
|
|
7986119054 | ||
|
|
76582fd487 | ||
|
|
cd9357c050 | ||
|
|
d53fdd1ccb | ||
|
|
e75539338b | ||
|
|
7267fc454b | ||
|
|
9e0c89c04e | ||
|
|
a9a479b2d3 | ||
|
|
12af348000 | ||
|
|
039c09962a | ||
|
|
681c11fed9 | ||
|
|
5b616a9dc1 | ||
|
|
3e5cc4f8d7 | ||
|
|
3cc7809210 | ||
|
|
be1d8c295a | ||
|
|
7a177f7517 | ||
|
|
c718875b49 | ||
|
|
c618a6a80d | ||
|
|
3e7202d65e | ||
|
|
f78ccd01b6 | ||
|
|
a4d0fd0108 | ||
|
|
6f1368f3c6 | ||
|
|
83a39835fa | ||
|
|
49b597d5ae | ||
|
|
f5d27ed056 | ||
|
|
8a26fa0990 | ||
|
|
15a9e2b1bd | ||
|
|
7192db31e4 | ||
|
|
190e1781ee | ||
|
|
a134c2043b | ||
|
|
09a1ec0947 | ||
|
|
1db9c57140 | ||
|
|
aacbc0ce5a | ||
|
|
1bdc1c53f6 | ||
|
|
20e71a77d8 | ||
|
|
d037b6aaa7 | ||
|
|
43495f407e | ||
|
|
f0c94c4f82 | ||
| 60b0b20844 | |||
|
|
969f8d37af | ||
| d1c9c1f292 | |||
|
|
ec05b0c8fb | ||
| 5eaab6b213 | |||
|
|
5db29ae681 | ||
| b55a0d0590 | |||
|
|
44a938ea29 | ||
| be78fca7d0 | |||
|
|
955daf4933 | ||
| 8bdbb9059f | |||
|
|
27a0bcd6ce | ||
| d5e2af2de5 | |||
|
|
5a8dcafa8e | ||
| be5796fbfd | |||
|
|
02b621d85a | ||
| 683a7e1066 | |||
|
|
773359e900 | ||
|
|
74fa65a1ba | ||
|
|
46f11a8e78 | ||
|
|
3e2aff3ad4 | ||
|
|
09c53a6492 | ||
|
|
452c603b95 | ||
|
|
6bcd540d54 | ||
|
|
2c38be9fa4 | ||
|
|
74df7d82db | ||
|
|
c8d5fc756e | ||
|
|
1b9534b690 | ||
|
|
5ac5deec48 | ||
|
|
08cf1ad370 | ||
|
|
2c59fd0923 | ||
|
|
958d09906b | ||
|
|
631efe6f9e | ||
|
|
0749a53e24 | ||
| 0982c97d66 | |||
|
|
e4168862ad | ||
| 59f26ee977 | |||
| 187b056413 | |||
|
|
e546cacd0c | ||
| e1266a18f4 | |||
|
|
9bbd149d03 | ||
|
|
27f97d0e11 | ||
|
|
ea2ec05ed6 | ||
|
|
7b1574392b | ||
|
|
6dc30f4c89 | ||
|
|
4426eef2dc | ||
|
|
e04c5c97f9 | ||
|
|
0a636e05b8 | ||
|
|
987d80e4ce | ||
|
|
69412ee7ea | ||
|
|
478ac139dd | ||
|
|
0886d1cd7b | ||
|
|
2759cc64c9 | ||
|
|
cfe6b50c28 | ||
|
|
61d1ad1f55 | ||
|
|
ebe28136af | ||
|
|
058b0267be | ||
|
|
e1ca8c3d77 | ||
|
|
0f9677d6ab | ||
|
|
7f90430000 | ||
|
|
a3f0fe03af | ||
|
|
dd40689fd7 | ||
|
|
a30d10c179 | ||
|
|
460045108e | ||
|
|
9e22a4163a | ||
|
|
f20d645420 | ||
|
|
96e80ced38 | ||
|
|
b1111a461d | ||
|
|
f5e2634c07 | ||
|
|
9e49b3dbca | ||
|
|
e242b27e44 | ||
|
|
1b7a5219d3 | ||
|
|
1740823e48 | ||
|
|
265a9b60c3 | ||
|
|
f145ccb8e0 | ||
|
|
44e3b89875 | ||
|
|
c02585b149 | ||
|
|
69c53321d2 | ||
|
|
87393726fd | ||
|
|
a179e5fa83 |
@@ -11,6 +11,29 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Checkout env repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: mso7nueh/eatvio_app_env
|
||||||
|
path: env_repo
|
||||||
|
token: ${{ vars.MSO7NUEH_TOKEN }}
|
||||||
|
ref: main
|
||||||
|
|
||||||
|
- name: Copy .env file
|
||||||
|
run: |
|
||||||
|
cp env_repo/.env .env
|
||||||
|
|
||||||
|
- name: Load environment variables from .env
|
||||||
|
run: |
|
||||||
|
set -a
|
||||||
|
source .env
|
||||||
|
set +a
|
||||||
|
# Export all variables to GITHUB_ENV
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ $line =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then
|
||||||
|
echo "$line" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
done < .env
|
||||||
|
|
||||||
- name: Unlock login keychain
|
- name: Unlock login keychain
|
||||||
run: |
|
run: |
|
||||||
@@ -18,12 +41,25 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
KEYCHAIN_PASSWORD: ${{ vars.IOS_RUNNER_CI_PASSWORD }}
|
KEYCHAIN_PASSWORD: ${{ vars.IOS_RUNNER_CI_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Setup API key
|
||||||
|
run: |
|
||||||
|
echo "${API_APPSTORE_KEY}" | tr -d '\n' | base64 --decode > ios/AuthKey.p8
|
||||||
|
chmod 600 ios/AuthKey.p8
|
||||||
|
ls -la ios/AuthKey.p8
|
||||||
|
echo "File size: $(wc -c < ios/AuthKey.p8) bytes"
|
||||||
|
echo "Contents of ios directory:"
|
||||||
|
ls -la ios/
|
||||||
|
env:
|
||||||
|
API_APPSTORE_KEY: ${{ vars.API_APPSTORE_KEY }}
|
||||||
|
|
||||||
- name: Flutter build
|
- name: Flutter build
|
||||||
run: |
|
run: |
|
||||||
flutter clean
|
flutter clean
|
||||||
flutter pub get
|
flutter pub get
|
||||||
flutter pub upgrade
|
flutter pub upgrade
|
||||||
flutter pub run build_runner build --delete-conflicting-outputs
|
flutter pub run build_runner build --delete-conflicting-outputs
|
||||||
|
# Configure Flutter for release mode
|
||||||
|
flutter build ios --config-only --release
|
||||||
cd ios
|
cd ios
|
||||||
pod update
|
pod update
|
||||||
fastlane beta
|
fastlane beta
|
||||||
@@ -31,6 +67,8 @@ jobs:
|
|||||||
LANG: en_US.UTF-8
|
LANG: en_US.UTF-8
|
||||||
LC_ALL: en_US.UTF-8
|
LC_ALL: en_US.UTF-8
|
||||||
MATCH_PASSWORD: ${{ vars.IOS_RUNNER_CI_PASSWORD }}
|
MATCH_PASSWORD: ${{ vars.IOS_RUNNER_CI_PASSWORD }}
|
||||||
|
FASTLANE_PASSWORD: ${{ vars.FASTLANE_PASSWORD }}
|
||||||
MATCH_GIT_URL: http://gitea.office.local:3000/mso7nueh/fastlane
|
MATCH_GIT_URL: http://gitea.office.local:3000/mso7nueh/fastlane
|
||||||
FASTLANE_USER: eatvio2023@icloud.com
|
FASTLANE_USER: eatvio2023@icloud.com
|
||||||
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ vars.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
|
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ vars.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
|
||||||
|
API_APPSTORE_KEY: ${{ vars.API_APPSTORE_KEY }}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: Eatvio App Android Test
|
|||||||
on: [ pull_request ]
|
on: [ pull_request ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
flutter_version: "3.32.5"
|
flutter_version: "3.35.1"
|
||||||
java_version: "21.x"
|
java_version: "21.x"
|
||||||
flutter_channel: "stable"
|
flutter_channel: "stable"
|
||||||
my_local_cache_dir: "/opt/hostedtoolcache/"
|
my_local_cache_dir: "/opt/hostedtoolcache/"
|
||||||
@@ -16,6 +16,30 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Checkout env repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: mso7nueh/eatvio_app_env
|
||||||
|
path: env_repo
|
||||||
|
token: ${{ vars.MSO7NUEH_TOKEN }}
|
||||||
|
ref: main
|
||||||
|
|
||||||
|
- name: Copy .env file
|
||||||
|
run: |
|
||||||
|
cp env_repo/.env .env
|
||||||
|
|
||||||
|
- name: Load environment variables from .env
|
||||||
|
run: |
|
||||||
|
set -a
|
||||||
|
source .env
|
||||||
|
set +a
|
||||||
|
# Export all variables to GITHUB_ENV
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ $line =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then
|
||||||
|
echo "$line" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
done < .env
|
||||||
|
|
||||||
- name: Create key.properties file
|
- name: Create key.properties file
|
||||||
run: |
|
run: |
|
||||||
cat > android/key.properties <<EOF
|
cat > android/key.properties <<EOF
|
||||||
@@ -119,7 +143,11 @@ jobs:
|
|||||||
run: flutter test
|
run: flutter test
|
||||||
|
|
||||||
- name: Build apk
|
- name: Build apk
|
||||||
run: flutter build apk --release
|
run: |
|
||||||
|
BUILD_DATE=$(TZ=Europe/Moscow date +'%Y-%m-%d %H:%M:%S')
|
||||||
|
flutter build apk --release \
|
||||||
|
--dart-define=HIDE_PLANS=false \
|
||||||
|
--dart-define=BUILD_DATE="$BUILD_DATE"
|
||||||
|
|
||||||
- name: Rename and move apk
|
- name: Rename and move apk
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -12,5 +12,11 @@
|
|||||||
/android/app/.cxx
|
/android/app/.cxx
|
||||||
*.g.dart
|
*.g.dart
|
||||||
*.freezed.dart
|
*.freezed.dart
|
||||||
|
*.gr.dart
|
||||||
|
*.mocks.dart
|
||||||
android/build/
|
android/build/
|
||||||
ios/XCBuildData/
|
ios/XCBuildData/
|
||||||
|
env/.env
|
||||||
|
.env
|
||||||
|
android/key.properties
|
||||||
|
app/upload-keystore.jks
|
||||||
84
ENV_SETUP.md
Normal file
84
ENV_SETUP.md
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
# Настройка переменных окружения
|
||||||
|
|
||||||
|
Этот проект использует переменные окружения для хранения секретных данных и конфигурации.
|
||||||
|
|
||||||
|
## Установка
|
||||||
|
|
||||||
|
1. Скопируйте файл `env.example` в `.env`:
|
||||||
|
```bash
|
||||||
|
cp env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Отредактируйте файл `.env` и замените значения на ваши собственные секреты.
|
||||||
|
|
||||||
|
## Переменные окружения
|
||||||
|
|
||||||
|
### API URLs
|
||||||
|
- `BASE_URL` - основной URL API (по умолчанию: https://eatvio.ru)
|
||||||
|
- `DEV_BASE_URL` - URL API для разработки (по умолчанию: https://dev2.eatvio.com)
|
||||||
|
|
||||||
|
### Sentry Configuration
|
||||||
|
- `SENTRY_DSN` - DSN для Sentry мониторинга
|
||||||
|
|
||||||
|
### Firebase Configuration
|
||||||
|
- `FIREBASE_PROJECT_ID` - ID проекта Firebase
|
||||||
|
- `FIREBASE_DATABASE_URL` - URL базы данных Firebase
|
||||||
|
- `FIREBASE_STORAGE_BUCKET` - bucket для хранения файлов
|
||||||
|
- `FIREBASE_MESSAGING_SENDER_ID` - ID отправителя сообщений
|
||||||
|
|
||||||
|
### Firebase Android Configuration
|
||||||
|
- `FIREBASE_ANDROID_API_KEY` - API ключ для Android
|
||||||
|
- `FIREBASE_ANDROID_APP_ID` - ID приложения для Android
|
||||||
|
|
||||||
|
### Firebase iOS Configuration
|
||||||
|
- `FIREBASE_IOS_API_KEY` - API ключ для iOS
|
||||||
|
- `FIREBASE_IOS_APP_ID` - ID приложения для iOS
|
||||||
|
- `FIREBASE_IOS_BUNDLE_ID` - Bundle ID для iOS
|
||||||
|
|
||||||
|
### App Store URLs
|
||||||
|
- `APP_STORE_URL` - URL App Store
|
||||||
|
- `RUSTORE_URL` - URL RuStore
|
||||||
|
|
||||||
|
### Support URLs
|
||||||
|
- `TELEGRAM_SUPPORT_URL` - URL поддержки в Telegram
|
||||||
|
- `SUPPORT_EMAIL` - email для поддержки
|
||||||
|
|
||||||
|
### Test Credentials (только для разработки)
|
||||||
|
- `TEST_EMAIL` - тестовый email
|
||||||
|
- `TEST_PASSWORD` - тестовый пароль
|
||||||
|
|
||||||
|
### Email Validation API
|
||||||
|
- `EMAIL_VALIDATION_API_URL` - URL API для валидации email
|
||||||
|
|
||||||
|
### Connection Check URLs
|
||||||
|
- `GOOGLE_CHECK_URL` - URL для проверки соединения (Google)
|
||||||
|
- `YANDEX_CHECK_URL` - URL для проверки соединения (Yandex)
|
||||||
|
|
||||||
|
## Безопасность
|
||||||
|
|
||||||
|
⚠️ **ВАЖНО**: Файл `.env` добавлен в `.gitignore` и не должен попадать в репозиторий. Все секретные данные должны храниться только в этом файле.
|
||||||
|
|
||||||
|
## Использование в коде
|
||||||
|
|
||||||
|
Для доступа к переменным окружения используйте класс `EnvConfig`:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
import 'package:eatvio_app/core/env_config.dart';
|
||||||
|
|
||||||
|
String baseUrl = EnvConfig.baseUrl;
|
||||||
|
String sentryDsn = EnvConfig.sentryDsn;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Миграция
|
||||||
|
|
||||||
|
Все секреты были перенесены из кода в переменные окружения:
|
||||||
|
|
||||||
|
1. **Sentry DSN** - из `main.dart`
|
||||||
|
2. **Firebase конфигурация** - из `firebase_options.dart`
|
||||||
|
3. **API URLs** - из `const.dart`
|
||||||
|
4. **URL для проверки соединения** - из `internet_connection_checker_screen.dart`
|
||||||
|
5. **URL для обновления приложения** - из `update_screen.dart`
|
||||||
|
6. **URL поддержки Telegram** - из `support_screen.dart`
|
||||||
|
7. **API для валидации email** - из `registration_repository.dart`
|
||||||
|
8. **Тестовые учетные данные** - из `test_cases.dart`
|
||||||
|
9. **Email поддержки** - из `support_screen.dart`
|
||||||
1
android/app/agconnect-services.json
Normal file
1
android/app/agconnect-services.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"agcgw":{"url":"connect-drru.hispace.dbankcloud.ru","backurl":"connect-drru.hispace.dbankcloud.cn","websocketurl":"connect-ws-drru.hispace.dbankcloud.ru","websocketbackurl":"connect-ws-drru.hispace.dbankcloud.cn"},"agcgw_all":{"SG":"connect-dra.dbankcloud.cn","SG_back":"connect-dra.hispace.hicloud.com","CN":"connect-drcn.dbankcloud.cn","CN_back":"connect-drcn.hispace.hicloud.com","RU":"connect-drru.hispace.dbankcloud.ru","RU_back":"connect-drru.hispace.dbankcloud.cn","DE":"connect-dre.dbankcloud.cn","DE_back":"connect-dre.hispace.hicloud.com"},"websocketgw_all":{"SG":"connect-ws-dra.hispace.dbankcloud.cn","SG_back":"connect-ws-dra.hispace.dbankcloud.com","CN":"connect-ws-drcn.hispace.dbankcloud.cn","CN_back":"connect-ws-drcn.hispace.dbankcloud.com","RU":"connect-ws-drru.hispace.dbankcloud.ru","RU_back":"connect-ws-drru.hispace.dbankcloud.cn","DE":"connect-ws-dre.hispace.dbankcloud.cn","DE_back":"connect-ws-dre.hispace.dbankcloud.com"},"client":{"cp_id":"20007000036693451","product_id":"461323198429446894","client_id":"1595824543740483264","client_secret":"2A1727B0D31AA9BE1F5D9E8A5CDA1A67B9EF084AC9FB68D6C633A3CCB08ECDEE","project_id":"461323198429446894","app_id":"113238569","api_key":"DQEDAJNRITp9M3uc1rPHyT8PzLc7bnVcKJAeavZZk0TQNMx9ifvBebr+JOmZe9tEvjnLwv7c1hAHXmPGR/gWG86iABDrCVotq+NGnw==","package_name":"com.eatvioapp.app"},"oauth_client":{"client_id":"113238569","client_type":1},"app_info":{"app_id":"113238569","package_name":"com.eatvioapp.app"},"service":{"analytics":{"collector_url":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com","collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn","collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn","collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com","collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn","resource_id":"p1","channel_id":""},"ml":{"mlservice_url":"ml-api-drru.ai.dbankcloud.ru,ml-api-drru.ai.dbankcloud.cn"},"cloudstorage":{"storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn","storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru","storage_url_sg":"https://ops-dra.agcstorage.link","storage_url_de":"https://ops-dre.agcstorage.link","storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn","storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru","storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia","storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu","storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn"},"search":{"url":"https://search-drru.cloud.huawei.ru"},"edukit":{"edu_url":"edukit.cloud.huawei.com.cn","dh_url":"edukit.cloud.huawei.com.cn"}},"region":"RU","configuration_version":"3.0","appInfos":[{"package_name":"com.eatvioapp.app","client":{"app_id":"113238569"},"app_info":{"package_name":"com.eatvioapp.app","app_id":"113238569"},"oauth_client":{"client_type":1,"client_id":"113238569"}}]}
|
||||||
@@ -5,6 +5,7 @@ plugins {
|
|||||||
// END: FlutterFire Configuration
|
// END: FlutterFire Configuration
|
||||||
id "kotlin-android"
|
id "kotlin-android"
|
||||||
id "dev.flutter.flutter-gradle-plugin"
|
id "dev.flutter.flutter-gradle-plugin"
|
||||||
|
id 'com.huawei.agconnect'
|
||||||
}
|
}
|
||||||
|
|
||||||
def keystoreProperties = new Properties()
|
def keystoreProperties = new Properties()
|
||||||
@@ -13,26 +14,32 @@ if (keystorePropertiesFile.exists()) {
|
|||||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def yandexClientId = project.hasProperty('YANDEX_CLIENT_ID') ? project.property('YANDEX_CLIENT_ID') : (System.getenv('YANDEX_CLIENT_ID') ?: "")
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.eatvioapp.app"
|
namespace = "com.eatvioapp.app"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = "27.0.12077973"
|
ndkVersion = "27.0.12077973"
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = 21
|
jvmTarget = JavaVersion.VERSION_11.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.eatvioapp.app"
|
applicationId = "com.eatvioapp.app"
|
||||||
minSdk = flutter.minSdkVersion
|
minSdkVersion flutter.minSdkVersion
|
||||||
targetSdk = flutter.targetSdkVersion
|
targetSdk = flutter.targetSdkVersion
|
||||||
versionCode = flutter.versionCode
|
versionCode = flutter.versionCode
|
||||||
versionName = flutter.versionName
|
versionName = flutter.versionName
|
||||||
|
manifestPlaceholders = [
|
||||||
|
YANDEX_CLIENT_ID: yandexClientId,
|
||||||
|
applicationName: "io.flutter.app.FlutterApplication"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
@@ -47,6 +54,9 @@ android {
|
|||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
|
minifyEnabled true
|
||||||
|
shrinkResources true
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
@@ -57,6 +67,15 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.huawei.agconnect:agconnect-core:1.9.1.301'
|
||||||
|
implementation 'com.huawei.hms:push:6.12.0.300'
|
||||||
|
// Huawei Analytics dependency to satisfy com.huawei.hianalytics.* references during R8
|
||||||
|
implementation 'com.huawei.hms:hianalytics:6.12.0.300'
|
||||||
|
// BouncyCastle provider required by Huawei secure utils used transitively by HMS
|
||||||
|
implementation 'org.bouncycastle:bcprov-jdk15to18:1.78.1'
|
||||||
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
source = "../.."
|
source = "../.."
|
||||||
}
|
}
|
||||||
|
|||||||
21
android/app/proguard-rules.pro
vendored
Normal file
21
android/app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
-keep class com.huawei.** { *; }
|
||||||
|
-dontwarn com.huawei.**
|
||||||
|
|
||||||
|
-keep class org.bouncycastle.** { *; }
|
||||||
|
-dontwarn org.bouncycastle.**
|
||||||
|
|
||||||
|
-keep class io.flutter.** { *; }
|
||||||
|
-dontwarn io.flutter.**
|
||||||
|
|
||||||
|
-keep class kotlinx.coroutines.** { *; }
|
||||||
|
-dontwarn kotlinx.coroutines.**
|
||||||
|
|
||||||
|
-keep class **.R$* { *; }
|
||||||
|
-keepclassmembers class ** { @androidx.annotation.Keep *; }
|
||||||
|
-keep @androidx.annotation.Keep class * { *; }
|
||||||
|
|
||||||
|
-keep public class * extends android.app.Application
|
||||||
|
-keep public class * extends android.content.ContentProvider
|
||||||
|
|
||||||
|
-keep class * implements android.os.Parcelable { *; }
|
||||||
|
-keepclassmembers enum * { *; }
|
||||||
@@ -2,12 +2,25 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="Eatvio"
|
android:label="Итвио"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
|
<service
|
||||||
|
android:name=".HmsPushService"
|
||||||
|
android:exported="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
<meta-data
|
||||||
|
android:name="push_kit_auto_init_enabled"
|
||||||
|
android:value="true" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.eatvioapp.app
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.huawei.hms.push.HmsMessageService
|
||||||
|
import com.huawei.hms.push.RemoteMessage
|
||||||
|
|
||||||
|
class HmsPushService : HmsMessageService() {
|
||||||
|
override fun onNewToken(token: String?) {
|
||||||
|
super.onNewToken(token)
|
||||||
|
Log.i("HMS", "onNewToken: ${token ?: "null"}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMessageReceived(message: RemoteMessage?) {
|
||||||
|
super.onMessageReceived(message)
|
||||||
|
Log.i("HMS", "onMessageReceived: ${message?.data}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,71 @@
|
|||||||
package com.eatvioapp.app
|
package com.eatvioapp.app
|
||||||
|
|
||||||
|
import android.content.pm.ApplicationInfo
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Bundle
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import com.huawei.agconnect.config.AGConnectServicesConfig
|
||||||
|
import com.huawei.hms.aaid.HmsInstanceId
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class MainActivity: FlutterActivity() {
|
class MainActivity: FlutterActivity() {
|
||||||
|
private val channelName = "com.eatvioapp/hms_push"
|
||||||
|
|
||||||
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
|
super.configureFlutterEngine(flutterEngine)
|
||||||
|
|
||||||
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, channelName)
|
||||||
|
.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"getHuaweiToken" -> {
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
try {
|
||||||
|
// Try to read appId from agconnect-services.json
|
||||||
|
var appId: String? = try {
|
||||||
|
AGConnectServicesConfig.fromContext(applicationContext)
|
||||||
|
.getString("client/app_id")
|
||||||
|
} catch (_: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to manifest meta-data if needed
|
||||||
|
if (appId.isNullOrBlank()) {
|
||||||
|
try {
|
||||||
|
val pm: PackageManager = applicationContext.packageManager
|
||||||
|
val ai: ApplicationInfo = pm.getApplicationInfo(applicationContext.packageName, PackageManager.GET_META_DATA)
|
||||||
|
val raw = ai.metaData?.getString("com.huawei.hms.client.appid")
|
||||||
|
if (!raw.isNullOrBlank()) {
|
||||||
|
appId = raw.removePrefix("appid=")
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
// ignore and handle below
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appId.isNullOrBlank()) {
|
||||||
|
runOnUiThread {
|
||||||
|
result.error("HMS_TOKEN_ERROR", "Missing Huawei appId. Ensure agconnect-services.json or manifest meta-data is configured.", null)
|
||||||
|
}
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
val token = HmsInstanceId.getInstance(applicationContext)
|
||||||
|
.getToken(appId, "HCM")
|
||||||
|
runOnUiThread {
|
||||||
|
result.success(token)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
runOnUiThread {
|
||||||
|
result.error("HMS_TOKEN_ERROR", e.message, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,21 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven {url 'https://developer.huawei.com/repo/'}
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:8.12.0'
|
||||||
|
classpath 'com.huawei.agconnect:agcp:1.9.1.301'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {url 'https://developer.huawei.com/repo/'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,6 +27,32 @@ subprojects {
|
|||||||
project.evaluationDependsOn(":app")
|
project.evaluationDependsOn(":app")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary safeguard: set missing namespaces for Android library modules based on their manifest package
|
||||||
|
subprojects { Project subproject ->
|
||||||
|
subproject.pluginManager.withPlugin('com.android.library') {
|
||||||
|
def androidExt = subproject.extensions.findByName('android')
|
||||||
|
if (androidExt != null) {
|
||||||
|
def hasNamespaceProp = androidExt.hasProperty('namespace')
|
||||||
|
def currentNamespace = hasNamespaceProp ? androidExt.namespace : null
|
||||||
|
if (hasNamespaceProp && !currentNamespace) {
|
||||||
|
def manifestFile = file("${subproject.projectDir}/src/main/AndroidManifest.xml")
|
||||||
|
if (manifestFile.exists()) {
|
||||||
|
try {
|
||||||
|
def manifest = new groovy.xml.XmlSlurper().parse(manifestFile)
|
||||||
|
def manifestPackage = manifest.@package?.text()
|
||||||
|
if (manifestPackage) {
|
||||||
|
androidExt.namespace = manifestPackage
|
||||||
|
subproject.logger.lifecycle("[namespace-fix] Set namespace for ${subproject.path} to '${manifestPackage}' from AndroidManifest.xml")
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
subproject.logger.warn("[namespace-fix] Failed to read manifest for ${subproject.path}: ${t.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.register("clean", Delete) {
|
tasks.register("clean", Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
|
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-all.zip
|
||||||
|
|||||||
@@ -12,17 +12,18 @@ pluginManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url 'https://developer.huawei.com/repo/' }
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||||
id "com.android.application" version "8.7.3" apply false
|
id "com.android.application" version "8.12.0" apply false
|
||||||
// START: FlutterFire Configuration
|
// START: FlutterFire Configuration
|
||||||
id "com.google.gms.google-services" version "4.4.2" apply false
|
id "com.google.gms.google-services" version "4.4.3" apply false
|
||||||
// END: FlutterFire Configuration
|
// END: FlutterFire Configuration
|
||||||
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
|
id "org.jetbrains.kotlin.android" version "2.2.10" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
include ":app"
|
include ":app"
|
||||||
|
|||||||
3
assets/icons/reply.svg
Normal file
3
assets/icons/reply.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="19" height="14" viewBox="0 0 19 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M3.56039 6.73215L7.06827 10.2925C7.22519 10.452 7.3026 10.6385 7.30049 10.8521C7.29855 11.0656 7.21569 11.2555 7.0519 11.4218C6.88812 11.577 6.70269 11.6573 6.49563 11.6629C6.28874 11.6682 6.1034 11.5879 5.93961 11.4218L1.19568 6.60653C1.0048 6.41278 0.909363 6.1868 0.909363 5.92858C0.909363 5.67037 1.0048 5.44439 1.19568 5.25064L5.93961 0.435368C6.08581 0.287154 6.26675 0.211261 6.48243 0.207689C6.69829 0.204297 6.88812 0.280189 7.0519 0.435368C7.21569 0.601618 7.29759 0.792601 7.29759 1.00831C7.29759 1.22385 7.21569 1.41474 7.0519 1.58099L3.56039 5.12501H13.4583C14.8441 5.12501 16.0261 5.62162 17.0045 6.61483C17.983 7.60787 18.4722 8.80769 18.4722 10.2143V13.1607C18.4722 13.3888 18.3964 13.5797 18.2448 13.7334C18.0933 13.8873 17.9052 13.9643 17.6806 13.9643C17.4559 13.9643 17.2678 13.8873 17.1164 13.7334C16.9647 13.5797 16.8889 13.3888 16.8889 13.1607V10.2143C16.8889 9.25269 16.5539 8.43197 15.884 7.75215C15.2143 7.07215 14.4057 6.73215 13.4583 6.73215H3.56039Z" fill="#2F80ED"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
3
assets/icons/resend.svg
Normal file
3
assets/icons/resend.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M19.377 11L15.3193 6.94225C15.1641 6.78709 15.0865 6.60892 15.0865 6.40775C15.0865 6.20642 15.1641 6.02817 15.3193 5.873C15.4744 5.72817 15.6542 5.65734 15.8587 5.6605C16.0631 5.66384 16.2345 5.73467 16.373 5.873L20.8673 10.3673C20.9609 10.4609 21.0269 10.5597 21.0653 10.6635C21.1038 10.7673 21.123 10.8795 21.123 11C21.123 11.1205 21.1038 11.2327 21.0653 11.3365C21.0269 11.4403 20.9609 11.5391 20.8673 11.6328L16.373 16.127C16.2178 16.282 16.0422 16.357 15.8462 16.352C15.6501 16.3468 15.4744 16.2718 15.3193 16.127C15.1641 15.9718 15.0856 15.7946 15.0837 15.5953C15.0817 15.3959 15.1551 15.2218 15.3038 15.073L19.377 11ZM14.0693 11.75H7.25C6.3525 11.75 5.5865 12.0673 4.952 12.702C4.31733 13.3365 4 14.1025 4 15V17.75C4 17.9628 3.92817 18.141 3.7845 18.2845C3.641 18.4282 3.46283 18.5 3.25 18.5C3.03717 18.5 2.859 18.4282 2.7155 18.2845C2.57183 18.141 2.5 17.9628 2.5 17.75V15C2.5 13.6872 2.9635 12.5673 3.8905 11.6405C4.81733 10.7135 5.93717 10.25 7.25 10.25H14.0693L10.7615 6.94225C10.6065 6.78709 10.529 6.60892 10.529 6.40775C10.529 6.20642 10.6065 6.02817 10.7615 5.873C10.9167 5.72817 11.0965 5.65734 11.301 5.6605C11.5055 5.66384 11.677 5.73467 11.8155 5.873L16.3095 10.3673C16.4032 10.4609 16.4692 10.5597 16.5078 10.6635C16.5463 10.7673 16.5655 10.8795 16.5655 11C16.5655 11.1205 16.5463 11.2327 16.5078 11.3365C16.4692 11.4403 16.4032 11.5391 16.3095 11.6328L11.8155 16.127C11.6603 16.282 11.4847 16.357 11.2885 16.352C11.0923 16.3468 10.9167 16.2718 10.7615 16.127C10.6065 15.9718 10.528 15.7946 10.526 15.5953C10.524 15.3959 10.5974 15.2218 10.7463 15.073L14.0693 11.75Z" fill="#2F80ED"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -21,6 +21,6 @@
|
|||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>MinimumOSVersion</key>
|
<key>MinimumOSVersion</key>
|
||||||
<string>12.0</string>
|
<string>16.0</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "fastlane"
|
gem "fastlane", "~> 2.217"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Uncomment this line to define a global platform for your project
|
# Uncomment this line to define a global platform for your project
|
||||||
platform :ios, '14.0'
|
platform :ios, '16.0'
|
||||||
|
|
||||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||||
@@ -39,7 +39,7 @@ post_install do |installer|
|
|||||||
flutter_additional_ios_build_settings(target)
|
flutter_additional_ios_build_settings(target)
|
||||||
target.build_configurations.each do |config|
|
target.build_configurations.each do |config|
|
||||||
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
|
||||||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
|
||||||
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
|
||||||
'$(inherited)',
|
'$(inherited)',
|
||||||
## dart: PermissionGroup.camera
|
## dart: PermissionGroup.camera
|
||||||
|
|||||||
@@ -370,7 +370,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SUPPORTED_PLATFORMS = iphoneos;
|
SUPPORTED_PLATFORMS = iphoneos;
|
||||||
@@ -388,7 +388,7 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
|
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 74;
|
||||||
DEVELOPMENT_TEAM = VL68C36HYS;
|
DEVELOPMENT_TEAM = VL68C36HYS;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@@ -406,10 +406,11 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.50;
|
MARKETING_VERSION = 1.2.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
||||||
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
@@ -466,7 +467,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = YES;
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
@@ -518,7 +519,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SUPPORTED_PLATFORMS = iphoneos;
|
SUPPORTED_PLATFORMS = iphoneos;
|
||||||
@@ -538,7 +539,7 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
|
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 74;
|
||||||
DEVELOPMENT_TEAM = VL68C36HYS;
|
DEVELOPMENT_TEAM = VL68C36HYS;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@@ -556,10 +557,11 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.50;
|
MARKETING_VERSION = 1.2.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
||||||
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -576,7 +578,7 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
|
CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 74;
|
||||||
DEVELOPMENT_TEAM = VL68C36HYS;
|
DEVELOPMENT_TEAM = VL68C36HYS;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@@ -594,10 +596,11 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.50;
|
MARKETING_VERSION = 1.2.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
PRODUCT_BUNDLE_IDENTIFIER = com.eatvioapp.app;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
PROVISIONING_PROFILE_SPECIFIER = "match AppStore com.eatvioapp.app 1747050044";
|
||||||
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
</Testables>
|
</Testables>
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Release"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
|
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>eatvio_app</string>
|
<string>Итвио</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>39</string>
|
<string>74</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
|||||||
@@ -18,9 +18,69 @@ default_platform(:ios)
|
|||||||
platform :ios do
|
platform :ios do
|
||||||
desc "Push a new beta build to TestFlight"
|
desc "Push a new beta build to TestFlight"
|
||||||
lane :beta do
|
lane :beta do
|
||||||
match(type: "appstore")
|
UI.message "Current working directory: #{Dir.pwd}"
|
||||||
|
UI.message "Checking API key file..."
|
||||||
|
|
||||||
|
possible_paths = [
|
||||||
|
"../AuthKey.p8",
|
||||||
|
"./AuthKey.p8",
|
||||||
|
"../../AuthKey.p8",
|
||||||
|
File.expand_path("../AuthKey.p8"),
|
||||||
|
File.expand_path("./AuthKey.p8")
|
||||||
|
]
|
||||||
|
|
||||||
|
auth_key_path = nil
|
||||||
|
possible_paths.each do |path|
|
||||||
|
if File.exist?(path)
|
||||||
|
UI.message "Found AuthKey.p8 at: #{path}"
|
||||||
|
auth_key_path = File.expand_path(path)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if auth_key_path.nil?
|
||||||
|
UI.user_error!("API key file not found. Tried paths: #{possible_paths.join(', ')}")
|
||||||
|
end
|
||||||
|
|
||||||
|
UI.message "Using auth_key_path: #{auth_key_path}"
|
||||||
|
|
||||||
|
# Configure Flutter for release mode
|
||||||
|
UI.message "Configuring Flutter for release mode..."
|
||||||
|
sh("cd .. && flutter build ios --config-only --release")
|
||||||
|
|
||||||
|
match(type: "appstore", readonly: true)
|
||||||
increment_build_number(xcodeproj: "Runner.xcodeproj")
|
increment_build_number(xcodeproj: "Runner.xcodeproj")
|
||||||
build_app(workspace: "Runner.xcworkspace", scheme: "Runner", export_method: "app-store", codesigning_identity: "Apple Distribution")
|
|
||||||
upload_to_testflight
|
build_app(
|
||||||
|
workspace: "Runner.xcworkspace",
|
||||||
|
scheme: "Runner",
|
||||||
|
export_method: "app-store",
|
||||||
|
codesigning_identity: "Apple Distribution",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app_store_connect_api_key(
|
||||||
|
key_id: "325JS9JCZH",
|
||||||
|
issuer_id: "dfa27d1d-2bb8-4d4d-847e-0b32f9b880b3",
|
||||||
|
key_filepath: auth_key_path,
|
||||||
|
duration: 1200,
|
||||||
|
in_house: false
|
||||||
|
)
|
||||||
|
|
||||||
|
begin
|
||||||
|
upload_to_testflight(
|
||||||
|
skip_waiting_for_build_processing: true,
|
||||||
|
skip_submission: true,
|
||||||
|
distribute_external: false,
|
||||||
|
notify_external_testers: false,
|
||||||
|
changelog: "TestFlight build #{get_build_number(xcodeproj: 'Runner.xcodeproj')}",
|
||||||
|
verbose: true
|
||||||
|
)
|
||||||
|
rescue => ex
|
||||||
|
UI.error "Upload to TestFlight failed: #{ex.message}"
|
||||||
|
UI.error "Full error: #{ex.backtrace.join("\n")}"
|
||||||
|
raise ex
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,22 +5,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000206">
|
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000227">
|
||||||
|
|
||||||
</testcase>
|
</testcase>
|
||||||
|
|
||||||
|
|
||||||
<testcase classname="fastlane.lanes" name="1: increment_build_number" time="0.195115">
|
<testcase classname="fastlane.lanes" name="1: match" time="8.292217">
|
||||||
|
|
||||||
</testcase>
|
</testcase>
|
||||||
|
|
||||||
|
|
||||||
<testcase classname="fastlane.lanes" name="2: build_app" time="116.686863">
|
<testcase classname="fastlane.lanes" name="2: increment_build_number" time="0.201631">
|
||||||
|
|
||||||
</testcase>
|
</testcase>
|
||||||
|
|
||||||
|
|
||||||
<testcase classname="fastlane.lanes" name="3: upload_to_testflight" time="338.642203">
|
<testcase classname="fastlane.lanes" name="3: build_app" time="9.870647">
|
||||||
|
|
||||||
|
<failure message="/opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/actions/actions_helper.rb:67:in 'Fastlane::Actions.execute_action' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/runner.rb:255:in 'block in Fastlane::Runner#execute_action' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/runner.rb:229:in 'Dir.chdir' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/runner.rb:229:in 'Fastlane::Runner#execute_action' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/runner.rb:157:in 'Fastlane::Runner#trigger_action_by_name' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/fast_file.rb:159:in 'Fastlane::FastFile#method_missing' Fastfile:23:in 'block (2 levels) in Fastlane::FastFile#parsing_binding' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/lane.rb:41:in 'Fastlane::Lane#call' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/runner.rb:49:in 'block in Fastlane::Runner#execute' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/runner.rb:45:in 'Dir.chdir' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/runner.rb:45:in 'Fastlane::Runner#execute' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/lane_manager.rb:46:in 'Fastlane::LaneManager.cruise_lane' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/command_line_handler.rb:34:in 'Fastlane::CommandLineHandler.handle' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/commands_generator.rb:110:in 'block (2 levels) in Fastlane::CommandsGenerator#run' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/commander-4.6.0/lib/commander/command.rb:187:in 'Commander::Command#call' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/commander-4.6.0/lib/commander/command.rb:157:in 'Commander::Command#run' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/commander-4.6.0/lib/commander/runner.rb:444:in 'Commander::Runner#run_active_command' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in 'Commander::Runner#run!' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/commander-4.6.0/lib/commander/delegates.rb:18:in 'Commander::Delegates#run!' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/commands_generator.rb:363:in 'Fastlane::CommandsGenerator#run' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/commands_generator.rb:43:in 'Fastlane::CommandsGenerator.start' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in 'Fastlane::CLIToolsDistributor.take_off' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/gems/fastlane-2.228.0/bin/fastlane:23:in '<top (required)>' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/bin/fastlane:25:in 'Kernel#load' /opt/homebrew/Cellar/fastlane/2.228.0/libexec/bin/fastlane:25:in '<main>' Error building the application - see the log above" />
|
||||||
|
|
||||||
</testcase>
|
</testcase>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import 'dart:io';
|
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:eatvio_app/core/const.dart';
|
import 'package:eatvio_app/core/const.dart';
|
||||||
import 'package:eatvio_app/core/firebase_api.dart';
|
import 'package:eatvio_app/core/firebase_api.dart';
|
||||||
@@ -26,6 +24,7 @@ import 'package:eatvio_app/features/consultations/presentation/pages/consultatio
|
|||||||
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultant_finances_screen.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultant_finances_screen.dart';
|
||||||
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/user_purchases_screen.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/user_purchases_screen.dart';
|
||||||
import 'package:eatvio_app/features/menu/presentation/pages/blocked_users_screen.dart';
|
import 'package:eatvio_app/features/menu/presentation/pages/blocked_users_screen.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/pages/notifications_settings_screen.dart';
|
||||||
import 'package:eatvio_app/features/order_info/presentation/info_by_order_screen.dart';
|
import 'package:eatvio_app/features/order_info/presentation/info_by_order_screen.dart';
|
||||||
import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart';
|
import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart';
|
||||||
import 'package:eatvio_app/features/create_diet/presentation/diet_preview_screen.dart';
|
import 'package:eatvio_app/features/create_diet/presentation/diet_preview_screen.dart';
|
||||||
@@ -113,21 +112,13 @@ class AppRouter {
|
|||||||
name: 'authScreen',
|
name: 'authScreen',
|
||||||
builder: (context, state) => const AuthScreen(),
|
builder: (context, state) => const AuthScreen(),
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
GoRoute(path: 'registration-screen', name: 'registrationScreen', builder: (context, state) => const RegistrationScreen()),
|
||||||
path: 'registration-screen',
|
|
||||||
name: 'registrationScreen',
|
|
||||||
builder: (context, state) => const RegistrationScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'forget-password-screen',
|
path: 'forget-password-screen',
|
||||||
name: 'forgetPasswordScreen',
|
name: 'forgetPasswordScreen',
|
||||||
builder: (context, state) => const ForgetPasswordScreen(),
|
builder: (context, state) => ForgetPasswordScreen(isAuth: state.extra as bool),
|
||||||
),
|
|
||||||
GoRoute(
|
|
||||||
path: 'scan-qr-code-screen',
|
|
||||||
name: 'scanQRCodeScreen',
|
|
||||||
builder: (context, state) => const ScanQRCodeScreen(),
|
|
||||||
),
|
),
|
||||||
|
GoRoute(path: 'scan-qr-code-screen', name: 'scanQRCodeScreen', builder: (context, state) => const ScanQRCodeScreen()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ShellRoute(
|
ShellRoute(
|
||||||
@@ -165,19 +156,23 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/diary-screen',
|
path: '/diary-screen',
|
||||||
name: 'diaryScreen',
|
name: 'diaryScreen',
|
||||||
pageBuilder: (context, state) => const NoTransitionPage(
|
pageBuilder: (context, state) => const NoTransitionPage(child: DiaryScreen()),
|
||||||
child: DiaryScreen(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: ConsultationsScreen.path,
|
path: ConsultationsScreen.path,
|
||||||
name: ConsultationsScreen.name,
|
name: ConsultationsScreen.name,
|
||||||
pageBuilder: (context, state) => const NoTransitionPage(child: ConsultationsScreen())),
|
pageBuilder: (context, state) => const NoTransitionPage(child: ConsultationsScreen()),
|
||||||
GoRoute(path: '/chat-select-screen', name: 'chatSelectScreen', pageBuilder: (context, state) => const NoTransitionPage(child: ChatsScreen())),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/notifications-screen',
|
path: '/chat-select-screen',
|
||||||
name: 'notificationsScreen',
|
name: 'chatSelectScreen',
|
||||||
pageBuilder: (context, state) => const NoTransitionPage(child: NotificationsScreen())),
|
pageBuilder: (context, state) => const NoTransitionPage(child: ChatsScreen()),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/notifications-screen',
|
||||||
|
name: 'notificationsScreen',
|
||||||
|
pageBuilder: (context, state) => const NoTransitionPage(child: NotificationsScreen()),
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/menu-screen',
|
path: '/menu-screen',
|
||||||
name: 'menuScreen',
|
name: 'menuScreen',
|
||||||
@@ -194,32 +189,16 @@ class AppRouter {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(name: 'blockedUsersScreen', path: '/blocked-users-screen', builder: (context, state) => const BlockedUsersScreen()),
|
||||||
name: 'blockedUsersScreen',
|
|
||||||
path: '/blocked-users-screen',
|
|
||||||
builder: (context, state) => const BlockedUsersScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/welcome-screen',
|
path: '/welcome-screen',
|
||||||
name: 'welcomeScreen',
|
name: 'welcomeScreen',
|
||||||
builder: (context, state) => const WelcomeScreen(),
|
builder: (context, state) => const WelcomeScreen(),
|
||||||
redirect: (context, state) async {
|
redirect: (context, state) async {
|
||||||
try {
|
try {
|
||||||
if (await TokenStorage.haveTokenInStorage()) {
|
|
||||||
final firebaseApi = sl<FirebaseApi>();
|
|
||||||
final fbToken = await firebaseApi.getToken();
|
|
||||||
final deviceInfo = DeviceInfoPlugin();
|
|
||||||
await sl<Dio>().post(
|
|
||||||
'/api/profile/notification/token/register',
|
|
||||||
data: {
|
|
||||||
'platform': Platform.isIOS ? 'ios' : 'android',
|
|
||||||
'hw_id': Platform.isIOS ? (await deviceInfo.iosInfo).identifierForVendor : (await deviceInfo.androidInfo).id,
|
|
||||||
'token': fbToken,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final sharedPreferences = await SharedPreferences.getInstance();
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
final welcomeScreenWasShowed = sharedPreferences.getBool('welcomeScreenWasShowed') ?? false;
|
final welcomeScreenWasShowed = sharedPreferences.getBool('welcomeScreenWasShowed') ?? false;
|
||||||
|
await sl<FirebaseApi>().registerPushToken();
|
||||||
if (welcomeScreenWasShowed == false) {
|
if (welcomeScreenWasShowed == false) {
|
||||||
return null;
|
return null;
|
||||||
} else if (await TokenStorage.haveTokenInStorage()) {
|
} else if (await TokenStorage.haveTokenInStorage()) {
|
||||||
@@ -228,7 +207,7 @@ class AppRouter {
|
|||||||
return '/auth-screen';
|
return '/auth-screen';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rethrow;
|
return '/feed-screen';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -253,26 +232,10 @@ class AppRouter {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(path: ConsultationsArchiveScreen.path, name: ConsultationsArchiveScreen.name, builder: (context, state) => const ConsultationsArchiveScreen()),
|
||||||
path: ConsultationsArchiveScreen.path,
|
GoRoute(path: ConsultantFinancesScreen.path, name: ConsultantFinancesScreen.name, builder: (context, state) => const ConsultantFinancesScreen()),
|
||||||
name: ConsultationsArchiveScreen.name,
|
GoRoute(path: UserPurchasesScreen.path, name: UserPurchasesScreen.name, builder: (context, state) => const UserPurchasesScreen()),
|
||||||
builder: (context, state) => const ConsultationsArchiveScreen(),
|
GoRoute(path: '/user-finance-screen', name: 'userFinanceScreen', builder: (context, state) => const UserFinanceScreen()),
|
||||||
),
|
|
||||||
GoRoute(
|
|
||||||
path: ConsultantFinancesScreen.path,
|
|
||||||
name: ConsultantFinancesScreen.name,
|
|
||||||
builder: (context, state) => const ConsultantFinancesScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
|
||||||
path: UserPurchasesScreen.path,
|
|
||||||
name: UserPurchasesScreen.name,
|
|
||||||
builder: (context, state) => const UserPurchasesScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
|
||||||
path: '/user-finance-screen',
|
|
||||||
name: 'userFinanceScreen',
|
|
||||||
builder: (context, state) => const UserFinanceScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: CardSettingsScreen.path,
|
path: CardSettingsScreen.path,
|
||||||
name: CardSettingsScreen.name,
|
name: CardSettingsScreen.name,
|
||||||
@@ -287,47 +250,37 @@ class AppRouter {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final slug = state.uri.queryParameters['slug'];
|
final slug = state.uri.queryParameters['slug'];
|
||||||
if (slug != null) {
|
if (slug != null) {
|
||||||
return AboutPlanScreen(
|
return AboutPlanScreen(slug: slug, navigateToComments: false, index: null);
|
||||||
slug: slug,
|
|
||||||
navigateToComments: false,
|
|
||||||
index: null,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final data = state.extra as Map<String, dynamic>;
|
final data = state.extra as Map<String, dynamic>;
|
||||||
return AboutPlanScreen(slug: data['slug'] as String, index: data['index'] as int?, navigateToComments: data['navigateToComments'] as bool);
|
return AboutPlanScreen(slug: data['slug'] as String, index: data['index'] as int?, navigateToComments: data['navigateToComments'] as bool);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(path: '/glossary-screen', name: 'glossaryScreen', builder: (context, state) => const GlossaryScreen()),
|
GoRoute(path: '/glossary-screen', name: 'glossaryScreen', builder: (context, state) => GlossaryScreen(passKey: state.extra as String,)),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/about-recipes-screen',
|
path: '/about-recipes-screen',
|
||||||
name: 'aboutRecipesScreen',
|
name: 'aboutRecipesScreen',
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final slug = state.uri.queryParameters['slug'];
|
final slug = state.uri.queryParameters['slug'];
|
||||||
if (slug != null) {
|
if (slug != null) {
|
||||||
return AboutRecipeScreen(
|
return AboutRecipeScreen(recipeSlug: slug, navigateToComments: false, index: null);
|
||||||
recipeSlug: slug,
|
|
||||||
navigateToComments: false,
|
|
||||||
index: null,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final data = state.extra as Map<String, dynamic>;
|
final data = state.extra as Map<String, dynamic>;
|
||||||
return AboutRecipeScreen(
|
return AboutRecipeScreen(recipeSlug: data['recipe'] as String, index: data['index'] as int?, navigateToComments: data['navigateToComments'] as bool);
|
||||||
recipeSlug: data['recipe'] as String,
|
|
||||||
index: data['index'] as int?,
|
|
||||||
navigateToComments: data['navigateToComments'] as bool,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: RecipeCreateScreen.path,
|
path: RecipeCreateScreen.path,
|
||||||
name: RecipeCreateScreen.name,
|
name: RecipeCreateScreen.name,
|
||||||
builder: (context, state) => RecipeCreateScreen(
|
builder: (context, state) => RecipeCreateScreen(recipe: state.extra != null ? state.extra as Recipe : null),
|
||||||
recipe: state.extra != null ? state.extra as Recipe : null,
|
),
|
||||||
),
|
GoRoute(
|
||||||
|
path: '/profile-screen',
|
||||||
|
name: 'profileScreen',
|
||||||
|
builder: (context, state) => ProfileScreen(author: state.extra as Author),
|
||||||
),
|
),
|
||||||
GoRoute(path: '/profile-screen', name: 'profileScreen', builder: (context, state) => ProfileScreen(author: state.extra as Author)),
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/subs-screen/:slug',
|
path: '/subs-screen/:slug',
|
||||||
name: 'subsScreen',
|
name: 'subsScreen',
|
||||||
@@ -339,11 +292,7 @@ class AppRouter {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final slug = state.uri.queryParameters['slug'];
|
final slug = state.uri.queryParameters['slug'];
|
||||||
if (slug != null) {
|
if (slug != null) {
|
||||||
return AboutDietScreen(
|
return AboutDietScreen(slug: slug, index: null, navigateToComments: false);
|
||||||
slug: slug,
|
|
||||||
index: null,
|
|
||||||
navigateToComments: false,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
final data = state.extra as Map<String, dynamic>;
|
final data = state.extra as Map<String, dynamic>;
|
||||||
return AboutDietScreen(slug: data['slug'] as String, index: data['index'] as int?, navigateToComments: data['navigateToComments'] as bool);
|
return AboutDietScreen(slug: data['slug'] as String, index: data['index'] as int?, navigateToComments: data['navigateToComments'] as bool);
|
||||||
@@ -355,30 +304,26 @@ class AppRouter {
|
|||||||
builder: (context, state) => BlogPostCreateScreen(feedBlogPostModel: state.extra != null ? state.extra as FeedBlogPostModel : null),
|
builder: (context, state) => BlogPostCreateScreen(feedBlogPostModel: state.extra != null ? state.extra as FeedBlogPostModel : null),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/blog-post-screen',
|
path: '/blog-post-screen',
|
||||||
name: 'blogPostScreen',
|
name: 'blogPostScreen',
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final id = state.uri.queryParameters['id'];
|
final id = state.uri.queryParameters['id'];
|
||||||
final parsedId = int.tryParse(id ?? '');
|
final parsedId = int.tryParse(id ?? '');
|
||||||
if (parsedId != null) {
|
if (parsedId != null) {
|
||||||
return BlogPostScreen(
|
return BlogPostScreen(id: parsedId);
|
||||||
id: parsedId,
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return BlogPostScreen(id: state.extra as int);
|
return BlogPostScreen(id: state.extra as int);
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/chat-screen',
|
path: '/chat-screen',
|
||||||
name: 'chatScreen',
|
name: 'chatScreen',
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final data = state.extra as Map<String, dynamic>;
|
final data = state.extra as Map<String, dynamic>;
|
||||||
final chatId = data['chatId'] as String;
|
final uuid = data['uuid'] as String;
|
||||||
final sendInitialMessage = data['sendInitialMessage'] as bool?;
|
final sendInitialMessage = data['sendInitialMessage'] as bool?;
|
||||||
return ChatScreen(
|
return ChatScreen(uuid: uuid, sendInitialMessage: sendInitialMessage);
|
||||||
chatId: chatId,
|
|
||||||
sendInitialMessage: sendInitialMessage,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
@@ -411,7 +356,11 @@ class AppRouter {
|
|||||||
name: 'physicalFormScreen',
|
name: 'physicalFormScreen',
|
||||||
builder: (context, state) => PhysicalFormScreen(settingsEntity: state.extra as SettingsEntity),
|
builder: (context, state) => PhysicalFormScreen(settingsEntity: state.extra as SettingsEntity),
|
||||||
),
|
),
|
||||||
GoRoute(path: 'pressure-screen', name: 'pressureScreen', builder: (context, state) => PressureScreen(settingsEntity: state.extra as SettingsEntity)),
|
GoRoute(
|
||||||
|
path: 'pressure-screen',
|
||||||
|
name: 'pressureScreen',
|
||||||
|
builder: (context, state) => PressureScreen(settingsEntity: state.extra as SettingsEntity),
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'change-password-screen',
|
path: 'change-password-screen',
|
||||||
name: 'changePasswordScreen',
|
name: 'changePasswordScreen',
|
||||||
@@ -428,9 +377,7 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/stepper-become-consultant-screen',
|
path: '/stepper-become-consultant-screen',
|
||||||
name: 'stepperBecomeConsultantScreen',
|
name: 'stepperBecomeConsultantScreen',
|
||||||
builder: (context, state) => StepperBecomeConsultantScreen(
|
builder: (context, state) => StepperBecomeConsultantScreen(slug: state.extra == null ? null : state.extra as String),
|
||||||
slug: state.extra == null ? null : state.extra as String,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
GoRoute(path: '/calendar-screen', name: 'calendarScreen', builder: (context, state) => const CalendarScreen()),
|
GoRoute(path: '/calendar-screen', name: 'calendarScreen', builder: (context, state) => const CalendarScreen()),
|
||||||
GoRoute(path: '/support-screen', name: 'supportScreen', builder: (context, state) => const SupportScreen()),
|
GoRoute(path: '/support-screen', name: 'supportScreen', builder: (context, state) => const SupportScreen()),
|
||||||
@@ -458,7 +405,11 @@ class AppRouter {
|
|||||||
GoRoute(path: CreatePlanScreen.path, name: CreatePlanScreen.name, builder: (context, state) => const CreatePlanScreen()),
|
GoRoute(path: CreatePlanScreen.path, name: CreatePlanScreen.name, builder: (context, state) => const CreatePlanScreen()),
|
||||||
GoRoute(path: MyDietsScreen.path, name: MyDietsScreen.name, builder: (context, state) => const MyDietsScreen()),
|
GoRoute(path: MyDietsScreen.path, name: MyDietsScreen.name, builder: (context, state) => const MyDietsScreen()),
|
||||||
GoRoute(path: MyPlansScreen.path, name: MyPlansScreen.name, builder: (context, state) => const MyPlansScreen()),
|
GoRoute(path: MyPlansScreen.path, name: MyPlansScreen.name, builder: (context, state) => const MyPlansScreen()),
|
||||||
GoRoute(path: UserDetailsScreen.path, name: UserDetailsScreen.name, builder: (context, state) => UserDetailsScreen(slug: state.extra as String)),
|
GoRoute(
|
||||||
|
path: UserDetailsScreen.path,
|
||||||
|
name: UserDetailsScreen.name,
|
||||||
|
builder: (context, state) => UserDetailsScreen(slug: state.extra as String),
|
||||||
|
),
|
||||||
GoRoute(path: DevToolsScreen.path, name: DevToolsScreen.name, builder: (context, state) => const DevToolsScreen()),
|
GoRoute(path: DevToolsScreen.path, name: DevToolsScreen.name, builder: (context, state) => const DevToolsScreen()),
|
||||||
GoRoute(path: ConsultantRatingScreen.path, name: ConsultantRatingScreen.name, builder: (context, state) => const ConsultantRatingScreen()),
|
GoRoute(path: ConsultantRatingScreen.path, name: ConsultantRatingScreen.name, builder: (context, state) => const ConsultantRatingScreen()),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
@@ -468,10 +419,7 @@ class AppRouter {
|
|||||||
final data = state.extra as Map<String, dynamic>;
|
final data = state.extra as Map<String, dynamic>;
|
||||||
final planId = data['planId'] as int;
|
final planId = data['planId'] as int;
|
||||||
final successfulPayment = data['successfulPayment'] as bool?;
|
final successfulPayment = data['successfulPayment'] as bool?;
|
||||||
return InfoByOrderScreen(
|
return InfoByOrderScreen(planId: planId, successfulPayment: successfulPayment);
|
||||||
planId: planId,
|
|
||||||
successfulPayment: successfulPayment,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
@@ -481,10 +429,7 @@ class AppRouter {
|
|||||||
final data = state.extra as Map<String, dynamic>;
|
final data = state.extra as Map<String, dynamic>;
|
||||||
final planId = data['planId'] as int;
|
final planId = data['planId'] as int;
|
||||||
final url = data['url'] as String;
|
final url = data['url'] as String;
|
||||||
return PaymentScreen(
|
return PaymentScreen(url: url, planId: planId);
|
||||||
url: url,
|
|
||||||
planId: planId,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
@@ -494,10 +439,7 @@ class AppRouter {
|
|||||||
final data = state.extra as Map<String, int>;
|
final data = state.extra as Map<String, int>;
|
||||||
final diaryId = data['diaryId'] as int;
|
final diaryId = data['diaryId'] as int;
|
||||||
final currentPlanDay = data['currentDiaryDay'] as int;
|
final currentPlanDay = data['currentDiaryDay'] as int;
|
||||||
return UserDiaryScreen(
|
return UserDiaryScreen(diaryId: diaryId, currentPlanDay: currentPlanDay);
|
||||||
diaryId: diaryId,
|
|
||||||
currentPlanDay: currentPlanDay,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
@@ -505,16 +447,9 @@ class AppRouter {
|
|||||||
name: 'verifyScreen',
|
name: 'verifyScreen',
|
||||||
builder: (context, state) => VerifyScreen(passKey: state.extra as String),
|
builder: (context, state) => VerifyScreen(passKey: state.extra as String),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(path: '/verify-email-screen', name: 'verifyEmailScreen', builder: (context, state) => const VerifyEmailScreen()),
|
||||||
path: '/verify-email-screen',
|
GoRoute(path: MyRecipesScreen.path, name: MyRecipesScreen.name, builder: (context, state) => const MyRecipesScreen()),
|
||||||
name: 'verifyEmailScreen',
|
GoRoute(path: '/notifications-settings-screen', name: 'notificationsSettingsScreen', builder: (context, state) => const NotificationsSettingsScreen()),
|
||||||
builder: (context, state) => const VerifyEmailScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
|
||||||
path: MyRecipesScreen.path,
|
|
||||||
name: MyRecipesScreen.name,
|
|
||||||
builder: (context, state) => const MyRecipesScreen(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_state.dart';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:eatvio_app/core/comments/comments_cubit/comments_state.dart';
|
||||||
|
import 'package:eatvio_app/core/comments/repositories/comments_repository.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart';
|
import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart';
|
||||||
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class CommentsCubit extends Cubit<CommentsState> {
|
class CommentsCubit extends Cubit<CommentsState> {
|
||||||
final FeedRepository feedRepository;
|
final FeedRepository feedRepository;
|
||||||
|
final CommentsRepository commentsRepository;
|
||||||
|
|
||||||
CommentsCubit({
|
CommentsCubit({
|
||||||
required this.feedRepository,
|
required this.feedRepository,
|
||||||
|
required this.commentsRepository,
|
||||||
}) : super(const CommentsState());
|
}) : super(const CommentsState());
|
||||||
|
|
||||||
void setReplyId(int? replyId) {
|
void setReplyId(int? replyId) {
|
||||||
emit((state as CommentsStateLoaded).copyWith(replyId: replyId));
|
emit((state as CommentsStateLoaded).copyWith(replyId: replyId));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getComments(String id, CommentSourceType commentSourceType, [bool isFirstFetch = false]) async {
|
Future<void> getComments(String id, CommentSourceType commentSourceType, [bool isFirstFetch = false]) async {
|
||||||
if (isFirstFetch) emit(const CommentsState.loading());
|
if (isFirstFetch) emit(const CommentsState.loading());
|
||||||
try {
|
try {
|
||||||
switch (commentSourceType) {
|
switch (commentSourceType) {
|
||||||
@@ -27,7 +32,7 @@ class CommentsCubit extends Cubit<CommentsState> {
|
|||||||
case CommentSourceType.recipe:
|
case CommentSourceType.recipe:
|
||||||
emit(CommentsState.loaded(comment: await feedRepository.getRecipesComments(id: id)));
|
emit(CommentsState.loaded(comment: await feedRepository.getRecipesComments(id: id)));
|
||||||
break;
|
break;
|
||||||
case CommentSourceType.plan:
|
case CommentSourceType.plan:
|
||||||
emit(CommentsState.loaded(comment: await feedRepository.getPlansComments(slug: id)));
|
emit(CommentsState.loaded(comment: await feedRepository.getPlansComments(slug: id)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -78,4 +83,34 @@ class CommentsCubit extends Cubit<CommentsState> {
|
|||||||
emit(CommentsState.error(errorMessage: e.toString()));
|
emit(CommentsState.error(errorMessage: e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> deleteComment({required int id}) async {
|
||||||
|
if (state is! CommentsStateLoaded) return false;
|
||||||
|
final commentModel = (state as CommentsStateLoaded).comment;
|
||||||
|
final updatedCommentModel = commentModel.copyWith(data: commentModel.data.where((comment) => comment.id != id).toList());
|
||||||
|
try {
|
||||||
|
await commentsRepository.deleteComment(id: id);
|
||||||
|
emit(CommentsState.loaded(comment: updatedCommentModel));
|
||||||
|
return true;
|
||||||
|
} catch (e, st) {
|
||||||
|
emit(CommentsState.loaded(comment: commentModel));
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> updateComment({required int id, required String body}) async {
|
||||||
|
final commentModel = (state as CommentsStateLoaded).comment;
|
||||||
|
final updatedCommentModel =
|
||||||
|
commentModel.copyWith(data: commentModel.data.map((comment) => comment.id == id ? comment.copyWith(body: body) : comment).toList());
|
||||||
|
try {
|
||||||
|
await commentsRepository.updateComment(id: id, body: body);
|
||||||
|
emit(CommentsState.loaded(comment: updatedCommentModel));
|
||||||
|
return true;
|
||||||
|
} catch (e, st) {
|
||||||
|
emit(CommentsState.loaded(comment: commentModel));
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ abstract class CommentsState with _$CommentsState {
|
|||||||
const factory CommentsState.loaded({
|
const factory CommentsState.loaded({
|
||||||
required CommentModel comment,
|
required CommentModel comment,
|
||||||
int? replyId,
|
int? replyId,
|
||||||
|
int? editedCommentId,
|
||||||
}) = CommentsStateLoaded;
|
}) = CommentsStateLoaded;
|
||||||
|
|
||||||
const factory CommentsState.error({
|
const factory CommentsState.error({
|
||||||
12
lib/core/comments/models/comment_update_model.dart
Normal file
12
lib/core/comments/models/comment_update_model.dart
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'comment_update_model.freezed.dart';
|
||||||
|
part 'comment_update_model.g.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class CommentUpdateModel with _$CommentUpdateModel {
|
||||||
|
|
||||||
|
factory CommentUpdateModel({required String body}) = _CommentUpdateModel;
|
||||||
|
|
||||||
|
factory CommentUpdateModel.fromJson(Map<String, dynamic> json) => _$CommentUpdateModelFromJson(json);
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/bottom_sheet_action_widget.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/custom_divider.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
|
||||||
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
|
void showCommentsActionsBottomSheet(
|
||||||
|
BuildContext context, {
|
||||||
|
required void Function()? reply,
|
||||||
|
required void Function() copy,
|
||||||
|
required void Function(String text) edit,
|
||||||
|
required void Function() delete,
|
||||||
|
required void Function() complain,
|
||||||
|
required String commentText,
|
||||||
|
required bool isMyComment,
|
||||||
|
}) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
builder: (context) => Container(
|
||||||
|
margin: EdgeInsets.only(left: 8, right: 8, bottom: MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).padding.bottom + 20),
|
||||||
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: appTheme.whiteA700),
|
||||||
|
child: CommentsActionsBottomSheet(
|
||||||
|
isMyComment: isMyComment,
|
||||||
|
reply: reply,
|
||||||
|
copy: copy,
|
||||||
|
edit: edit,
|
||||||
|
delete: delete,
|
||||||
|
complain: complain,
|
||||||
|
commentText: commentText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CommentsActionsBottomSheet extends StatefulWidget {
|
||||||
|
const CommentsActionsBottomSheet({
|
||||||
|
super.key,
|
||||||
|
required this.isMyComment,
|
||||||
|
required this.reply,
|
||||||
|
required this.copy,
|
||||||
|
required this.edit,
|
||||||
|
required this.delete,
|
||||||
|
required this.complain,
|
||||||
|
required this.commentText,
|
||||||
|
});
|
||||||
|
final bool isMyComment;
|
||||||
|
final void Function()? reply;
|
||||||
|
final void Function() copy;
|
||||||
|
final void Function(String text) edit;
|
||||||
|
final void Function() delete;
|
||||||
|
final void Function() complain;
|
||||||
|
final String commentText;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CommentsActionsBottomSheet> createState() => _CommentsActionsBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CommentsActionsBottomSheetState extends State<CommentsActionsBottomSheet> {
|
||||||
|
bool isUserEditingComment = false;
|
||||||
|
final controller = TextEditingController();
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
controller.text = widget.commentText;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = S.of(context);
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: isUserEditingComment
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: CustomTextFormField(autofocus: true, controller: controller, onChanged: (value) => setState(() {})),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.edit(controller.text);
|
||||||
|
GoRouter.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(color: controller.text.length > 2 ? appTheme.blueA400 : appTheme.gray50, shape: BoxShape.circle),
|
||||||
|
height: 32,
|
||||||
|
width: 32,
|
||||||
|
child: Icon(Icons.send_rounded, size: 18, color: controller.text.length > 2 ? appTheme.whiteA700 : appTheme.black),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 7),
|
||||||
|
const BottomSheetHandlerBar(),
|
||||||
|
if (widget.isMyComment)
|
||||||
|
BottomSheetActionWidget(
|
||||||
|
text: s.edit,
|
||||||
|
iconPath: 'assets/icons/edit_paint.svg',
|
||||||
|
needToPop: false,
|
||||||
|
onTap: () => setState(() {
|
||||||
|
isUserEditingComment = true;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
else if (widget.reply != null)
|
||||||
|
BottomSheetActionWidget(text: s.reply, iconPath: 'assets/icons/reply.svg', onTap: widget.reply!),
|
||||||
|
if (widget.reply != null) const CustomDivider(),
|
||||||
|
BottomSheetActionWidget(text: s.copy, iconPath: 'assets/icons/copy2.svg', onTap: widget.copy),
|
||||||
|
if (widget.isMyComment) ...[
|
||||||
|
if (widget.reply != null) ...[
|
||||||
|
const CustomDivider(),
|
||||||
|
BottomSheetActionWidget(text: s.reply, iconPath: 'assets/icons/reply.svg', onTap: widget.reply!),
|
||||||
|
],
|
||||||
|
const CustomDivider(),
|
||||||
|
BottomSheetActionWidget(text: s.deleteComment, iconPath: 'assets/icons/red_trash.svg', onTap: widget.delete),
|
||||||
|
] else ...[
|
||||||
|
const CustomDivider(),
|
||||||
|
BottomSheetActionWidget(text: s.complain, iconPath: 'assets/icons/complain.svg', onTap: widget.complain),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
lib/core/comments/repositories/comments_repository.dart
Normal file
24
lib/core/comments/repositories/comments_repository.dart
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import 'package:eatvio_app/core/comments/models/comment_update_model.dart';
|
||||||
|
import 'package:eatvio_app/core/comments/services/comments_service.dart';
|
||||||
|
|
||||||
|
class CommentsRepository {
|
||||||
|
final CommentsService service;
|
||||||
|
|
||||||
|
CommentsRepository({required this.service});
|
||||||
|
|
||||||
|
Future<void> deleteComment({required int id}) async {
|
||||||
|
try {
|
||||||
|
return service.deleteComment(id);
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateComment({required int id, required String body}) async {
|
||||||
|
try {
|
||||||
|
return service.updateComment(id, CommentUpdateModel(body: body));
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
lib/core/comments/services/comments_service.dart
Normal file
16
lib/core/comments/services/comments_service.dart
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:eatvio_app/core/comments/models/comment_update_model.dart';
|
||||||
|
import 'package:retrofit/retrofit.dart';
|
||||||
|
|
||||||
|
part 'comments_service.g.dart';
|
||||||
|
|
||||||
|
@RestApi()
|
||||||
|
abstract class CommentsService {
|
||||||
|
factory CommentsService(Dio dio, {String baseUrl}) = _CommentsService;
|
||||||
|
|
||||||
|
@DELETE('/api/comments/{id}')
|
||||||
|
Future<void> deleteComment(@Path('id') int id);
|
||||||
|
|
||||||
|
@PATCH('/api/comments/{id}')
|
||||||
|
Future<void> updateComment(@Path('id') int id, @Body() CommentUpdateModel body);
|
||||||
|
}
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
String baseUrl = 'https://eatvio.ru';
|
import 'package:eatvio_app/core/env_config.dart';
|
||||||
|
|
||||||
|
String baseUrl = EnvConfig.baseUrl;
|
||||||
|
bool hidePlans = const bool.fromEnvironment('HIDE_PLANS', defaultValue: false);
|
||||||
|
const buildDate = String.fromEnvironment('BUILD_DATE', defaultValue: '');
|
||||||
|
|
||||||
const List<int> durationValues = [7, 14, 21];
|
const List<int> durationValues = [7, 14, 21];
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
|
|
||||||
abstract class CredentialsStorage {
|
|
||||||
static Future<bool> haveCredentialsInStorage() async {
|
|
||||||
try {
|
|
||||||
if (await const FlutterSecureStorage().read(key: 'email') == null || await const FlutterSecureStorage().read(key: 'password') == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<Map<String, String>> getCredentialsFromStorage() async {
|
|
||||||
return {
|
|
||||||
'email': (await const FlutterSecureStorage().read(key: 'email'))!,
|
|
||||||
'password': (await const FlutterSecureStorage().read(key: 'password'))!,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<void> saveCredentials(String email, String password) async {
|
|
||||||
await const FlutterSecureStorage().write(key: 'email', value: email);
|
|
||||||
await const FlutterSecureStorage().write(key: 'password', value: password);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<void> removeCredentials() async {
|
|
||||||
await const FlutterSecureStorage().delete(key: 'email');
|
|
||||||
await const FlutterSecureStorage().delete(key: 'password');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,8 +12,8 @@ class PhoneVerifyErrorInterceptor extends Interceptor {
|
|||||||
final data = err.response?.data;
|
final data = err.response?.data;
|
||||||
|
|
||||||
if (data is Map<String, dynamic> && data['type'] == 'unverificated_phone') {
|
if (data is Map<String, dynamic> && data['type'] == 'unverificated_phone') {
|
||||||
final String phone = await sl<ProfileRepository>().getMyPhone();
|
final String phone = await sl<ProfileRepository>().getMyPhone();
|
||||||
final String passKey = await sl<ProfileRepository>().getPassKey(phone);
|
final String passKey = await sl<ProfileRepository>().getPassKey(routeName: 'user_detailz.change-phone-verify', routeParams: {"phone": phone});
|
||||||
await showErrorDialog(AppRouter.navigatorKey.currentContext!,
|
await showErrorDialog(AppRouter.navigatorKey.currentContext!,
|
||||||
title: 'Привяжите номер телефона', description: 'Для того, что бы выполнить это действие необходимо привязать номер телефона');
|
title: 'Привяжите номер телефона', description: 'Для того, что бы выполнить это действие необходимо привязать номер телефона');
|
||||||
AppRouter.navigatorKey.currentContext?.pushNamed('verifyScreen', extra: passKey);
|
AppRouter.navigatorKey.currentContext?.pushNamed('verifyScreen', extra: passKey);
|
||||||
|
|||||||
@@ -1,7 +1 @@
|
|||||||
enum ComplainedContent {
|
enum ComplainedContent { diet, plan, recipe, profile, posts, comment }
|
||||||
diet,
|
|
||||||
plan,
|
|
||||||
recipe,
|
|
||||||
profile,
|
|
||||||
posts
|
|
||||||
}
|
|
||||||
|
|||||||
46
lib/core/env_config.dart
Normal file
46
lib/core/env_config.dart
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
|
|
||||||
|
class EnvConfig {
|
||||||
|
static String get baseUrl => dotenv.env['BASE_URL'] ?? '';
|
||||||
|
static String get devBaseUrl => dotenv.env['DEV_BASE_URL'] ?? '';
|
||||||
|
|
||||||
|
// Sentry Configuration
|
||||||
|
static String get sentryDsn => dotenv.env['SENTRY_DSN'] ?? '';
|
||||||
|
|
||||||
|
// AppMetrica Configuration
|
||||||
|
static String get appMetricaApiKey => dotenv.env['APPMETRICA_KEY'] ?? '';
|
||||||
|
|
||||||
|
// Firebase Configuration
|
||||||
|
static String get firebaseProjectId => dotenv.env['FIREBASE_PROJECT_ID'] ?? '';
|
||||||
|
static String get firebaseDatabaseUrl => dotenv.env['FIREBASE_DATABASE_URL'] ?? '';
|
||||||
|
static String get firebaseStorageBucket => dotenv.env['FIREBASE_STORAGE_BUCKET'] ?? '';
|
||||||
|
static String get firebaseMessagingSenderId => dotenv.env['FIREBASE_MESSAGING_SENDER_ID'] ?? '';
|
||||||
|
|
||||||
|
// Firebase Android Configuration
|
||||||
|
static String get firebaseAndroidApiKey => dotenv.env['FIREBASE_ANDROID_API_KEY'] ?? '';
|
||||||
|
static String get firebaseAndroidAppId => dotenv.env['FIREBASE_ANDROID_APP_ID'] ?? '';
|
||||||
|
|
||||||
|
// Firebase iOS Configuration
|
||||||
|
static String get firebaseIosApiKey => dotenv.env['FIREBASE_IOS_API_KEY'] ?? '';
|
||||||
|
static String get firebaseIosAppId => dotenv.env['FIREBASE_IOS_APP_ID'] ?? '';
|
||||||
|
static String get firebaseIosBundleId => dotenv.env['FIREBASE_IOS_BUNDLE_ID'] ?? '';
|
||||||
|
|
||||||
|
// App Store URLs
|
||||||
|
static String get appStoreUrl => dotenv.env['APP_STORE_URL'] ?? '';
|
||||||
|
static String get rustoreUrl => dotenv.env['RUSTORE_URL'] ?? '';
|
||||||
|
|
||||||
|
// Telegram Support
|
||||||
|
static String get telegramSupportUrl => dotenv.env['TELEGRAM_SUPPORT_URL'] ?? '';
|
||||||
|
static String get supportEmail => dotenv.env['SUPPORT_EMAIL'] ?? '';
|
||||||
|
|
||||||
|
// Test Credentials (for development only)
|
||||||
|
static String get testEmail => dotenv.env['TEST_EMAIL'] ?? '';
|
||||||
|
static String get testPassword => dotenv.env['TEST_PASSWORD'] ?? '';
|
||||||
|
|
||||||
|
// Email Validation API
|
||||||
|
static String get emailValidationApiUrl => dotenv.env['EMAIL_VALIDATION_API_URL'] ?? '';
|
||||||
|
|
||||||
|
// Connection Check URLs
|
||||||
|
static String get googleCheckUrl => dotenv.env['GOOGLE_CHECK_URL'] ?? '';
|
||||||
|
static String get yandexCheckUrl => dotenv.env['YANDEX_CHECK_URL'] ?? '';
|
||||||
|
}
|
||||||
@@ -1,10 +1,74 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:eatvio_app/core/utils/toasts.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:eatvio_app/core/locator_service.dart';
|
||||||
|
import 'package:eatvio_app/core/token_storage.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
|
import 'package:flutter/services.dart' show MethodChannel, PlatformException;
|
||||||
|
|
||||||
class FirebaseApi {
|
class FirebaseApi {
|
||||||
final _firebaseMessaging = FirebaseMessaging.instance;
|
final _firebaseMessaging = FirebaseMessaging.instance;
|
||||||
|
|
||||||
Future<String?> getToken() async {
|
Future<String?> getToken() async {
|
||||||
await _firebaseMessaging.requestPermission();
|
String? token;
|
||||||
return await _firebaseMessaging.getToken();
|
|
||||||
|
if (await _isHuaweiDevice()) {
|
||||||
|
token = await _getHuaweiPushTokenNative();
|
||||||
|
} else {
|
||||||
|
await _firebaseMessaging.requestPermission();
|
||||||
|
token = await _firebaseMessaging.getToken();
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> registerPushToken() async {
|
||||||
|
if (await TokenStorage.haveTokenInStorage()) {
|
||||||
|
try {
|
||||||
|
final deviceInfo = DeviceInfoPlugin();
|
||||||
|
final isHuawei = Platform.isAndroid ? await _isHuaweiDevice() : false;
|
||||||
|
await sl<Dio>().post(
|
||||||
|
'/api/profile/notification/token/register',
|
||||||
|
data: {
|
||||||
|
'platform': Platform.isIOS ? 'ios' : (isHuawei ? 'huawei' : 'android'),
|
||||||
|
'hw_id': Platform.isIOS ? (await deviceInfo.iosInfo).identifierForVendor : (await deviceInfo.androidInfo).id,
|
||||||
|
'token': await getToken(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (e, st) {
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _isHuaweiDevice() async {
|
||||||
|
if (!Platform.isAndroid) return false;
|
||||||
|
try {
|
||||||
|
final info = await DeviceInfoPlugin().androidInfo;
|
||||||
|
final brand = info.brand.toLowerCase();
|
||||||
|
final manufacturer = info.manufacturer.toLowerCase();
|
||||||
|
return brand.contains('huawei') || brand.contains('honor') || manufacturer.contains('huawei') || manufacturer.contains('honor');
|
||||||
|
} catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> _getHuaweiPushTokenNative() async {
|
||||||
|
try {
|
||||||
|
const channel = MethodChannel('com.eatvioapp/hms_push');
|
||||||
|
final String? token = await channel.invokeMethod<String>('getHuaweiToken');
|
||||||
|
return token;
|
||||||
|
} on PlatformException catch (e, st) {
|
||||||
|
showErrorToast('$e $st');
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
return null;
|
||||||
|
} catch (e, st) {
|
||||||
|
showErrorToast('$e $st');
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:eatvio_app/core/comments/repositories/comments_repository.dart';
|
||||||
|
import 'package:eatvio_app/core/comments/services/comments_service.dart';
|
||||||
import 'package:eatvio_app/core/const.dart';
|
import 'package:eatvio_app/core/const.dart';
|
||||||
import 'package:eatvio_app/core/dio/phone_verify_error_interceptor.dart';
|
import 'package:eatvio_app/core/dio/phone_verify_error_interceptor.dart';
|
||||||
import 'package:eatvio_app/core/firebase_api.dart';
|
import 'package:eatvio_app/core/firebase_api.dart';
|
||||||
import 'package:eatvio_app/core/interceptors/token_interceptor.dart';
|
import 'package:eatvio_app/core/interceptors/token_interceptor.dart';
|
||||||
|
import 'package:eatvio_app/core/views/cubit/views_cubit.dart';
|
||||||
|
import 'package:eatvio_app/core/views/repository/views_repository.dart';
|
||||||
|
import 'package:eatvio_app/core/views/service/views_service.dart';
|
||||||
import 'package:eatvio_app/core/websockets/ws_manager.dart';
|
import 'package:eatvio_app/core/websockets/ws_manager.dart';
|
||||||
import 'package:eatvio_app/core/websockets/ws_service.dart';
|
import 'package:eatvio_app/core/websockets/ws_service.dart';
|
||||||
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_cubit.dart';
|
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_cubit.dart';
|
||||||
@@ -18,6 +23,9 @@ import 'package:eatvio_app/features/cancel_plan_bottom_sheet/service/cancel_plan
|
|||||||
import 'package:eatvio_app/features/complaining/presentation/cubit/complaining_cubit.dart';
|
import 'package:eatvio_app/features/complaining/presentation/cubit/complaining_cubit.dart';
|
||||||
import 'package:eatvio_app/features/complaining/repositories/complaining_repository.dart';
|
import 'package:eatvio_app/features/complaining/repositories/complaining_repository.dart';
|
||||||
import 'package:eatvio_app/features/complaining/services/complaining_service.dart';
|
import 'package:eatvio_app/features/complaining/services/complaining_service.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/presentation/cubit/consultant_rating_cubit.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/repositories/consultant_rating_repository.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/services/consultant_rating_service.dart';
|
||||||
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_cubit.dart';
|
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_cubit.dart';
|
||||||
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
||||||
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
|
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
|
||||||
@@ -37,9 +45,13 @@ import 'package:eatvio_app/features/blog_post_create/services/blog_post_service.
|
|||||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart';
|
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_cubit.dart';
|
||||||
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_cubit.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_cubit.dart';
|
||||||
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/user_purchases/user_purchases_cubit.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/user_purchases/user_purchases_cubit.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/bloc/menu_cubit/menu_cubit.dart';
|
||||||
import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_cubit.dart';
|
import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_cubit.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/bloc/notification_settings_cubit/notification_settings_cubit.dart';
|
||||||
import 'package:eatvio_app/features/menu/presentation/repositories/blocked_users_repository.dart';
|
import 'package:eatvio_app/features/menu/presentation/repositories/blocked_users_repository.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/repositories/notification_settings_repository.dart';
|
||||||
import 'package:eatvio_app/features/menu/services/blocked_users_service.dart';
|
import 'package:eatvio_app/features/menu/services/blocked_users_service.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/services/notification_settings_service.dart';
|
||||||
import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_cubit.dart';
|
import 'package:eatvio_app/features/notifications/presentation/notifications_cubit/notifications_cubit.dart';
|
||||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart';
|
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart';
|
||||||
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart';
|
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_cubit.dart';
|
||||||
@@ -56,7 +68,7 @@ import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
|||||||
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
|
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
|
||||||
import 'package:eatvio_app/features/diary/services/diary_service.dart';
|
import 'package:eatvio_app/features/diary/services/diary_service.dart';
|
||||||
import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_cubit.dart';
|
import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_cubit.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart';
|
import 'package:eatvio_app/core/comments/comments_cubit/comments_cubit.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart';
|
import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart';
|
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
|
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
|
||||||
@@ -105,7 +117,6 @@ import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/se
|
|||||||
import 'package:eatvio_app/features/settings/repositories/service_repository.dart';
|
import 'package:eatvio_app/features/settings/repositories/service_repository.dart';
|
||||||
import 'package:eatvio_app/features/settings/services/settings_service.dart';
|
import 'package:eatvio_app/features/settings/services/settings_service.dart';
|
||||||
import 'package:eatvio_app/features/user_details/presentation/cubit/user_details_cubit.dart';
|
import 'package:eatvio_app/features/user_details/presentation/cubit/user_details_cubit.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:eatvio_app/features/profile/presentation/bloc/plans_cubit/plans_cubit.dart' as profile_plans;
|
import 'package:eatvio_app/features/profile/presentation/bloc/plans_cubit/plans_cubit.dart' as profile_plans;
|
||||||
|
|
||||||
@@ -128,18 +139,20 @@ Future<void> init() async {
|
|||||||
sl.registerFactory<ProfileCubit>(() => ProfileCubit(profileRepository: sl(), chatRepository: sl(), consultantRepository: sl()));
|
sl.registerFactory<ProfileCubit>(() => ProfileCubit(profileRepository: sl(), chatRepository: sl(), consultantRepository: sl()));
|
||||||
sl.registerFactory<profile_plans.PlansCubit>(() => profile_plans.PlansCubit(plansRepository: sl()));
|
sl.registerFactory<profile_plans.PlansCubit>(() => profile_plans.PlansCubit(plansRepository: sl()));
|
||||||
sl.registerFactory<DietsCubit>(() => DietsCubit(feedRepository: sl(), dietsRepository: sl()));
|
sl.registerFactory<DietsCubit>(() => DietsCubit(feedRepository: sl(), dietsRepository: sl()));
|
||||||
sl.registerFactory<CommentsCubit>(() => CommentsCubit(feedRepository: sl()));
|
sl.registerFactory<CommentsCubit>(() => CommentsCubit(feedRepository: sl(), commentsRepository: sl()));
|
||||||
sl.registerFactory<PlansCubit>(() => PlansCubit(feedRepository: sl(), planRepository: sl()));
|
sl.registerFactory<PlansCubit>(() => PlansCubit(feedRepository: sl(), planRepository: sl()));
|
||||||
sl.registerFactory<SettingsCubit>(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl(), consultantRepository: sl()));
|
sl.registerFactory<SettingsCubit>(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl(), consultantRepository: sl(), consultationsRepository: sl()));
|
||||||
sl.registerFactory<RegisterConsultantCubit>(() => RegisterConsultantCubit(consultantRepository: sl()));
|
sl.registerFactory<RegisterConsultantCubit>(() => RegisterConsultantCubit(consultantRepository: sl()));
|
||||||
sl.registerFactory<DiaryCubit>(() => DiaryCubit(
|
sl.registerFactory<DiaryCubit>(
|
||||||
chatRepository: sl(),
|
() => DiaryCubit(
|
||||||
diaryRepository: sl(),
|
chatRepository: sl(),
|
||||||
glossaryRepository: sl(),
|
diaryRepository: sl(),
|
||||||
profileRepository: sl(),
|
glossaryRepository: sl(),
|
||||||
dietRepository: sl(),
|
profileRepository: sl(),
|
||||||
settingsRepository: sl(),
|
dietRepository: sl(),
|
||||||
));
|
settingsRepository: sl(),
|
||||||
|
),
|
||||||
|
);
|
||||||
sl.registerFactory<AboutDietCubit>(() => AboutDietCubit(dietsRepository: sl(), profileRepository: sl()));
|
sl.registerFactory<AboutDietCubit>(() => AboutDietCubit(dietsRepository: sl(), profileRepository: sl()));
|
||||||
sl.registerFactory<BlogPostCreateCubit>(() => BlogPostCreateCubit(blogPostRepository: sl()));
|
sl.registerFactory<BlogPostCreateCubit>(() => BlogPostCreateCubit(blogPostRepository: sl()));
|
||||||
sl.registerFactory<SubCubit>(() => SubCubit(profileRepository: sl()));
|
sl.registerFactory<SubCubit>(() => SubCubit(profileRepository: sl()));
|
||||||
@@ -168,6 +181,10 @@ Future<void> init() async {
|
|||||||
sl.registerFactory<ResetPasswordCubit>(() => ResetPasswordCubit(resetPasswordRepository: sl()));
|
sl.registerFactory<ResetPasswordCubit>(() => ResetPasswordCubit(resetPasswordRepository: sl()));
|
||||||
sl.registerFactory<BlogPostCubit>(() => BlogPostCubit(sl()));
|
sl.registerFactory<BlogPostCubit>(() => BlogPostCubit(sl()));
|
||||||
sl.registerFactory<BlockedUsersCubit>(() => BlockedUsersCubit(blockedUsersRepository: sl()));
|
sl.registerFactory<BlockedUsersCubit>(() => BlockedUsersCubit(blockedUsersRepository: sl()));
|
||||||
|
sl.registerFactory<NotificationSettingsCubit>(() => NotificationSettingsCubit(notificationSettingsRepository: sl()));
|
||||||
|
sl.registerFactory<ConsultantRatingCubit>(() => ConsultantRatingCubit(sl()));
|
||||||
|
sl.registerFactory<ViewsCubit>(() => ViewsCubit(viewsRepository: sl()));
|
||||||
|
sl.registerFactory<MenuCubit>(() => MenuCubit(sl()));
|
||||||
|
|
||||||
// Repository
|
// Repository
|
||||||
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
|
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
|
||||||
@@ -198,6 +215,10 @@ Future<void> init() async {
|
|||||||
sl.registerFactory<MyRecipesRepository>(() => MyRecipesRepository(myRecipesService: sl()));
|
sl.registerFactory<MyRecipesRepository>(() => MyRecipesRepository(myRecipesService: sl()));
|
||||||
sl.registerFactory<ResetPasswordRepository>(() => ResetPasswordRepository(resetPasswordService: sl()));
|
sl.registerFactory<ResetPasswordRepository>(() => ResetPasswordRepository(resetPasswordService: sl()));
|
||||||
sl.registerLazySingleton<BlockedUsersRepository>(() => BlockedUsersRepository(blockedUserService: sl()));
|
sl.registerLazySingleton<BlockedUsersRepository>(() => BlockedUsersRepository(blockedUserService: sl()));
|
||||||
|
sl.registerLazySingleton<CommentsRepository>(() => CommentsRepository(service: sl()));
|
||||||
|
sl.registerLazySingleton<NotificationSettingsRepository>(() => NotificationSettingsRepository(sl()));
|
||||||
|
sl.registerFactory<ConsultantRatingRepository>(() => ConsultantRatingRepository(sl()));
|
||||||
|
sl.registerFactory<ViewsRepository>(() => ViewsRepository(viewsService: sl()));
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
sl.registerLazySingleton<ChatService>(() => ChatService(sl()));
|
sl.registerLazySingleton<ChatService>(() => ChatService(sl()));
|
||||||
@@ -226,28 +247,19 @@ Future<void> init() async {
|
|||||||
sl.registerLazySingleton<CancelPlanService>(() => CancelPlanService(sl()));
|
sl.registerLazySingleton<CancelPlanService>(() => CancelPlanService(sl()));
|
||||||
sl.registerLazySingleton<CreatePlanService>(() => CreatePlanService(sl()));
|
sl.registerLazySingleton<CreatePlanService>(() => CreatePlanService(sl()));
|
||||||
sl.registerLazySingleton<NotificationsService>(() => NotificationsService(sl()));
|
sl.registerLazySingleton<NotificationsService>(() => NotificationsService(sl()));
|
||||||
sl.registerLazySingleton<MyRecipesService>(() => MyRecipesService(sl()));
|
|
||||||
sl.registerLazySingleton<FirebaseApi>(() => FirebaseApi());
|
sl.registerLazySingleton<FirebaseApi>(() => FirebaseApi());
|
||||||
sl.registerLazySingleton<ResetPasswordService>(() => ResetPasswordService(sl()));
|
sl.registerLazySingleton<ResetPasswordService>(() => ResetPasswordService(sl()));
|
||||||
sl.registerLazySingleton<BlockedUserService>(() => BlockedUserService(sl()));
|
sl.registerLazySingleton<BlockedUserService>(() => BlockedUserService(sl()));
|
||||||
|
sl.registerLazySingleton<CommentsService>(() => CommentsService(sl()));
|
||||||
|
sl.registerLazySingleton<MyRecipesService>(() => MyRecipesService(sl()));
|
||||||
|
sl.registerLazySingleton<ConsultantRatingService>(() => ConsultantRatingService(sl()));
|
||||||
|
sl.registerLazySingleton<NotificationSettingsService>(() => NotificationSettingsService(sl()));
|
||||||
|
sl.registerLazySingleton<ViewsService>(() => ViewsService(sl()));
|
||||||
|
|
||||||
// External
|
// External
|
||||||
sl.registerLazySingleton(
|
sl.registerLazySingleton(
|
||||||
() => Dio(
|
() =>
|
||||||
BaseOptions(
|
Dio(BaseOptions(baseUrl: baseUrl, headers: {'accept': 'application/json', 'content-type': 'application/json'}))
|
||||||
baseUrl: baseUrl,
|
..interceptors.addAll([TokenInterceptor(), PhoneVerifyErrorInterceptor()]),
|
||||||
headers: {
|
|
||||||
'accept': 'application/json',
|
|
||||||
'content-type': 'application/json',
|
|
||||||
},
|
|
||||||
validateStatus: (status) => status != null && status < 500,
|
|
||||||
),
|
|
||||||
)..interceptors.addAll(
|
|
||||||
[
|
|
||||||
TokenInterceptor(),
|
|
||||||
PhoneVerifyErrorInterceptor(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
sl.registerLazySingleton(() async => const FlutterSecureStorage());
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
|
import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -11,6 +13,10 @@ class PermissionHandler {
|
|||||||
required Future<void> Function() onGranted,
|
required Future<void> Function() onGranted,
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
await onGranted();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final permissionState = await permission.request();
|
final permissionState = await permission.request();
|
||||||
if (permissionState.isGranted) {
|
if (permissionState.isGranted) {
|
||||||
await onGranted();
|
await onGranted();
|
||||||
|
|||||||
@@ -202,6 +202,10 @@ class PrimaryColors {
|
|||||||
Color get darkGray => const Color(0XFFBBBCC0);
|
Color get darkGray => const Color(0XFFBBBCC0);
|
||||||
|
|
||||||
Color get commentBg => const Color(0XFFFFFDD8);
|
Color get commentBg => const Color(0XFFFFFDD8);
|
||||||
|
|
||||||
|
Color get cardNotificationsBG => const Color(0xFFA4A4A4);
|
||||||
|
|
||||||
|
Color get grey7B => const Color(0xFF7B7B7B);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimaryColors get appTheme => ThemeHelper().themeColor();
|
PrimaryColors get appTheme => ThemeHelper().themeColor();
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
abstract class TokenStorage {
|
abstract class TokenStorage {
|
||||||
static Future<bool> haveTokenInStorage() async {
|
static Future<bool> haveTokenInStorage() async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
try {
|
try {
|
||||||
if (await const FlutterSecureStorage().read(key: 'token') == null) {
|
if (sharedPreferences.getString('token') == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@@ -13,11 +14,48 @@ abstract class TokenStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String?> getTokenFromStorage() async => await const FlutterSecureStorage().read(key: 'token');
|
static Future<String?> getTokenFromStorage() async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
static Future<void> saveTokenInStorage(String token) async {
|
return sharedPreferences.getString('token');
|
||||||
await const FlutterSecureStorage().write(key: 'token', value: token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> removeTokenInStorage() async => (await const FlutterSecureStorage().delete(key: 'token'));
|
static Future<void> saveTokenInStorage(String token) async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
await sharedPreferences.setString('token', token);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> removeTokenInStorage() async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
await sharedPreferences.remove('token');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class SocketIdStorage {
|
||||||
|
static Future<bool> haveSocketIdInStorage() async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
try {
|
||||||
|
if (sharedPreferences.getString('socketId') == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String?> getSocketIdFromStorage() async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
return sharedPreferences.getString('socketId');
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> saveSocketIdInStorage(String socketId) async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
await sharedPreferences.setString('socketId', socketId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> removeSocketIdInStorage() async {
|
||||||
|
final sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
await sharedPreferences.remove('socketId');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,30 @@ import 'package:intl/intl.dart';
|
|||||||
|
|
||||||
const String dateTimeFormatPattern = 'dd/MM/yyyy';
|
const String dateTimeFormatPattern = 'dd/MM/yyyy';
|
||||||
|
|
||||||
|
/// Преобразует дату из формата гггг-мм-дд чч:мм:сс в дд.мм.гггг
|
||||||
|
String formatBuildDate(String dateString) {
|
||||||
|
if (dateString.isEmpty) return '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
final dateTimeParts = dateString.split(' ');
|
||||||
|
if (dateTimeParts.isNotEmpty) {
|
||||||
|
final datePart = dateTimeParts[0];
|
||||||
|
final dateParts = datePart.split('-');
|
||||||
|
if (dateParts.length == 3) {
|
||||||
|
final year = dateParts[0];
|
||||||
|
final month = dateParts[1];
|
||||||
|
final day = dateParts[2];
|
||||||
|
return '$day.$month.$year';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return dateString;
|
||||||
|
}
|
||||||
|
return dateString;
|
||||||
|
}
|
||||||
|
|
||||||
extension DateTimeExtension on DateTime {
|
extension DateTimeExtension on DateTime {
|
||||||
String format([
|
String format([String pattern = dateTimeFormatPattern, String? locale]) {
|
||||||
String pattern = dateTimeFormatPattern,
|
|
||||||
String? locale,
|
|
||||||
]) {
|
|
||||||
final localDate = isUtc ? toLocal() : this;
|
final localDate = isUtc ? toLocal() : this;
|
||||||
if (locale != null && locale.isNotEmpty) {
|
if (locale != null && locale.isNotEmpty) {
|
||||||
initializeDateFormatting(locale);
|
initializeDateFormatting(locale);
|
||||||
@@ -19,17 +38,13 @@ extension DateTimeExtension on DateTime {
|
|||||||
final localDate = isUtc ? toLocal() : this;
|
final localDate = isUtc ? toLocal() : this;
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final yesterday = DateTime(now.year, now.month, now.day).subtract(const Duration(days: 1));
|
final yesterday = DateTime(now.year, now.month, now.day).subtract(const Duration(days: 1));
|
||||||
return localDate.year == yesterday.year &&
|
return localDate.year == yesterday.year && localDate.month == yesterday.month && localDate.day == yesterday.day;
|
||||||
localDate.month == yesterday.month &&
|
|
||||||
localDate.day == yesterday.day;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isToday() {
|
bool isToday() {
|
||||||
final localDate = isUtc ? toLocal() : this;
|
final localDate = isUtc ? toLocal() : this;
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
return now.year == localDate.year &&
|
return now.year == localDate.year && now.month == localDate.month && now.day == localDate.day;
|
||||||
now.month == localDate.month &&
|
|
||||||
now.day == localDate.day;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
128
lib/core/views/cubit/views_cubit.dart
Normal file
128
lib/core/views/cubit/views_cubit.dart
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:eatvio_app/core/views/cubit/views_state.dart';
|
||||||
|
import 'package:eatvio_app/core/views/repository/views_repository.dart';
|
||||||
|
import 'package:eatvio_app/features/feed/models/view_model.dart';
|
||||||
|
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
class ViewsCubit extends Cubit<ViewsCubitState> {
|
||||||
|
final ViewsRepository viewsRepository;
|
||||||
|
ViewsCubit({required this.viewsRepository}) : super(ViewsCubitState()) {
|
||||||
|
_listener = AppLifecycleListener(onPause: _sendViews, onInactive: _sendViews);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final AppLifecycleListener _listener;
|
||||||
|
|
||||||
|
final Set<int> postsIds = <int>{};
|
||||||
|
final Set<int> plansIds = <int>{};
|
||||||
|
final Set<int> dietsIds = <int>{};
|
||||||
|
final Set<int> recipesIds = <int>{};
|
||||||
|
|
||||||
|
final Set<int> _sentPosts = <int>{};
|
||||||
|
final Set<int> _sentPlans = <int>{};
|
||||||
|
final Set<int> _sentDiets = <int>{};
|
||||||
|
final Set<int> _sentRecipes = <int>{};
|
||||||
|
|
||||||
|
final Map<ViewableContentType, Map<int, Timer>> _visibilityTimers = {
|
||||||
|
ViewableContentType.posts: <int, Timer>{},
|
||||||
|
ViewableContentType.plans: <int, Timer>{},
|
||||||
|
ViewableContentType.diets: <int, Timer>{},
|
||||||
|
ViewableContentType.recipes: <int, Timer>{},
|
||||||
|
};
|
||||||
|
|
||||||
|
Timer? _debounceTimer;
|
||||||
|
|
||||||
|
Set<int> _idsForType(ViewableContentType type) {
|
||||||
|
switch (type) {
|
||||||
|
case ViewableContentType.posts:
|
||||||
|
return postsIds;
|
||||||
|
case ViewableContentType.plans:
|
||||||
|
return plansIds;
|
||||||
|
case ViewableContentType.diets:
|
||||||
|
return dietsIds;
|
||||||
|
case ViewableContentType.recipes:
|
||||||
|
return recipesIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<int> _sentIdsForType(ViewableContentType type) {
|
||||||
|
switch (type) {
|
||||||
|
case ViewableContentType.posts:
|
||||||
|
return _sentPosts;
|
||||||
|
case ViewableContentType.plans:
|
||||||
|
return _sentPlans;
|
||||||
|
case ViewableContentType.diets:
|
||||||
|
return _sentDiets;
|
||||||
|
case ViewableContentType.recipes:
|
||||||
|
return _sentRecipes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleVisibility({required double visibleFraction, required int id, required ViewableContentType type}) {
|
||||||
|
final timers = _visibilityTimers[type]!;
|
||||||
|
final ids = _idsForType(type);
|
||||||
|
final sent = _sentIdsForType(type);
|
||||||
|
|
||||||
|
if (sent.contains(id)) {
|
||||||
|
timers[id]?.cancel();
|
||||||
|
timers.remove(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ids.contains(id)) return;
|
||||||
|
|
||||||
|
if (visibleFraction >= 0.5) {
|
||||||
|
if (timers.containsKey(id)) return;
|
||||||
|
timers[id] = Timer(const Duration(seconds: 1), () {
|
||||||
|
ids.add(id);
|
||||||
|
timers.remove(id);
|
||||||
|
_scheduleDebouncedSend();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
timers[id]?.cancel();
|
||||||
|
timers.remove(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _viewContent({required ViewableContentType type, required List<int> ids}) async {
|
||||||
|
await viewsRepository.viewContent(
|
||||||
|
viewModel: ViewModel(type: type.getStringifiedVersion(), ids: ids),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _scheduleDebouncedSend() {
|
||||||
|
_debounceTimer?.cancel();
|
||||||
|
_debounceTimer = Timer(const Duration(seconds: 4), _sendViews);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _send(Set<int> ids, Set<int> sent, ViewableContentType type) {
|
||||||
|
final newIds = ids.difference(sent);
|
||||||
|
if (newIds.isNotEmpty) {
|
||||||
|
_viewContent(type: type, ids: newIds.toList());
|
||||||
|
sent.addAll(newIds);
|
||||||
|
ids.removeAll(newIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _sendViews() {
|
||||||
|
_send(postsIds, _sentPosts, ViewableContentType.posts);
|
||||||
|
_send(plansIds, _sentPlans, ViewableContentType.plans);
|
||||||
|
_send(dietsIds, _sentDiets, ViewableContentType.diets);
|
||||||
|
_send(recipesIds, _sentRecipes, ViewableContentType.recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> close() async {
|
||||||
|
for (final map in _visibilityTimers.values) {
|
||||||
|
for (final t in map.values) {
|
||||||
|
t.cancel();
|
||||||
|
}
|
||||||
|
map.clear();
|
||||||
|
}
|
||||||
|
_debounceTimer?.cancel();
|
||||||
|
_listener.dispose();
|
||||||
|
_sendViews();
|
||||||
|
await super.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
3
lib/core/views/cubit/views_state.dart
Normal file
3
lib/core/views/cubit/views_state.dart
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class ViewsCubitState {
|
||||||
|
ViewsCubitState();
|
||||||
|
}
|
||||||
16
lib/core/views/repository/views_repository.dart
Normal file
16
lib/core/views/repository/views_repository.dart
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import 'package:eatvio_app/core/views/service/views_service.dart';
|
||||||
|
import 'package:eatvio_app/features/feed/models/view_model.dart';
|
||||||
|
|
||||||
|
class ViewsRepository {
|
||||||
|
final ViewsService viewsService;
|
||||||
|
|
||||||
|
ViewsRepository({required this.viewsService});
|
||||||
|
|
||||||
|
Future<void> viewContent({required ViewModel viewModel}) async {
|
||||||
|
try {
|
||||||
|
await viewsService.viewContent(viewModel: viewModel);
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
lib/core/views/service/views_service.dart
Normal file
15
lib/core/views/service/views_service.dart
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:eatvio_app/features/feed/models/view_model.dart';
|
||||||
|
import 'package:retrofit/retrofit.dart';
|
||||||
|
|
||||||
|
part 'views_service.g.dart';
|
||||||
|
|
||||||
|
@RestApi()
|
||||||
|
abstract class ViewsService {
|
||||||
|
factory ViewsService(Dio dio, {String baseUrl}) = _ViewsService;
|
||||||
|
|
||||||
|
@POST('/api/views')
|
||||||
|
Future<void> viewContent({
|
||||||
|
@Body() required ViewModel viewModel,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:dart_pusher_channels/dart_pusher_channels.dart';
|
import 'package:dart_pusher_channels/dart_pusher_channels.dart';
|
||||||
@@ -59,6 +60,24 @@ class WsManager {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
String? extractSocketId(String? data) {
|
||||||
|
if (data == null) return null;
|
||||||
|
try {
|
||||||
|
final decoded = jsonDecode(data);
|
||||||
|
return decoded['socket_id'] as String?;
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client?.eventStream.listen((event) async {
|
||||||
|
if (event.name == 'pusher:connection_established') {
|
||||||
|
final data = event.data;
|
||||||
|
final socketId = extractSocketId(data);
|
||||||
|
await SocketIdStorage.saveSocketIdInStorage(socketId!);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
await client?.connect();
|
await client?.connect();
|
||||||
|
|
||||||
client = client;
|
client = client;
|
||||||
@@ -77,9 +96,8 @@ class WsManager {
|
|||||||
EasyDebounce.debounce(
|
EasyDebounce.debounce(
|
||||||
'searchChatRoom',
|
'searchChatRoom',
|
||||||
const Duration(milliseconds: 300),
|
const Duration(milliseconds: 300),
|
||||||
() => sl<ChatsCubit>().getChatRooms(),
|
() => sl<ChatsCubit>().getChatRooms(),
|
||||||
);
|
);
|
||||||
log(event.rootObject.toString());
|
|
||||||
});
|
});
|
||||||
_subscribe();
|
_subscribe();
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
|
|||||||
33
lib/core/widgets/bottom_sheet_action_widget.dart
Normal file
33
lib/core/widgets/bottom_sheet_action_widget.dart
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
|
||||||
|
class BottomSheetActionWidget extends StatelessWidget {
|
||||||
|
const BottomSheetActionWidget({super.key, required this.text, required this.iconPath, required this.onTap, this.needToPop = true, this.color});
|
||||||
|
final String text;
|
||||||
|
final String iconPath;
|
||||||
|
final void Function() onTap;
|
||||||
|
final bool needToPop;
|
||||||
|
final Color? color;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if (needToPop) Navigator.pop(context);
|
||||||
|
onTap();
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(text, style: TextStyles.textLMedium.copyWith(color: appTheme.black)),
|
||||||
|
),
|
||||||
|
SvgPicture.asset(iconPath, colorFilter: color != null ? ColorFilter.mode(color!, BlendMode.srcIn) : null),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,8 @@ import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.d
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CustomDropDown extends StatelessWidget {
|
class CustomDropDown extends StatelessWidget {
|
||||||
const CustomDropDown({super.key,
|
const CustomDropDown({
|
||||||
|
super.key,
|
||||||
this.alignment,
|
this.alignment,
|
||||||
this.width,
|
this.width,
|
||||||
this.focusNode,
|
this.focusNode,
|
||||||
@@ -48,12 +49,7 @@ class CustomDropDown extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return alignment != null
|
return alignment != null ? Align(alignment: alignment ?? Alignment.center, child: _buildDropDownWidget(context)) : _buildDropDownWidget(context);
|
||||||
? Align(
|
|
||||||
alignment: alignment ?? Alignment.center,
|
|
||||||
child: _buildDropDownWidget(context),
|
|
||||||
)
|
|
||||||
: _buildDropDownWidget(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DropdownButtonFormField<SelectionPopupModel> _buildDropDownWidget(BuildContext context) {
|
DropdownButtonFormField<SelectionPopupModel> _buildDropDownWidget(BuildContext context) {
|
||||||
@@ -61,7 +57,7 @@ class CustomDropDown extends StatelessWidget {
|
|||||||
focusNode: focusNode ?? FocusNode(),
|
focusNode: focusNode ?? FocusNode(),
|
||||||
icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||||
autofocus: autofocus!,
|
autofocus: autofocus!,
|
||||||
value: value,
|
initialValue: value,
|
||||||
isDense: true,
|
isDense: true,
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
items: items?.map((SelectionPopupModel item) {
|
items: items?.map((SelectionPopupModel item) {
|
||||||
@@ -69,12 +65,7 @@ class CustomDropDown extends StatelessWidget {
|
|||||||
value: item,
|
value: item,
|
||||||
child: Text(
|
child: Text(
|
||||||
item.title,
|
item.title,
|
||||||
style: hintStyle ??
|
style: hintStyle ?? const TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black),
|
||||||
const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
@@ -90,19 +81,9 @@ class CustomDropDown extends StatelessWidget {
|
|||||||
|
|
||||||
InputDecoration _buildInputDecoration(BuildContext context) {
|
InputDecoration _buildInputDecoration(BuildContext context) {
|
||||||
return InputDecoration(
|
return InputDecoration(
|
||||||
labelStyle: const TextStyle(
|
labelStyle: const TextStyle(fontSize: 16, color: Colors.black, fontWeight: FontWeight.w400),
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
),
|
|
||||||
hintText: hintText ?? "",
|
hintText: hintText ?? "",
|
||||||
hintStyle: hintStyle ??
|
hintStyle: hintStyle ?? TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.grey.shade400, height: 1),
|
||||||
TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Colors.grey.shade400,
|
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
prefixIcon: prefix,
|
prefixIcon: prefix,
|
||||||
prefixIconConstraints: prefixConstraints,
|
prefixIconConstraints: prefixConstraints,
|
||||||
suffixIcon: suffix,
|
suffixIcon: suffix,
|
||||||
@@ -111,18 +92,9 @@ class CustomDropDown extends StatelessWidget {
|
|||||||
contentPadding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
contentPadding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
||||||
fillColor: const Color(0xFFF6F6F6),
|
fillColor: const Color(0xFFF6F6F6),
|
||||||
filled: filled,
|
filled: filled,
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide.none),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
enabledBorder: const OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide.none),
|
||||||
borderSide: BorderSide.none,
|
focusedBorder: const OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide.none),
|
||||||
),
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
|
||||||
borderSide: BorderSide.none,
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
|
||||||
borderSide: BorderSide.none,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
|
||||||
class CustomDropDownButton<T> extends StatelessWidget {
|
class CustomDropDownButton<T> extends StatelessWidget {
|
||||||
const CustomDropDownButton({
|
const CustomDropDownButton({super.key, required this.items, required this.onChanged, this.value, this.hint, this.hasError = false});
|
||||||
super.key,
|
|
||||||
required this.items,
|
|
||||||
required this.onChanged,
|
|
||||||
this.value,
|
|
||||||
this.hint,
|
|
||||||
this.hasError = false,
|
|
||||||
});
|
|
||||||
final T? value;
|
final T? value;
|
||||||
final List<DropdownMenuItem<T>> items;
|
final List<DropdownMenuItem<T>> items;
|
||||||
final void Function(T?)? onChanged;
|
final void Function(T?)? onChanged;
|
||||||
@@ -20,11 +13,7 @@ class CustomDropDownButton<T> extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DropdownButtonFormField(
|
return DropdownButtonFormField(
|
||||||
hint: hint,
|
hint: hint,
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset('assets/icons/arrow_down2.svg', width: 12, height: 8),
|
||||||
'assets/icons/arrow_down2.svg',
|
|
||||||
width: 12,
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
dropdownColor: appTheme.lightGray0,
|
dropdownColor: appTheme.lightGray0,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -43,7 +32,7 @@ class CustomDropDownButton<T> extends StatelessWidget {
|
|||||||
fillColor: appTheme.lightGray0,
|
fillColor: appTheme.lightGray0,
|
||||||
filled: true,
|
filled: true,
|
||||||
),
|
),
|
||||||
value: value,
|
initialValue: value,
|
||||||
items: items,
|
items: items,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,9 +26,13 @@ class SuccessPublishedRecipeBottomSheet extends StatelessWidget {
|
|||||||
s.recipe_publishing,
|
s.recipe_publishing,
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||||
),
|
),
|
||||||
Text(
|
Padding(
|
||||||
'"$title" ${s.successfully_published}',
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
child: Text(
|
||||||
|
'"$title" ${s.successfully_published}',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
|
|||||||
12
lib/features/auth/models/social_exchange_request.dart
Normal file
12
lib/features/auth/models/social_exchange_request.dart
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class SocialExchangeRequest {
|
||||||
|
final String provider;
|
||||||
|
final String accessToken;
|
||||||
|
|
||||||
|
SocialExchangeRequest({required this.provider, required this.accessToken});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {'provider': provider, 'access_token': accessToken};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -6,28 +6,17 @@ import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_state
|
|||||||
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
|
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
|
||||||
class AuthCubit extends Cubit<AuthState> {
|
class AuthCubit extends Cubit<AuthState> {
|
||||||
final AuthRepository authRepository;
|
final AuthRepository authRepository;
|
||||||
|
|
||||||
AuthCubit({
|
AuthCubit({required this.authRepository}) : super(const AuthState());
|
||||||
required this.authRepository,
|
|
||||||
}) : super(const AuthState());
|
|
||||||
|
|
||||||
Future<bool> getTokenByCredentials(String email, String password) async {
|
Future<bool> getTokenByCredentials(String email, String password) async {
|
||||||
emit(const AuthState.loading());
|
emit(const AuthState.loading());
|
||||||
try {
|
try {
|
||||||
final token = (await authRepository.getTokenByCredentials(
|
final token = (await authRepository.getTokenByCredentials(email, password)).token;
|
||||||
email,
|
emit(AuthState.loaded(token: token));
|
||||||
password,
|
await TokenStorage.saveTokenInStorage(token);
|
||||||
))
|
|
||||||
.token;
|
|
||||||
emit(
|
|
||||||
AuthState.loaded(
|
|
||||||
token: token,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await TokenStorage.saveTokenInStorage(token);
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e.toString());
|
log(e.toString());
|
||||||
@@ -36,4 +25,19 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> getTokenBySocial({required String provider, required String accessToken}) async {
|
||||||
|
emit(const AuthState.loading());
|
||||||
|
try {
|
||||||
|
final token = (await authRepository.getTokenBySocial(provider: provider, accessToken: accessToken)).token;
|
||||||
|
emit(AuthState.loaded(token: token));
|
||||||
|
await TokenStorage.saveTokenInStorage(token);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
log(e.toString());
|
||||||
|
showErrorToast('Не удалось войти через $provider');
|
||||||
|
emit(AuthState.error(errorMessage: '$e'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
// ignore_for_file: unused_element, duplicate_ignore
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:eatvio_app/core/app_router.dart';
|
import 'package:eatvio_app/core/app_router.dart';
|
||||||
import 'package:eatvio_app/core/const.dart';
|
import 'package:eatvio_app/core/const.dart';
|
||||||
|
import 'package:eatvio_app/core/firebase_api.dart';
|
||||||
import 'package:eatvio_app/core/locator_service.dart';
|
import 'package:eatvio_app/core/locator_service.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
import 'package:eatvio_app/core/utils/image_constant.dart';
|
import 'package:eatvio_app/core/utils/image_constant.dart';
|
||||||
@@ -23,6 +26,7 @@ import 'package:flutter_native_splash/flutter_native_splash.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'package:eatvio_app/features/auth/sdk/social_auth_facade.dart';
|
||||||
|
|
||||||
class AuthScreen extends StatefulWidget {
|
class AuthScreen extends StatefulWidget {
|
||||||
const AuthScreen({super.key});
|
const AuthScreen({super.key});
|
||||||
@@ -46,12 +50,20 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
var keyboardVisibilityController = KeyboardVisibilityController();
|
var keyboardVisibilityController = KeyboardVisibilityController();
|
||||||
keyboardSubscription = keyboardVisibilityController.onChange.listen((bool visible) {
|
keyboardSubscription = keyboardVisibilityController.onChange.listen((bool visible) {
|
||||||
setState(() {
|
if (mounted) {
|
||||||
isFocused = visible;
|
setState(() {
|
||||||
});
|
isFocused = visible;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
keyboardSubscription.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _reconnectWebSocket(BuildContext context) async {
|
Future<void> _reconnectWebSocket(BuildContext context) async {
|
||||||
try {
|
try {
|
||||||
await sl<WsManager>().clear();
|
await sl<WsManager>().clear();
|
||||||
@@ -66,19 +78,20 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
await sl<ChatsCubit>().connectToWebSocket();
|
await sl<ChatsCubit>().connectToWebSocket();
|
||||||
await sl<NotificationsCubit>().getNotifications();
|
await sl<NotificationsCubit>().getNotifications();
|
||||||
await sl<NotificationsCubit>().connectToWebSocket();
|
await sl<NotificationsCubit>().connectToWebSocket();
|
||||||
|
await sl<FirebaseApi>().registerPushToken();
|
||||||
showSuccessToast('Успешный вход');
|
showSuccessToast('Успешный вход');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppRouter.navigatorKey.currentContext?.go(
|
AppRouter.navigatorKey.currentContext?.go('/feed-screen', extra: {'needToInitializeWebSocket': false});
|
||||||
'/feed-screen',
|
|
||||||
extra: {'needToInitializeWebSocket': false},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var shortestSide = MediaQuery.sizeOf(context).shortestSide;
|
||||||
|
final bool useMobileLayout = shortestSide < 600;
|
||||||
|
if (!useMobileLayout) isFocused = true;
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
FlutterNativeSplash.remove();
|
FlutterNativeSplash.remove();
|
||||||
return BlocProvider<AuthCubit>(
|
return BlocProvider<AuthCubit>(
|
||||||
@@ -97,11 +110,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
GoRouter.of(context).pushNamed(DevToolsScreen.name);
|
GoRouter.of(context).pushNamed(DevToolsScreen.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(ImageConstant.imgLogoEatvio, height: isFocused ? 64 : MediaQuery.of(context).size.width - 64, fit: BoxFit.contain),
|
||||||
ImageConstant.imgLogoEatvio,
|
|
||||||
height: isFocused ? 64 : MediaQuery.of(context).size.width - 64,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
@@ -132,23 +141,16 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
hidePassword = !hidePassword;
|
hidePassword = !hidePassword;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(hidePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined, color: Colors.grey),
|
||||||
hidePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Center(
|
Center(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => GoRouter.of(context).goNamed('forgetPasswordScreen'),
|
onTap: () => GoRouter.of(context).goNamed('forgetPasswordScreen', extra: false),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Забыли пароль?',
|
'Забыли пароль?',
|
||||||
style: TextStyle(
|
style: TextStyle(color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline),
|
||||||
color: appTheme.blueA400,
|
|
||||||
decorationColor: appTheme.blueA400,
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -161,11 +163,53 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
onTap: () => GoRouter.of(context).goNamed('registrationScreen'),
|
onTap: () => GoRouter.of(context).goNamed('registrationScreen'),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Зарегистрироваться',
|
'Зарегистрироваться',
|
||||||
style: TextStyle(
|
style: TextStyle(color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline),
|
||||||
color: appTheme.blueA400,
|
),
|
||||||
decorationColor: appTheme.blueA400,
|
),
|
||||||
decoration: TextDecoration.underline,
|
],
|
||||||
),
|
),
|
||||||
|
// const SizedBox(height: 16),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
_SocialButton(
|
||||||
|
onTap: () => _onVkPressed(context),
|
||||||
|
backgroundColor: const Color(0xFF2787F5),
|
||||||
|
tooltip: 'VK ID',
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
'assets/icons/vk.svg',
|
||||||
|
height: 24,
|
||||||
|
width: 24,
|
||||||
|
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_SocialButton(
|
||||||
|
onTap: _onOkPressed,
|
||||||
|
backgroundColor: const Color(0xFFF58220),
|
||||||
|
tooltip: 'Одноклассники',
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
'assets/icons/ok.svg',
|
||||||
|
height: 24,
|
||||||
|
width: 24,
|
||||||
|
colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const _SocialButton(
|
||||||
|
onTap: _onMailRuPressed,
|
||||||
|
backgroundColor: Color(0xFF005FF9),
|
||||||
|
tooltip: 'Mail.ru',
|
||||||
|
child: Text(
|
||||||
|
'Mail',
|
||||||
|
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const _SocialButton(
|
||||||
|
onTap: _onYandexPressed,
|
||||||
|
backgroundColor: Color(0xFFFFCC00),
|
||||||
|
tooltip: 'Яндекс ID',
|
||||||
|
child: Text(
|
||||||
|
'Yandex',
|
||||||
|
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w700),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -176,23 +220,22 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: 'Нажимая "Войти" или "Зарегистрироваться", Вы соглашаетесь \n',
|
text: 'Нажимая "Войти" или "Зарегистрироваться", Вы соглашаетесь \n',
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 12, color: Colors.black),
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
children: [
|
children: [
|
||||||
const TextSpan(text: 'c '),
|
const TextSpan(text: 'c '),
|
||||||
TextSpan(
|
if (!hidePlans) ...[
|
||||||
text: ' Публичной офертой',
|
TextSpan(
|
||||||
style: TextStyle(
|
text: ' Публичной офертой',
|
||||||
fontSize: 12,
|
style: TextStyle(
|
||||||
color: appTheme.blueA400,
|
fontSize: 12,
|
||||||
decorationColor: appTheme.blueA400,
|
color: appTheme.blueA400,
|
||||||
decoration: TextDecoration.underline,
|
decorationColor: appTheme.blueA400,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('$baseUrl/oferta_bs.pdf')),
|
||||||
),
|
),
|
||||||
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('$baseUrl/oferta_bs.pdf')),
|
const TextSpan(text: ' и '),
|
||||||
),
|
],
|
||||||
const TextSpan(text: ' и '),
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: 'Политикой конфиденциальности\nи защитой персональных данных',
|
text: 'Политикой конфиденциальности\nи защитой персональных данных',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -218,17 +261,12 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
highlightElevation: 0,
|
highlightElevation: 0,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
focusElevation: 0,
|
focusElevation: 0,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
),
|
|
||||||
backgroundColor: state is AuthStateLoading ? Colors.black.withAlpha(50) : appTheme.blueA400,
|
backgroundColor: state is AuthStateLoading ? Colors.black.withAlpha(50) : appTheme.blueA400,
|
||||||
onPressed: state is AuthStateLoading
|
onPressed: state is AuthStateLoading
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () async {
|
||||||
final isAuthenticated = await authCubit.getTokenByCredentials(
|
final isAuthenticated = await authCubit.getTokenByCredentials(emailController.text, passwordController.text);
|
||||||
emailController.text,
|
|
||||||
passwordController.text,
|
|
||||||
);
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
_reconnectWebSocket(context);
|
_reconnectWebSocket(context);
|
||||||
@@ -237,10 +275,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
},
|
},
|
||||||
label: state is AuthStateLoading
|
label: state is AuthStateLoading
|
||||||
? const CupertinoActivityIndicator()
|
? const CupertinoActivityIndicator()
|
||||||
: Text(
|
: Text('Войти', style: theme.textTheme.titleSmall!.copyWith(color: Colors.white)),
|
||||||
'Войти',
|
|
||||||
style: theme.textTheme.titleSmall!.copyWith(color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
@@ -252,9 +287,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
highlightElevation: 0,
|
highlightElevation: 0,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
focusElevation: 0,
|
focusElevation: 0,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
),
|
|
||||||
backgroundColor: state is AuthStateLoading ? Colors.black.withAlpha(50) : appTheme.blueA400,
|
backgroundColor: state is AuthStateLoading ? Colors.black.withAlpha(50) : appTheme.blueA400,
|
||||||
onPressed: state is AuthStateLoading
|
onPressed: state is AuthStateLoading
|
||||||
? null
|
? null
|
||||||
@@ -269,14 +302,10 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text('Где взять QR-код?\n', style: TextStyle(fontSize: 18)),
|
||||||
'Где взять QR-код?\n',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
'1. Войдите на сайте $baseUrl в свой аккаунт\n\n2. Перейдите в настройки профиля\n\n3. В разделе "Доп информация" перейдите на "QR Login"'),
|
'1. Войдите на сайте $baseUrl в свой аккаунт\n\n2. Перейдите в настройки профиля\n\n3. В разделе "Доп информация" перейдите на "QR Login"',
|
||||||
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@@ -288,15 +317,10 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
},
|
},
|
||||||
child: Ink(
|
child: Ink(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
child: const Text(
|
child: const Text(
|
||||||
'Отмена',
|
'Отмена',
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w400),
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -309,15 +333,10 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
},
|
},
|
||||||
child: Ink(
|
child: Ink(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
'Перейти',
|
'Перейти',
|
||||||
style: TextStyle(
|
style: TextStyle(color: appTheme.blueA400, fontWeight: FontWeight.w600),
|
||||||
color: appTheme.blueA400,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -332,10 +351,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
},
|
},
|
||||||
label: state is AuthStateLoading
|
label: state is AuthStateLoading
|
||||||
? const CupertinoActivityIndicator()
|
? const CupertinoActivityIndicator()
|
||||||
: const Icon(
|
: const Icon(Icons.qr_code_scanner_rounded, color: Colors.white),
|
||||||
Icons.qr_code_scanner_rounded,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -350,3 +366,88 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: unused_element
|
||||||
|
class _SocialButton extends StatelessWidget {
|
||||||
|
const _SocialButton({required this.onTap, required this.child, required this.backgroundColor, required this.tooltip});
|
||||||
|
|
||||||
|
final VoidCallback onTap;
|
||||||
|
final Widget child;
|
||||||
|
final Color backgroundColor;
|
||||||
|
final String tooltip;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Tooltip(
|
||||||
|
message: tooltip,
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
onTap: onTap,
|
||||||
|
child: Ink(
|
||||||
|
height: 48,
|
||||||
|
width: (MediaQuery.of(context).size.width - 16 * 2 - 12 * 3) / 4,
|
||||||
|
decoration: BoxDecoration(color: backgroundColor, borderRadius: BorderRadius.circular(12)),
|
||||||
|
child: Center(child: child),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore: unused_element
|
||||||
|
void _onVkPressed(BuildContext context) async {
|
||||||
|
final accessToken = await SocialAuthFacade.signInWithVk(context: context);
|
||||||
|
if (accessToken == null) return;
|
||||||
|
final isAuthenticated = await sl<AuthCubit>().getTokenBySocial(provider: 'vk', accessToken: accessToken);
|
||||||
|
if (isAuthenticated) {
|
||||||
|
if (AppRouter.navigatorKey.currentContext != null) {
|
||||||
|
// Reuse success flow
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
await _reconnectAfterAuth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onOkPressed() async {
|
||||||
|
final accessToken = await SocialAuthFacade.signInWithOk();
|
||||||
|
if (accessToken == null) return;
|
||||||
|
final isAuthenticated = await sl<AuthCubit>().getTokenBySocial(provider: 'ok', accessToken: accessToken);
|
||||||
|
if (isAuthenticated) {
|
||||||
|
await _reconnectAfterAuth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onMailRuPressed() async {
|
||||||
|
final accessToken = await SocialAuthFacade.signInWithMailRu();
|
||||||
|
if (accessToken == null) return;
|
||||||
|
final isAuthenticated = await sl<AuthCubit>().getTokenBySocial(provider: 'mailru', accessToken: accessToken);
|
||||||
|
if (isAuthenticated) {
|
||||||
|
await _reconnectAfterAuth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onYandexPressed() async {
|
||||||
|
final accessToken = await SocialAuthFacade.signInWithYandex();
|
||||||
|
if (accessToken == null) return;
|
||||||
|
final isAuthenticated = await sl<AuthCubit>().getTokenBySocial(provider: 'yandex', accessToken: accessToken);
|
||||||
|
if (isAuthenticated) {
|
||||||
|
await _reconnectAfterAuth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _reconnectAfterAuth() async {
|
||||||
|
final context = AppRouter.navigatorKey.currentContext;
|
||||||
|
if (context == null) return;
|
||||||
|
try {
|
||||||
|
await sl<WsManager>().clear();
|
||||||
|
await sl<WsManager>().initialize();
|
||||||
|
await sl<ProfileAvatarCubit>().getMyProfile();
|
||||||
|
await sl<ChatsCubit>().getChatRoomsWithLoading();
|
||||||
|
await sl<ChatsCubit>().connectToWebSocket();
|
||||||
|
await sl<NotificationsCubit>().getNotifications();
|
||||||
|
await sl<NotificationsCubit>().connectToWebSocket();
|
||||||
|
await sl<FirebaseApi>().registerPushToken();
|
||||||
|
showSuccessToast('Успешный вход');
|
||||||
|
} catch (_) {}
|
||||||
|
AppRouter.navigatorKey.currentContext?.go('/feed-screen', extra: {'needToInitializeWebSocket': false});
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class ForgetPasswordScreen extends StatefulWidget {
|
class ForgetPasswordScreen extends StatefulWidget {
|
||||||
const ForgetPasswordScreen({super.key});
|
final bool isAuth;
|
||||||
|
const ForgetPasswordScreen({super.key, required this.isAuth});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ForgetPasswordScreen> createState() => _ForgetPasswordScreenState();
|
State<ForgetPasswordScreen> createState() => _ForgetPasswordScreenState();
|
||||||
@@ -29,7 +30,7 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
|||||||
builder: (BuildContext context, ResetPasswordState state) {
|
builder: (BuildContext context, ResetPasswordState state) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Смена пароля'),
|
title: widget.isAuth ? const Text('Смена пароля') : const Text('Восстановление пароля'),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
),
|
),
|
||||||
body: state is ResetPasswordStateLoadingResetPassword || state is ResetPasswordStateLoadingSendEmailCode
|
body: state is ResetPasswordStateLoadingResetPassword || state is ResetPasswordStateLoadingSendEmailCode
|
||||||
@@ -42,9 +43,9 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (state is ResetPasswordStateCodeSendError || state is ResetPasswordStateEmpty) ...[
|
if (state is ResetPasswordStateCodeSendError || state is ResetPasswordStateEmpty) ...[
|
||||||
const Text(
|
Text(
|
||||||
'Забыли пароль? Укажите свой email,\nи мы пришлём код для сброса.',
|
'${widget.isAuth ? '' : 'Забыли пароль? '}Укажите свой email,\nи мы пришлём код для сброса.',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
@@ -156,7 +157,7 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
|||||||
}
|
}
|
||||||
if (state is ResetPasswordStateResetPassowrdSuccess) {
|
if (state is ResetPasswordStateResetPassowrdSuccess) {
|
||||||
GoRouter.of(context).pop();
|
GoRouter.of(context).pop();
|
||||||
showSuccessToast('Пароль успешно сменён. Войдите в аккаунт');
|
showSuccessToast('Пароль успешно сменён. ${widget.isAuth ? '' : 'Войдите в аккаунт'}');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:eatvio_app/core/app_router.dart';
|
import 'package:eatvio_app/core/app_router.dart';
|
||||||
import 'package:eatvio_app/core/const.dart';
|
import 'package:eatvio_app/core/const.dart';
|
||||||
|
import 'package:eatvio_app/core/firebase_api.dart';
|
||||||
import 'package:eatvio_app/core/locator_service.dart';
|
import 'package:eatvio_app/core/locator_service.dart';
|
||||||
import 'package:eatvio_app/core/token_storage.dart';
|
import 'package:eatvio_app/core/token_storage.dart';
|
||||||
import 'package:eatvio_app/core/utils/toasts.dart';
|
import 'package:eatvio_app/core/utils/toasts.dart';
|
||||||
@@ -92,6 +93,7 @@ class _ScanQRCodeScreenState extends State<ScanQRCodeScreen> {
|
|||||||
await sl<ChatsCubit>().connectToWebSocket();
|
await sl<ChatsCubit>().connectToWebSocket();
|
||||||
await sl<NotificationsCubit>().getNotifications();
|
await sl<NotificationsCubit>().getNotifications();
|
||||||
await sl<NotificationsCubit>().connectToWebSocket();
|
await sl<NotificationsCubit>().connectToWebSocket();
|
||||||
|
await sl<FirebaseApi>().registerPushToken();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:eatvio_app/features/auth/models/credentials_model.dart';
|
import 'package:eatvio_app/features/auth/models/credentials_model.dart';
|
||||||
import 'package:eatvio_app/features/auth/models/token_model.dart';
|
import 'package:eatvio_app/features/auth/models/token_model.dart';
|
||||||
import 'package:eatvio_app/features/auth/services/auth_service.dart';
|
import 'package:eatvio_app/features/auth/services/auth_service.dart';
|
||||||
|
import 'package:eatvio_app/features/auth/models/social_exchange_request.dart';
|
||||||
|
|
||||||
class AuthRepository {
|
class AuthRepository {
|
||||||
final AuthService authService;
|
final AuthService authService;
|
||||||
@@ -22,4 +23,17 @@ class AuthRepository {
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<TokenModel> getTokenBySocial({
|
||||||
|
required String provider,
|
||||||
|
required String accessToken,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
return await authService.getTokenBySocial(
|
||||||
|
body: SocialExchangeRequest(provider: provider, accessToken: accessToken),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
157
lib/features/auth/sdk/social_auth_facade.dart
Normal file
157
lib/features/auth/sdk/social_auth_facade.dart
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
|
import 'package:flutter_login_yandex/flutter_login_yandex.dart';
|
||||||
|
import 'package:eatvio_app/core/app_router.dart';
|
||||||
|
import 'package:vk_id/vk_id.dart';
|
||||||
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
|
class VkAuthResult {
|
||||||
|
VkAuthResult({required this.accessToken, this.refreshToken, this.userId, this.firstName, this.lastName, this.email, this.phone, this.gender, this.birthDate});
|
||||||
|
|
||||||
|
final String accessToken;
|
||||||
|
final String? refreshToken;
|
||||||
|
final String? userId;
|
||||||
|
final String? firstName;
|
||||||
|
final String? lastName;
|
||||||
|
final String? email;
|
||||||
|
final String? phone;
|
||||||
|
final String? gender;
|
||||||
|
final String? birthDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SocialAuthFacade {
|
||||||
|
static Future<String?> signInWithVk({required BuildContext context}) async {
|
||||||
|
final result = await signInWithVkAndFetchProfile(context: context);
|
||||||
|
return result?.accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<VkAuthResult?> signInWithVkAndFetchProfile({required BuildContext context}) async {
|
||||||
|
final clientIdStr = dotenv.maybeGet('VK_CLIENT_ID')?.trim() ?? Platform.environment['VK_CLIENT_ID'];
|
||||||
|
if (clientIdStr == null || clientIdStr.isEmpty) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
dynamic controller = VkIDController(clID: int.parse(clientIdStr));
|
||||||
|
final authUri = controller.generateAuthorizeLinkWithCodeVerifier();
|
||||||
|
final redirectScheme = 'vk$clientIdStr://';
|
||||||
|
final redirectParams = await _presentOAuthWebView(context: context, initialUrl: authUri.toString(), redirectSchemePrefix: redirectScheme);
|
||||||
|
if (redirectParams == null) return null;
|
||||||
|
final code = redirectParams['code'];
|
||||||
|
final deviceId = redirectParams['device_id'];
|
||||||
|
if (code == null || deviceId == null) return null;
|
||||||
|
|
||||||
|
final tokenResponse = await controller.exchangeAuthorizationCodeForToken(code: code, deviceId: deviceId);
|
||||||
|
final accessToken = _extractAccessToken(tokenResponse);
|
||||||
|
if (accessToken == null) return null;
|
||||||
|
return VkAuthResult(accessToken: accessToken);
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String?> signInWithOk() async {
|
||||||
|
final context = AppRouter.navigatorKey.currentContext;
|
||||||
|
if (context == null) return null;
|
||||||
|
return _signInWithVkIdProvider(context: context, provider: 'ok');
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String?> signInWithMailRu() async {
|
||||||
|
final context = AppRouter.navigatorKey.currentContext;
|
||||||
|
if (context == null) return null;
|
||||||
|
return _signInWithVkIdProvider(context: context, provider: 'mail');
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String?> signInWithYandex() async {
|
||||||
|
final clientId = dotenv.maybeGet('YANDEX_CLIENT_ID')?.trim() ?? Platform.environment['YANDEX_CLIENT_ID'];
|
||||||
|
final redirectUri = dotenv.maybeGet('YANDEX_REDIRECT_URI')?.trim() ?? Platform.environment['YANDEX_REDIRECT_URI'];
|
||||||
|
|
||||||
|
if (clientId == null || clientId.isEmpty || redirectUri == null || redirectUri.isEmpty) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final plugin = FlutterLoginYandex();
|
||||||
|
final response = await plugin.signIn();
|
||||||
|
final token = (response is Map) ? response['token'] as String? : null;
|
||||||
|
return (token != null && token.isNotEmpty) ? token : null;
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String?> _signInWithVkIdProvider({required BuildContext context, required String provider}) async {
|
||||||
|
final clientIdStr = dotenv.maybeGet('VK_CLIENT_ID')?.trim() ?? Platform.environment['VK_CLIENT_ID'];
|
||||||
|
if (clientIdStr == null || clientIdStr.isEmpty) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
dynamic controller = VkIDController(clID: int.parse(clientIdStr));
|
||||||
|
final authUri = controller.generateAuthorizeLinkWithCodeVerifier(provider: provider);
|
||||||
|
final redirectScheme = 'vk$clientIdStr://';
|
||||||
|
final redirectParams = await _presentOAuthWebView(context: context, initialUrl: authUri.toString(), redirectSchemePrefix: redirectScheme);
|
||||||
|
if (redirectParams == null) return null;
|
||||||
|
final code = redirectParams['code'];
|
||||||
|
final deviceId = redirectParams['device_id'];
|
||||||
|
if (code == null || deviceId == null) return null;
|
||||||
|
final tokenResponse = await controller.exchangeAuthorizationCodeForToken(code: code, deviceId: deviceId, provider: provider);
|
||||||
|
final accessToken = _extractAccessToken(tokenResponse);
|
||||||
|
return accessToken;
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static String? _extractAccessToken(dynamic tokenResponse) {
|
||||||
|
if (tokenResponse == null) return null;
|
||||||
|
if (tokenResponse is Map) {
|
||||||
|
return (tokenResponse['access_token'] as String?) ?? (tokenResponse['token'] as String?);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final token = (tokenResponse as dynamic).accessToken as String?;
|
||||||
|
if (token != null && token.isNotEmpty) return token;
|
||||||
|
} catch (_) {}
|
||||||
|
try {
|
||||||
|
final token = (tokenResponse as dynamic).token as String?;
|
||||||
|
if (token != null && token.isNotEmpty) return token;
|
||||||
|
} catch (_) {}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<Map<String, String>?> _presentOAuthWebView({
|
||||||
|
required BuildContext context,
|
||||||
|
required String initialUrl,
|
||||||
|
required String redirectSchemePrefix,
|
||||||
|
}) async {
|
||||||
|
final controller = WebViewController()
|
||||||
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
..setNavigationDelegate(
|
||||||
|
NavigationDelegate(
|
||||||
|
onNavigationRequest: (request) {
|
||||||
|
final url = request.url;
|
||||||
|
if (url.startsWith(redirectSchemePrefix)) {
|
||||||
|
final uri = Uri.parse(url);
|
||||||
|
final params = <String, String>{}..addAll(uri.queryParameters);
|
||||||
|
Navigator.of(context, rootNavigator: true).pop(params);
|
||||||
|
return NavigationDecision.prevent;
|
||||||
|
}
|
||||||
|
return NavigationDecision.navigate;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..loadRequest(Uri.parse(initialUrl));
|
||||||
|
|
||||||
|
return showDialog<Map<String, String>>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (_) {
|
||||||
|
return Dialog(
|
||||||
|
insetPadding: const EdgeInsets.all(16),
|
||||||
|
child: SizedBox(height: 560, child: WebViewWidget(controller: controller)),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:eatvio_app/features/auth/models/credentials_model.dart';
|
import 'package:eatvio_app/features/auth/models/credentials_model.dart';
|
||||||
import 'package:eatvio_app/features/auth/models/token_model.dart';
|
import 'package:eatvio_app/features/auth/models/token_model.dart';
|
||||||
|
import 'package:eatvio_app/features/auth/models/social_exchange_request.dart';
|
||||||
import 'package:retrofit/retrofit.dart';
|
import 'package:retrofit/retrofit.dart';
|
||||||
|
|
||||||
part 'auth_service.g.dart';
|
part 'auth_service.g.dart';
|
||||||
@@ -13,4 +14,9 @@ abstract class AuthService {
|
|||||||
Future<TokenModel> getTokenByCredentials({
|
Future<TokenModel> getTokenByCredentials({
|
||||||
@Body() required CredentialsModel credentials,
|
@Body() required CredentialsModel credentials,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@POST('/api/social/login')
|
||||||
|
Future<TokenModel> getTokenBySocial({
|
||||||
|
@Body() required SocialExchangeRequest body,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,4 +18,26 @@ class BlogPostCubit extends Cubit<BlogPostState> {
|
|||||||
emit(state.copyWith(isLoading: false));
|
emit(state.copyWith(isLoading: false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> toggleLike() async {
|
||||||
|
final current = state.blogPostModel;
|
||||||
|
if (current == null) return;
|
||||||
|
|
||||||
|
// optimistic update
|
||||||
|
final wasLiked = current.wasLikedByMe;
|
||||||
|
final updated = current.copyWith(wasLikedByMe: !wasLiked, totalLikes: wasLiked ? current.totalLikes - 1 : current.totalLikes + 1);
|
||||||
|
emit(state.copyWith(blogPostModel: updated));
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (wasLiked) {
|
||||||
|
await feedRepository.unlikedBlogPost(id: current.id);
|
||||||
|
} else {
|
||||||
|
await feedRepository.likeBlogPost(id: current.id);
|
||||||
|
}
|
||||||
|
} catch (e, st) {
|
||||||
|
// rollback on error
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
emit(state.copyWith(blogPostModel: current));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import 'package:eatvio_app/core/widgets/custom_popup.dart';
|
|||||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||||
import 'package:eatvio_app/features/blog_post/presentation/cubit/blog_post_cubit.dart';
|
import 'package:eatvio_app/features/blog_post/presentation/cubit/blog_post_cubit.dart';
|
||||||
import 'package:eatvio_app/features/blog_post/presentation/cubit/blog_post_state.dart';
|
import 'package:eatvio_app/features/blog_post/presentation/cubit/blog_post_state.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart';
|
import 'package:eatvio_app/core/comments/comments_cubit/comments_cubit.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_state.dart';
|
import 'package:eatvio_app/core/comments/comments_cubit/comments_state.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
|
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart';
|
import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart';
|
||||||
import 'package:eatvio_app/core/locator_service.dart';
|
import 'package:eatvio_app/core/locator_service.dart';
|
||||||
@@ -32,8 +32,6 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
final CommentsCubit commentsCubit = sl<CommentsCubit>();
|
final CommentsCubit commentsCubit = sl<CommentsCubit>();
|
||||||
final textEditingController = TextEditingController();
|
final textEditingController = TextEditingController();
|
||||||
int? replyId;
|
int? replyId;
|
||||||
bool isLiked = false;
|
|
||||||
int totalLikes = 0;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -60,26 +58,30 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
builder: (BuildContext context, CommentsState state) {
|
builder: (BuildContext context, CommentsState state) {
|
||||||
if (blogPostState.isLoading) {
|
if (blogPostState.isLoading) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: BackButton(
|
leading: BackButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (context.canPop()) {
|
if (context.canPop()) {
|
||||||
GoRouter.of(context).pop();
|
GoRouter.of(context).pop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GoRouter.of(context).go('/feed-screen');
|
GoRouter.of(context).go('/feed-screen');
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: const Loader());
|
),
|
||||||
|
body: const Loader(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
isLiked = blogPostState.blogPostModel?.wasLikedByMe ?? false;
|
final bool isLiked = blogPostState.blogPostModel?.wasLikedByMe ?? false;
|
||||||
totalLikes = blogPostState.blogPostModel?.totalLikes ?? 0;
|
final int totalLikes = blogPostState.blogPostModel?.totalLikes ?? 0;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
bottomSheet: Container(
|
bottomSheet: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12) + (Platform.isIOS ? const EdgeInsets.only(bottom: 16) : EdgeInsets.zero),
|
padding: const EdgeInsets.symmetric(vertical: 12) + (Platform.isIOS ? const EdgeInsets.only(bottom: 16) : EdgeInsets.zero),
|
||||||
decoration: BoxDecoration(color: Colors.white, border: Border(top: BorderSide(color: Colors.black.withValues(alpha: 0.1)))),
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border(top: BorderSide(color: Colors.black.withValues(alpha: 0.1))),
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -114,24 +116,14 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
maxLines: 5,
|
maxLines: 5,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
keyboardType: TextInputType.multiline,
|
keyboardType: TextInputType.multiline,
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black, height: 1.2),
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Colors.black,
|
|
||||||
height: 1.2,
|
|
||||||
),
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: false,
|
isDense: false,
|
||||||
// убираем true, чтобы padding учитывался корректно
|
// убираем true, чтобы padding учитывался корректно
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||||
// вертикальный паддинг увеличен
|
// вертикальный паддинг увеличен
|
||||||
hintText: 'Комментарий',
|
hintText: 'Комментарий',
|
||||||
hintStyle: const TextStyle(
|
hintStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400, height: 1.2, color: Color(0xFFAEAEB2)),
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
height: 1.2,
|
|
||||||
color: Color(0xFFAEAEB2),
|
|
||||||
),
|
|
||||||
filled: true,
|
filled: true,
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -196,7 +188,7 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
id: widget.id,
|
id: widget.id,
|
||||||
feedBlogPostModel: blogPostState.blogPostModel,
|
feedBlogPostModel: blogPostState.blogPostModel,
|
||||||
userSlug: blogPostState.blogPostModel?.author.authorSlug ?? '',
|
userSlug: blogPostState.blogPostModel?.author.authorSlug ?? '',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -215,9 +207,7 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
radius: 16,
|
radius: 16,
|
||||||
foregroundImage: NetworkImage(
|
foregroundImage: NetworkImage(baseUrl + (blogPostState.blogPostModel?.author.authorProfileIcon ?? '')),
|
||||||
baseUrl + (blogPostState.blogPostModel?.author.authorProfileIcon ?? ''),
|
|
||||||
),
|
|
||||||
backgroundImage: const AssetImage('assets/images/no_avatar.png'),
|
backgroundImage: const AssetImage('assets/images/no_avatar.png'),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
@@ -242,30 +232,32 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
if (blogPostState.blogPostModel?.description.isNotEmpty ?? false)
|
if (blogPostState.blogPostModel?.description.isNotEmpty ?? false)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
child: Html(data: blogPostState.blogPostModel?.description.replaceAll('\n', '<br>'), style: {"*": Style(color: Colors.black87)}),
|
child: Html(
|
||||||
|
data: blogPostState.blogPostModel?.description.replaceAll('\n', '<br>'),
|
||||||
|
style: {"*": Style(color: Colors.black87)},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
if (blogPostState.blogPostModel?.image.isNotEmpty ?? false)
|
if (blogPostState.blogPostModel?.image.isNotEmpty ?? false)
|
||||||
CachedNetworkImage(
|
CachedNetworkImage(imageUrl: '$baseUrl/storage/${blogPostState.blogPostModel?.image ?? ''}'),
|
||||||
imageUrl: '$baseUrl/storage/${blogPostState.blogPostModel?.image ?? ''}',
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
_iconButton(
|
_iconButton(
|
||||||
icon: Icons.favorite_border_rounded,
|
icon: isLiked ? Icons.favorite_rounded : Icons.favorite_border_rounded,
|
||||||
text: totalLikes.toString(),
|
text: totalLikes.toString(),
|
||||||
iconColor: isLiked ? Colors.red.withValues(alpha: 0.8) : null,
|
iconColor: isLiked ? Colors.red.withValues(alpha: 0.8) : null,
|
||||||
backgroundColor: isLiked ? Colors.red.withValues(alpha: 0.1) : null,
|
backgroundColor: isLiked ? Colors.red.withValues(alpha: 0.1) : null,
|
||||||
textColor: isLiked ? Colors.red.withValues(alpha: 0.8) : null,
|
textColor: isLiked ? Colors.red.withValues(alpha: 0.8) : null,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
setState(() {
|
await context.read<BlogPostCubit>().toggleLike();
|
||||||
isLiked = !isLiked;
|
// ignore: use_build_context_synchronously
|
||||||
isLiked ? totalLikes++ : totalLikes--;
|
final updated = context.read<BlogPostCubit>().state.blogPostModel;
|
||||||
});
|
if (updated != null) {
|
||||||
isLiked ? await context.read<FeedCubit>().likePost(widget.id) : await context.read<FeedCubit>().unlikedPost(widget.id);
|
// ignore: use_build_context_synchronously
|
||||||
sl<FeedCubit>().updateFeedBlogPostList(blogPostState.blogPostModel, isLiked);
|
context.read<FeedCubit>().updateFeedBlogPostList(updated, updated.wasLikedByMe);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
@@ -284,8 +276,10 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
const Spacer(),
|
const Spacer(),
|
||||||
Icon(Icons.visibility_rounded, size: 16, color: appTheme.gray500),
|
Icon(Icons.visibility_rounded, size: 16, color: appTheme.gray500),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(blogPostState.blogPostModel?.totalViews.toString() ?? '',
|
Text(
|
||||||
style: TextStyle(fontSize: 12, color: appTheme.gray500, fontWeight: FontWeight.w400)),
|
blogPostState.blogPostModel?.totalViews.toString() ?? '',
|
||||||
|
style: TextStyle(fontSize: 12, color: appTheme.gray500, fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -332,7 +326,11 @@ class _BlogPostScreenState extends State<BlogPostScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Icon(icon, size: 20, color: iconColor ?? appTheme.gray600),
|
Icon(icon, size: 20, color: iconColor ?? appTheme.gray600),
|
||||||
if (text != null) const SizedBox(width: 8),
|
if (text != null) const SizedBox(width: 8),
|
||||||
if (text != null) Text(text, style: TextStyle(color: textColor ?? appTheme.gray600, fontWeight: FontWeight.w500)),
|
if (text != null)
|
||||||
|
Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(color: textColor ?? appTheme.gray600, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,24 +1,55 @@
|
|||||||
|
import 'package:appmetrica_plugin/appmetrica_plugin.dart';
|
||||||
import 'package:eatvio_app/core/app_router.dart';
|
import 'package:eatvio_app/core/app_router.dart';
|
||||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart';
|
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart';
|
||||||
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
|
||||||
class ProfileAvatarCubit extends Cubit<ProfileAvatarState> {
|
class ProfileAvatarCubit extends Cubit<ProfileAvatarState> {
|
||||||
final ProfileRepository profileRepository;
|
final ProfileRepository profileRepository;
|
||||||
|
|
||||||
ProfileAvatarCubit({
|
ProfileAvatarCubit({required this.profileRepository}) : super(const ProfileAvatarState.loading());
|
||||||
required this.profileRepository,
|
|
||||||
}) : super(const ProfileAvatarState.loading());
|
int _calculateAge(String birthdate) {
|
||||||
|
try {
|
||||||
|
final dateParts = birthdate.split('-');
|
||||||
|
if (dateParts.length == 3) {
|
||||||
|
final birthYear = int.parse(dateParts[0]);
|
||||||
|
final birthMonth = int.parse(dateParts[1]);
|
||||||
|
final birthDay = int.parse(dateParts[2]);
|
||||||
|
|
||||||
|
final now = DateTime.now();
|
||||||
|
int age = now.year - birthYear;
|
||||||
|
|
||||||
|
if (now.month < birthMonth || (now.month == birthMonth && now.day < birthDay)) {
|
||||||
|
age--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> getMyProfile() async {
|
Future<void> getMyProfile() async {
|
||||||
emit(const ProfileAvatarState.loading());
|
emit(const ProfileAvatarState.loading());
|
||||||
|
final profile = await profileRepository.getMyProfile();
|
||||||
|
final profileDetails = await profileRepository.getMyProfileDetails();
|
||||||
try {
|
try {
|
||||||
emit(
|
emit(ProfileAvatarState.loaded(profile: profile));
|
||||||
ProfileAvatarState.loaded(
|
final notificationStatus = await Permission.notification.status;
|
||||||
profile: await profileRepository.getMyProfile(),
|
final isNotificationEnabled = notificationStatus.isGranted;
|
||||||
),
|
AppMetricaUserProfile userProfile = AppMetricaUserProfile([
|
||||||
);
|
AppMetricaNameAttribute.withValue(profile.name),
|
||||||
|
AppMetricaGenderAttribute.withValue(profileDetails.gender == 'male' ? AppMetricaGender.male : AppMetricaGender.female),
|
||||||
|
AppMetricaBirthDateAttribute.withAge(_calculateAge(profileDetails.birthdate)),
|
||||||
|
AppMetricaNotificationEnabledAttribute.withValue(isNotificationEnabled),
|
||||||
|
]);
|
||||||
|
AppMetrica.setUserProfileID(profile.slug);
|
||||||
|
AppMetrica.reportUserProfile(userProfile);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
AppRouter.navigatorKey.currentContext?.go('/auth-screen');
|
AppRouter.navigatorKey.currentContext?.go('/auth-screen');
|
||||||
emit(ProfileAvatarState.error(errorMessage: e.toString()));
|
emit(ProfileAvatarState.error(errorMessage: e.toString()));
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ abstract class ChatMessageModel with _$ChatMessageModel {
|
|||||||
@JsonKey(name: 'read_by_to_user', defaultValue: false) required bool isRead,
|
@JsonKey(name: 'read_by_to_user', defaultValue: false) required bool isRead,
|
||||||
@JsonKey(name: 'is_author_message_auth_user') required bool? isCurrentUserAuthor,
|
@JsonKey(name: 'is_author_message_auth_user') required bool? isCurrentUserAuthor,
|
||||||
@JsonKey(name: 'room_id') required String? roomId,
|
@JsonKey(name: 'room_id') required String? roomId,
|
||||||
|
@Default(MessageState.sent) @JsonKey(includeToJson: false, includeFromJson: false) MessageState messageState,
|
||||||
|
@Default(null) @JsonKey(includeToJson: false, includeFromJson: false) String? uuid,
|
||||||
}) = _ChatMessageModel;
|
}) = _ChatMessageModel;
|
||||||
|
|
||||||
factory ChatMessageModel.fromJson(Map<String, Object?> json) => _$ChatMessageModelFromJson(json);
|
factory ChatMessageModel.fromJson(Map<String, Object?> json) => _$ChatMessageModelFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum MessageState { loading, sent, error }
|
||||||
|
|||||||
@@ -22,13 +22,9 @@ abstract class ChatRoomModel with _$ChatRoomModel {
|
|||||||
@freezed
|
@freezed
|
||||||
abstract class Users with _$Users {
|
abstract class Users with _$Users {
|
||||||
const factory Users({
|
const factory Users({
|
||||||
|
|
||||||
@JsonKey(name: 'from_chat_user') required ChatUserModel sender,
|
@JsonKey(name: 'from_chat_user') required ChatUserModel sender,
|
||||||
@JsonKey(name: 'to_chat_user') required ChatUserModel receiver,
|
@JsonKey(name: 'to_chat_user') required ChatUserModel receiver,
|
||||||
|
|
||||||
}) = _Users;
|
}) = _Users;
|
||||||
|
|
||||||
factory Users.fromJson(Map<String, Object?> json) => _$UsersFromJson(json);
|
factory Users.fromJson(Map<String, Object?> json) => _$UsersFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:eatvio_app/core/models/pagination_model.dart';
|
||||||
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||||
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
|
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
@@ -8,29 +9,18 @@ part 'chat_room_pagination_model.g.dart';
|
|||||||
@freezed
|
@freezed
|
||||||
abstract class ChatRoomPaginationModel with _$ChatRoomPaginationModel {
|
abstract class ChatRoomPaginationModel with _$ChatRoomPaginationModel {
|
||||||
const factory ChatRoomPaginationModel({
|
const factory ChatRoomPaginationModel({
|
||||||
@JsonKey(name: "chatRooms") required ChatRooms chatRooms,
|
@JsonKey(name: "data") required List<ChatRoom> data,
|
||||||
@JsonKey(name: "number_of_unread_chat_rooms") required int unreadChatsCount,
|
@JsonKey(name: "number_of_unread_chat_rooms") required int unreadChatsCount,
|
||||||
|
required Meta meta,
|
||||||
}) = _ChatRoomPreviewModel;
|
}) = _ChatRoomPreviewModel;
|
||||||
|
|
||||||
factory ChatRoomPaginationModel.fromJson(Map<String, dynamic> json) => _$ChatRoomPaginationModelFromJson(json);
|
factory ChatRoomPaginationModel.fromJson(Map<String, dynamic> json) => _$ChatRoomPaginationModelFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
|
||||||
abstract class ChatRooms with _$ChatRooms {
|
|
||||||
const factory ChatRooms({
|
|
||||||
@JsonKey(name: "data") required List<ChatRoom> data,
|
|
||||||
@JsonKey(name: "last_page") required int lastPage,
|
|
||||||
@JsonKey(name: "current_page") required int currentPage,
|
|
||||||
}) = _ChatRooms;
|
|
||||||
|
|
||||||
factory ChatRooms.fromJson(Map<String, dynamic> json) => _$ChatRoomsFromJson(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
abstract class ChatRoom with _$ChatRoom {
|
abstract class ChatRoom with _$ChatRoom {
|
||||||
const factory ChatRoom({
|
const factory ChatRoom({
|
||||||
@JsonKey(name: "id") required String id,
|
@JsonKey(name: "id") required String id,
|
||||||
@JsonKey(name: "room_name") required String roomName,
|
|
||||||
@JsonKey(name: "last_message", fromJson: parseLastMessage) required ChatMessageModel? lastMessage,
|
@JsonKey(name: "last_message", fromJson: parseLastMessage) required ChatMessageModel? lastMessage,
|
||||||
@JsonKey(name: "users") required Users users,
|
@JsonKey(name: "users") required Users users,
|
||||||
@JsonKey(name: "unread_messages_count") required int unreadMessagesCount,
|
@JsonKey(name: "unread_messages_count") required int unreadMessagesCount,
|
||||||
|
|||||||
@@ -6,11 +6,8 @@ part 'chat_room_settings_model.g.dart';
|
|||||||
@freezed
|
@freezed
|
||||||
abstract class ChatRoomSettingsModel with _$ChatRoomSettingsModel {
|
abstract class ChatRoomSettingsModel with _$ChatRoomSettingsModel {
|
||||||
const factory ChatRoomSettingsModel({
|
const factory ChatRoomSettingsModel({
|
||||||
required int id,
|
@JsonKey(name: 'room_name') required String name,
|
||||||
@JsonKey(name: 'room_name') required String roomName,
|
|
||||||
required String state,
|
required String state,
|
||||||
@JsonKey(name: 'access_level') required String accessLevel,
|
|
||||||
@JsonKey(name: 'updated_at') required String updatedAt,
|
|
||||||
}) = _ChatRoomSettingsModel;
|
}) = _ChatRoomSettingsModel;
|
||||||
|
|
||||||
factory ChatRoomSettingsModel.fromJson(Map<String, Object?> json) => _$ChatRoomSettingsModelFromJson(json);
|
factory ChatRoomSettingsModel.fromJson(Map<String, Object?> json) => _$ChatRoomSettingsModelFromJson(json);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'dart:developer';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:audioplayers/audioplayers.dart';
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:dart_pusher_channels/dart_pusher_channels.dart';
|
import 'package:dart_pusher_channels/dart_pusher_channels.dart';
|
||||||
import 'package:easy_debounce/easy_debounce.dart';
|
import 'package:easy_debounce/easy_debounce.dart';
|
||||||
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
||||||
@@ -19,6 +20,7 @@ import 'package:eatvio_app/features/my_finance/models/card_model.dart';
|
|||||||
import 'package:eatvio_app/features/my_finance/repositories/cards_repository.dart';
|
import 'package:eatvio_app/features/my_finance/repositories/cards_repository.dart';
|
||||||
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
|
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class ChatRoomCubit extends Cubit<ChatRoomState> {
|
class ChatRoomCubit extends Cubit<ChatRoomState> {
|
||||||
final ChatRepository chatRepository;
|
final ChatRepository chatRepository;
|
||||||
@@ -31,12 +33,9 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
|||||||
late int lastPage;
|
late int lastPage;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
|
var uuid = const Uuid();
|
||||||
|
|
||||||
ChatRoomCubit({
|
ChatRoomCubit({required this.chatRepository, required this.wsManager, required this.cardsRepository}) : super(const ChatRoomState.loading());
|
||||||
required this.chatRepository,
|
|
||||||
required this.wsManager,
|
|
||||||
required this.cardsRepository,
|
|
||||||
}) : super(const ChatRoomState.loading());
|
|
||||||
|
|
||||||
void setTimer() {
|
void setTimer() {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
@@ -47,14 +46,14 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
|||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadNextPage(String chatId) async {
|
Future<void> loadNextPage(String uuid) async {
|
||||||
if (currentPage < lastPage && !isLoading) {
|
if (currentPage < lastPage && !isLoading) {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
|
||||||
emit((state as ChatRoomStateLoaded).copyWith(isLoading: isLoading));
|
emit((state as ChatRoomStateLoaded).copyWith(isLoading: isLoading));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final chatMessages = await chatRepository.getChatMessages(chatId, currentPage + 1);
|
final chatMessages = await chatRepository.getChatMessages(uuid, currentPage + 1);
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
emit(
|
emit(
|
||||||
@@ -89,17 +88,16 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initChat(String chatId, {bool sendInitialMessage = false}) async {
|
Future<void> initChat(String uuid, {bool sendInitialMessage = false}) async {
|
||||||
try {
|
try {
|
||||||
final chatRoom = await chatRepository.getChatRoom(chatId);
|
final chatRoom = await chatRepository.getChatRoom(uuid);
|
||||||
ChosenPlanModel? chosenPlan;
|
ChosenPlanModel? chosenPlan;
|
||||||
if (chatRoom.chosenPlanId != null) {
|
if (chatRoom.chosenPlanId != null) {
|
||||||
chosenPlan = await chatRepository.getChosenPlan(id: chatRoom.chosenPlanId!);
|
chosenPlan = await chatRepository.getChosenPlan(id: chatRoom.chosenPlanId!);
|
||||||
}
|
}
|
||||||
final chatMessages = await chatRepository.getChatMessages(chatId, currentPage);
|
final chatMessages = await chatRepository.getChatMessages(uuid, currentPage);
|
||||||
lastPage = chatMessages.meta.lastPage;
|
lastPage = chatMessages.meta.lastPage;
|
||||||
|
await _subscribeToChatChannel(uuid: uuid, chatId: chatRoom.id);
|
||||||
await _subscribeToChatChannel(chatId: chatId);
|
|
||||||
emit(
|
emit(
|
||||||
ChatRoomState.loaded(
|
ChatRoomState.loaded(
|
||||||
chatRoom: chatRoom.copyWith(chosenPlan: chosenPlan),
|
chatRoom: chatRoom.copyWith(chosenPlan: chosenPlan),
|
||||||
@@ -158,43 +156,80 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _subscribeToChatChannel({required String chatId}) async {
|
Future<void> _subscribeToChatChannel({required String uuid, required String chatId}) async {
|
||||||
final client = wsManager.client;
|
final client = wsManager.client;
|
||||||
if (client == null) return;
|
if (client == null) return;
|
||||||
await wsManager.initPrivateDirectChatChannel(chatId);
|
await wsManager.initPrivateDirectChatChannel(chatId);
|
||||||
wsManager.subscribeDirectChatChannel();
|
wsManager.subscribeDirectChatChannel();
|
||||||
messagesSubscription = wsManager.directChatStream?.listen((event) {
|
messagesSubscription = wsManager.directChatStream?.listen((event) {
|
||||||
AudioPlayer().play((AssetSource('audio/recive_message.wav')));
|
AudioPlayer().play((AssetSource('audio/recive_message.wav')));
|
||||||
final message = ChatMessageModel.fromJson(jsonDecode(event.data)['message']);
|
final message = ChatMessageModel.fromJson(jsonDecode(event.data));
|
||||||
List<ChatMessageModel> messagesList = [message, ...(state as ChatRoomStateLoaded).chatMessages];
|
List<ChatMessageModel> messagesList = [message, ...(state as ChatRoomStateLoaded).chatMessages];
|
||||||
chatRepository.emitNewMessageToChats(message);
|
chatRepository.emitNewMessageToChats(message);
|
||||||
emit((state as ChatRoomStateLoaded).copyWith(chatMessages: messagesList, isLoading: isLoading));
|
emit((state as ChatRoomStateLoaded).copyWith(chatMessages: messagesList, isLoading: isLoading));
|
||||||
EasyDebounce.debounce(
|
EasyDebounce.debounce('searchChatRoom', const Duration(milliseconds: 300), () => sl<ChatsCubit>().getChatRooms());
|
||||||
'searchChatRoom',
|
|
||||||
const Duration(milliseconds: 300),
|
|
||||||
() => sl<ChatsCubit>().getChatRooms(),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
typingSubscription = wsManager.clientTypingStream?.listen((event) {
|
typingSubscription = wsManager.clientTypingStream?.listen((event) {
|
||||||
emit((state as ChatRoomStateLoaded).copyWith(isTyping: true, isLoading: isLoading));
|
emit((state as ChatRoomStateLoaded).copyWith(isTyping: true, isLoading: isLoading));
|
||||||
EasyDebounce.debounce(
|
EasyDebounce.debounce(
|
||||||
'client-typing', const Duration(seconds: 3), () => emit((state as ChatRoomStateLoaded).copyWith(isTyping: false, isLoading: isLoading)));
|
'client-typing',
|
||||||
|
const Duration(seconds: 3),
|
||||||
|
() => emit((state as ChatRoomStateLoaded).copyWith(isTyping: false, isLoading: isLoading)),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> sendMessage({
|
Future<bool> sendMessage({String? data, List<File>? files, required String userSlug}) async {
|
||||||
String? data,
|
|
||||||
List<File>? files,
|
|
||||||
required String userSlug,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
await chatRepository.sendMessage(
|
final messageUuid = uuid.v4();
|
||||||
data: data,
|
final compressedFiles = files != null ? await ImageCompressUtility.compressFilesList(List<File>.from(files)) : null;
|
||||||
files: files != null ? await ImageCompressUtility.compressFilesList(List<File>.from(files)) : null,
|
|
||||||
slug: userSlug,
|
|
||||||
);
|
|
||||||
AudioPlayer().play((AssetSource('audio/send_message.wav')));
|
AudioPlayer().play((AssetSource('audio/send_message.wav')));
|
||||||
|
emit(
|
||||||
|
(state as ChatRoomStateLoaded).copyWith(
|
||||||
|
chatMessages: [
|
||||||
|
ChatMessageModel(
|
||||||
|
id: 1,
|
||||||
|
data: data ?? '',
|
||||||
|
mediaData: compressedFiles,
|
||||||
|
authorId: 1,
|
||||||
|
updatedAt: DateTime.now(),
|
||||||
|
isRead: true,
|
||||||
|
isCurrentUserAuthor: true,
|
||||||
|
roomId: '',
|
||||||
|
messageState: MessageState.loading,
|
||||||
|
uuid: messageUuid,
|
||||||
|
),
|
||||||
|
...(state as ChatRoomStateLoaded).chatMessages,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await chatRepository.sendMessage(data: data, files: compressedFiles, slug: userSlug);
|
||||||
|
emit(
|
||||||
|
(state as ChatRoomStateLoaded).copyWith(
|
||||||
|
chatMessages: (state as ChatRoomStateLoaded).chatMessages.map((elem) {
|
||||||
|
if (elem.uuid == messageUuid) {
|
||||||
|
return elem.copyWith(messageState: MessageState.sent);
|
||||||
|
}
|
||||||
|
return elem;
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
emit(
|
||||||
|
(state as ChatRoomStateLoaded).copyWith(
|
||||||
|
chatMessages: (state as ChatRoomStateLoaded).chatMessages.map((elem) {
|
||||||
|
if (elem.uuid == messageUuid) {
|
||||||
|
return elem.copyWith(messageState: MessageState.error);
|
||||||
|
}
|
||||||
|
return elem;
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
sl<ChatsCubit>().getChatRooms();
|
||||||
return true;
|
return true;
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
log(e.toString(), stackTrace: st);
|
log(e.toString(), stackTrace: st);
|
||||||
@@ -239,7 +274,10 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
|||||||
try {
|
try {
|
||||||
final planId = (state as ChatRoomStateLoaded).chatRoom.chosenPlan?.id;
|
final planId = (state as ChatRoomStateLoaded).chatRoom.chosenPlan?.id;
|
||||||
if (planId == null) return false;
|
if (planId == null) return false;
|
||||||
await chatRepository.complainAboutConsultation(id: planId, body: PlanComplainModel(description: description));
|
await chatRepository.complainAboutConsultation(
|
||||||
|
id: planId,
|
||||||
|
body: PlanComplainModel(description: description),
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e.toString());
|
log(e.toString());
|
||||||
@@ -267,4 +305,70 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
|||||||
typingSubscription?.cancel();
|
typingSubscription?.cancel();
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deleteMessage(String uuid) {
|
||||||
|
final currentState = state;
|
||||||
|
if (currentState is ChatRoomStateLoaded) {
|
||||||
|
emit(currentState.copyWith(chatMessages: currentState.chatMessages.where((message) => message.uuid != uuid).toList()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> resendMessage({required String uuid, required String userSlug}) async {
|
||||||
|
final currentState = state;
|
||||||
|
if (currentState is ChatRoomStateLoaded) {
|
||||||
|
final message = currentState.chatMessages.firstWhereOrNull((message) => message.uuid == uuid);
|
||||||
|
if (message != null) {
|
||||||
|
try {
|
||||||
|
AudioPlayer().play((AssetSource('audio/send_message.wav')));
|
||||||
|
emit(
|
||||||
|
(state as ChatRoomStateLoaded).copyWith(
|
||||||
|
chatMessages: [
|
||||||
|
ChatMessageModel(
|
||||||
|
id: 1,
|
||||||
|
data: message.data,
|
||||||
|
mediaData: message.mediaData,
|
||||||
|
authorId: 1,
|
||||||
|
updatedAt: DateTime.now(),
|
||||||
|
isRead: true,
|
||||||
|
isCurrentUserAuthor: true,
|
||||||
|
roomId: '',
|
||||||
|
messageState: MessageState.loading,
|
||||||
|
uuid: uuid,
|
||||||
|
),
|
||||||
|
...(state as ChatRoomStateLoaded).chatMessages.where((message) => message.uuid != uuid),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await chatRepository.sendMessage(data: message.data, files: message.mediaData as List<File>?, slug: userSlug);
|
||||||
|
emit(
|
||||||
|
(state as ChatRoomStateLoaded).copyWith(
|
||||||
|
chatMessages: (state as ChatRoomStateLoaded).chatMessages.map((elem) {
|
||||||
|
if (elem.uuid == uuid) {
|
||||||
|
return elem.copyWith(messageState: MessageState.sent);
|
||||||
|
}
|
||||||
|
return elem;
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
emit(
|
||||||
|
(state as ChatRoomStateLoaded).copyWith(
|
||||||
|
chatMessages: (state as ChatRoomStateLoaded).chatMessages.map((elem) {
|
||||||
|
if (elem.uuid == uuid) {
|
||||||
|
return elem.copyWith(messageState: MessageState.error);
|
||||||
|
}
|
||||||
|
return elem;
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
sl<ChatsCubit>().getChatRooms();
|
||||||
|
} catch (e, st) {
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class ChatsCubit extends Cubit<ChatsState> {
|
|||||||
required this.chatRepository,
|
required this.chatRepository,
|
||||||
required this.wsManager,
|
required this.wsManager,
|
||||||
required this.profileRepository,
|
required this.profileRepository,
|
||||||
}) : super(ChatsState()) {
|
}) : super(ChatsState()) {
|
||||||
newLastMessageSubscription = chatRepository.newUserMessagesStream.listen((message) {
|
newLastMessageSubscription = chatRepository.newUserMessagesStream.listen((message) {
|
||||||
_setNewLastMessage(message);
|
_setNewLastMessage(message);
|
||||||
});
|
});
|
||||||
@@ -29,6 +29,7 @@ class ChatsCubit extends Cubit<ChatsState> {
|
|||||||
String? _query;
|
String? _query;
|
||||||
int page = 1;
|
int page = 1;
|
||||||
late int lastPage;
|
late int lastPage;
|
||||||
|
|
||||||
Future<void> connectToWebSocket() async {
|
Future<void> connectToWebSocket() async {
|
||||||
await newIncomingMessagesSubscription?.cancel();
|
await newIncomingMessagesSubscription?.cancel();
|
||||||
newIncomingMessagesSubscription = wsManager.newMessagesStream?.listen((event) {
|
newIncomingMessagesSubscription = wsManager.newMessagesStream?.listen((event) {
|
||||||
@@ -43,10 +44,10 @@ class ChatsCubit extends Cubit<ChatsState> {
|
|||||||
try {
|
try {
|
||||||
final chatRoomsPaginationModel = await chatRepository.getChatRooms(query: query);
|
final chatRoomsPaginationModel = await chatRepository.getChatRooms(query: query);
|
||||||
final unreadChats = chatRoomsPaginationModel.unreadChatsCount;
|
final unreadChats = chatRoomsPaginationModel.unreadChatsCount;
|
||||||
lastPage = chatRoomsPaginationModel.chatRooms.lastPage + 1;
|
lastPage = chatRoomsPaginationModel.meta.lastPage + 1;
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
chatRooms: chatRoomsPaginationModel.chatRooms.data,
|
chatRooms: chatRoomsPaginationModel.data,
|
||||||
chatsWithUnreadMessagesCount: unreadChats,
|
chatsWithUnreadMessagesCount: unreadChats,
|
||||||
state: BaseState.success,
|
state: BaseState.success,
|
||||||
),
|
),
|
||||||
@@ -65,10 +66,10 @@ class ChatsCubit extends Cubit<ChatsState> {
|
|||||||
try {
|
try {
|
||||||
final chatRoomsPaginationModel = await chatRepository.getChatRooms(query: query);
|
final chatRoomsPaginationModel = await chatRepository.getChatRooms(query: query);
|
||||||
final unreadChats = chatRoomsPaginationModel.unreadChatsCount;
|
final unreadChats = chatRoomsPaginationModel.unreadChatsCount;
|
||||||
lastPage = chatRoomsPaginationModel.chatRooms.lastPage + 1;
|
lastPage = chatRoomsPaginationModel.meta.lastPage + 1;
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
chatRooms: chatRoomsPaginationModel.chatRooms.data,
|
chatRooms: chatRoomsPaginationModel.data,
|
||||||
chatsWithUnreadMessagesCount: unreadChats,
|
chatsWithUnreadMessagesCount: unreadChats,
|
||||||
state: BaseState.success,
|
state: BaseState.success,
|
||||||
),
|
),
|
||||||
@@ -90,7 +91,7 @@ class ChatsCubit extends Cubit<ChatsState> {
|
|||||||
final unreadChats = chatRoomsPaginationModel.unreadChatsCount;
|
final unreadChats = chatRoomsPaginationModel.unreadChatsCount;
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
chatRooms: [...state.chatRooms, ...chatRoomsPaginationModel.chatRooms.data],
|
chatRooms: [...state.chatRooms, ...chatRoomsPaginationModel.data],
|
||||||
chatsWithUnreadMessagesCount: unreadChats,
|
chatsWithUnreadMessagesCount: unreadChats,
|
||||||
state: BaseState.success,
|
state: BaseState.success,
|
||||||
isLoadingMoreChats: false,
|
isLoadingMoreChats: false,
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.da
|
|||||||
import 'package:eatvio_app/features/chat/presentation/widgets/about_order_button.dart';
|
import 'package:eatvio_app/features/chat/presentation/widgets/about_order_button.dart';
|
||||||
import 'package:eatvio_app/features/chat/presentation/widgets/chat_bubble_widget.dart';
|
import 'package:eatvio_app/features/chat/presentation/widgets/chat_bubble_widget.dart';
|
||||||
import 'package:eatvio_app/core/locator_service.dart';
|
import 'package:eatvio_app/core/locator_service.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_cubit.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_state.dart';
|
||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
import 'package:eatvio_app/features/chat/presentation/widgets/notification_banner.dart';
|
import 'package:eatvio_app/features/chat/presentation/widgets/notification_banner.dart';
|
||||||
@@ -32,10 +34,10 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:visibility_detector/visibility_detector.dart';
|
||||||
|
|
||||||
class ChatScreen extends StatefulWidget {
|
class ChatScreen extends StatefulWidget {
|
||||||
final String chatId;
|
final String uuid;
|
||||||
final bool? sendInitialMessage;
|
final bool? sendInitialMessage;
|
||||||
|
|
||||||
const ChatScreen({required this.chatId, super.key, required this.sendInitialMessage});
|
const ChatScreen({required this.uuid, super.key, required this.sendInitialMessage});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ChatScreen> createState() => _ChatScreenState();
|
State<ChatScreen> createState() => _ChatScreenState();
|
||||||
@@ -64,14 +66,14 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
scrollController.addListener(_onScroll);
|
scrollController.addListener(_onScroll);
|
||||||
chatRoomCubit.initChat(widget.chatId, sendInitialMessage: widget.sendInitialMessage ?? false);
|
chatRoomCubit.initChat(widget.uuid, sendInitialMessage: widget.sendInitialMessage ?? false);
|
||||||
chatRoomCubit.setTimer();
|
chatRoomCubit.setTimer();
|
||||||
_listener = AppLifecycleListener(onHide: _onHide, onResume: _onResume);
|
_listener = AppLifecycleListener(onHide: _onHide, onResume: _onResume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onScroll() {
|
void _onScroll() {
|
||||||
if (scrollController.offset >= scrollController.position.maxScrollExtent && !scrollController.position.outOfRange) {
|
if (scrollController.offset >= scrollController.position.maxScrollExtent && !scrollController.position.outOfRange) {
|
||||||
chatRoomCubit.loadNextPage(widget.chatId);
|
chatRoomCubit.loadNextPage(widget.uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +95,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
if (state is ChatRoomStateLoaded) {
|
if (state is ChatRoomStateLoaded) {
|
||||||
return _buildChat(context, state);
|
return _buildChat(context, state);
|
||||||
} else if (state is ChatRoomStateError) {
|
} else if (state is ChatRoomStateError) {
|
||||||
return Scaffold(appBar: AppBar(), body: DataErrorWidget(onReload: () => chatRoomCubit.initChat(widget.chatId)));
|
return Scaffold(
|
||||||
|
appBar: AppBar(),
|
||||||
|
body: DataErrorWidget(onReload: () => chatRoomCubit.initChat(widget.uuid)),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return const Scaffold(body: Loader());
|
return const Scaffold(body: Loader());
|
||||||
}
|
}
|
||||||
@@ -168,34 +173,19 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(color: Color(0xFFEBF4FF), shape: BoxShape.circle),
|
||||||
color: Color(0xFFEBF4FF),
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
state.chatRoom.users.receiver.name.split(' ').first[0] + state.chatRoom.users.receiver.name.split(' ')[1][0],
|
state.chatRoom.users.receiver.name.split(' ').first[0] + state.chatRoom.users.receiver.name.split(' ')[1][0],
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Color(0xFF7F9CF5), fontWeight: FontWeight.w400, fontSize: 20),
|
||||||
color: Color(0xFF7F9CF5),
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 20,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(state.chatRoom.users.receiver.name, style: CustomTextStyles.titleSmallBold.copyWith(color: PrimaryColors().black)),
|
||||||
state.chatRoom.users.receiver.name,
|
|
||||||
style: CustomTextStyles.titleSmallBold.copyWith(
|
|
||||||
color: PrimaryColors().black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AnimatedCrossFade(
|
AnimatedCrossFade(
|
||||||
firstChild: Text(
|
firstChild: Text('Печатает...', style: CustomTextStyles.bodySmallMulishPrimary),
|
||||||
'Печатает...',
|
|
||||||
style: CustomTextStyles.bodySmallMulishPrimary,
|
|
||||||
),
|
|
||||||
firstCurve: Curves.easeIn,
|
firstCurve: Curves.easeIn,
|
||||||
secondCurve: Curves.easeOut,
|
secondCurve: Curves.easeOut,
|
||||||
secondChild: const SizedBox.shrink(),
|
secondChild: const SizedBox.shrink(),
|
||||||
@@ -251,9 +241,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
if (!result) return;
|
if (!result) return;
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
context.read<ChatsCubit>().reduceUnreadMessagesCount(
|
context.read<ChatsCubit>().reduceUnreadMessagesCount(
|
||||||
chatId: state.chatRoom.id,
|
chatId: state.chatRoom.id,
|
||||||
count: unreadMessagesIdsCopy.length,
|
count: unreadMessagesIdsCopy.length,
|
||||||
);
|
);
|
||||||
unreadMessagesIdsCopy.clear();
|
unreadMessagesIdsCopy.clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -264,6 +254,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
text: state.chatMessages[index].data.trim(),
|
text: state.chatMessages[index].data.trim(),
|
||||||
isCurrentUser: isCurrentUserAuthor,
|
isCurrentUser: isCurrentUserAuthor,
|
||||||
mediaData: state.chatMessages[index].mediaData ?? [],
|
mediaData: state.chatMessages[index].mediaData ?? [],
|
||||||
|
messageState: state.chatMessages[index].messageState,
|
||||||
|
messageUuid: state.chatMessages[index].uuid ?? '',
|
||||||
|
userSlug: state.chatRoom.users.receiver.slug,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -290,6 +283,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
text: state.chatMessages[index].data.trim(),
|
text: state.chatMessages[index].data.trim(),
|
||||||
isCurrentUser: isCurrentUserAuthor,
|
isCurrentUser: isCurrentUserAuthor,
|
||||||
mediaData: state.chatMessages[index].mediaData ?? [],
|
mediaData: state.chatMessages[index].mediaData ?? [],
|
||||||
|
messageState: state.chatMessages[index].messageState,
|
||||||
|
messageUuid: state.chatMessages[index].uuid ?? '',
|
||||||
|
userSlug: state.chatRoom.users.receiver.slug,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -361,11 +357,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
final imageIndex = _imageIndexAt(pickedFiles, i);
|
final imageIndex = _imageIndexAt(pickedFiles, i);
|
||||||
|
|
||||||
context.pushTransparentRoute(
|
context.pushTransparentRoute(
|
||||||
PhotoViewScreen(
|
PhotoViewScreen(imageUrls: imageFiles.map((e) => e.path).toList(), isLocal: true, index: imageIndex),
|
||||||
imageUrls: imageFiles.map((e) => e.path).toList(),
|
|
||||||
isLocal: true,
|
|
||||||
index: imageIndex,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Hero(
|
child: Hero(
|
||||||
@@ -373,14 +365,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
transitionOnUserGestures: true,
|
transitionOnUserGestures: true,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: SizedBox(
|
child: SizedBox(height: 104, width: 104, child: Image.file(pickedFiles[i], fit: BoxFit.cover)),
|
||||||
height: 104,
|
|
||||||
width: 104,
|
|
||||||
child: Image.file(
|
|
||||||
pickedFiles[i],
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -397,15 +382,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(color: appTheme.gray50, shape: BoxShape.circle),
|
||||||
color: appTheme.gray50,
|
child: const Icon(size: 20, Icons.close, color: Colors.black),
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
size: 20,
|
|
||||||
Icons.close,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -427,7 +405,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
child: Ink(
|
child: Ink(
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 40,
|
width: 40,
|
||||||
child: Transform.rotate(angle: pi / 4, child: const Icon(Icons.attach_file_rounded, size: 30, color: Color(0xFF858E99))),
|
child: Transform.rotate(
|
||||||
|
angle: pi / 4,
|
||||||
|
child: const Icon(Icons.attach_file_rounded, size: 30, color: Color(0xFF858E99)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
@@ -449,7 +430,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
hintStyle: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, height: 1, color: Color(0xFFAEAEB2)),
|
hintStyle: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, height: 1, color: Color(0xFFAEAEB2)),
|
||||||
filled: true,
|
filled: true,
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(100), borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1)),
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
|
||||||
|
),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(100),
|
borderRadius: BorderRadius.circular(100),
|
||||||
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
|
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
|
||||||
@@ -465,7 +448,27 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
InkWell(
|
InkWell(
|
||||||
customBorder: const CircleBorder(),
|
customBorder: const CircleBorder(),
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
|
// Проверяем, заблокирован ли пользователь
|
||||||
|
final blockedUsersCubit = sl<BlockedUsersCubit>();
|
||||||
|
await blockedUsersCubit.getBlockedUsers();
|
||||||
|
final blockedState = blockedUsersCubit.state;
|
||||||
|
|
||||||
|
if (blockedState is BlockedUsersStateLoaded) {
|
||||||
|
final isBlocked = blockedState.profilesList.any((profile) => profile.slug == state.chatRoom.users.receiver.slug);
|
||||||
|
if (isBlocked) {
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Вы не можете отправить сообщение заблокированному пользователю'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (textEditingController.text.isNotEmpty || pickedFiles.isNotEmpty) {
|
if (textEditingController.text.isNotEmpty || pickedFiles.isNotEmpty) {
|
||||||
chatRoomCubit.sendMessage(
|
chatRoomCubit.sendMessage(
|
||||||
data: textEditingController.text.isEmpty ? null : textEditingController.text.trim(),
|
data: textEditingController.text.isEmpty ? null : textEditingController.text.trim(),
|
||||||
@@ -525,13 +528,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
const Icon(Icons.attach_file, size: 32, color: Colors.black54),
|
const Icon(Icons.attach_file, size: 32, color: Colors.black54),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Text(
|
child: Text(fileName, textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 12)),
|
||||||
fileName,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -579,13 +576,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
// await chatRoomCubit.sendMessage(files: [File(image.path)], userSlug: slug);
|
// await chatRoomCubit.sendMessage(files: [File(image.path)], userSlug: slug);
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
child: const Row(
|
child: const Row(children: [Icon(Icons.photo_camera), SizedBox(width: 8), Text('Фото')]),
|
||||||
children: [
|
|
||||||
Icon(Icons.photo_camera),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Фото'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
CupertinoActionSheetAction(
|
CupertinoActionSheetAction(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@@ -600,13 +591,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
// await chatRoomCubit.sendMessage(files: files, userSlug: slug);
|
// await chatRoomCubit.sendMessage(files: files, userSlug: slug);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Row(
|
child: const Row(children: [Icon(Icons.photo_library_rounded), SizedBox(width: 8), Text('Галерея')]),
|
||||||
children: [
|
|
||||||
Icon(Icons.photo_library_rounded),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Галерея'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
CupertinoActionSheetAction(
|
CupertinoActionSheetAction(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@@ -643,20 +628,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
// await chatRoomCubit.sendMessage(files: files, userSlug: slug);
|
// await chatRoomCubit.sendMessage(files: files, userSlug: slug);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Row(
|
child: const Row(children: [Icon(Icons.file_present_rounded), SizedBox(width: 8), Text('Файлы')]),
|
||||||
children: [
|
|
||||||
Icon(Icons.file_present_rounded),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Файлы'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
cancelButton: CupertinoActionSheetAction(
|
cancelButton: CupertinoActionSheetAction(onPressed: () => Navigator.of(context).pop(), isDestructiveAction: true, child: const Text('Отмена')),
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
isDestructiveAction: true,
|
|
||||||
child: const Text('Отмена'),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -665,7 +640,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 32),
|
padding: const EdgeInsets.only(top: 32),
|
||||||
child: Text(DateFormat.yMMMMd('RU').format(date), style: const TextStyle(height: 1, color: Color(0xFF8393A1), fontWeight: FontWeight.w500)),
|
child: Text(
|
||||||
|
DateFormat.yMMMMd('RU').format(date),
|
||||||
|
style: const TextStyle(height: 1, color: Color(0xFF8393A1), fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_cubit.dart';
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/blocked_user_cubit/blocked_users_state.dart';
|
||||||
|
|
||||||
class EmptyChatScreen extends StatefulWidget {
|
class EmptyChatScreen extends StatefulWidget {
|
||||||
final Author author;
|
final Author author;
|
||||||
@@ -133,21 +135,45 @@ class _EmptyChatScreenState extends State<EmptyChatScreen> {
|
|||||||
InkWell(
|
InkWell(
|
||||||
customBorder: const CircleBorder(),
|
customBorder: const CircleBorder(),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
// Проверяем, заблокирован ли пользователь
|
||||||
|
final blockedUsersCubit = sl<BlockedUsersCubit>();
|
||||||
|
await blockedUsersCubit.getBlockedUsers();
|
||||||
|
final blockedState = blockedUsersCubit.state;
|
||||||
|
|
||||||
|
if (blockedState is BlockedUsersStateLoaded) {
|
||||||
|
final isBlocked = blockedState.profilesList.any((profile) => profile.slug == widget.author.authorSlug);
|
||||||
|
if (isBlocked) {
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Вы не можете отправить сообщение заблокированному пользователю'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (textEditingController.text.isNotEmpty) {
|
if (textEditingController.text.isNotEmpty) {
|
||||||
await sl<ChatRepository>().sendMessage(
|
await sl<ChatRepository>().sendMessage(
|
||||||
data: textEditingController.text.trim(),
|
data: textEditingController.text.trim(),
|
||||||
slug: widget.author.authorSlug,
|
slug: widget.author.authorSlug,
|
||||||
);
|
);
|
||||||
setState(() {
|
if (mounted) {
|
||||||
textEditingController.clear();
|
setState(() {
|
||||||
});
|
textEditingController.clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
||||||
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
if (context.mounted) {
|
||||||
'chatScreen',
|
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
||||||
extra: {
|
'chatScreen',
|
||||||
'chatId': chatIdOrError,
|
extra: {
|
||||||
},
|
'uuid': chatIdOrError,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Ink(
|
child: Ink(
|
||||||
@@ -175,20 +201,44 @@ class _EmptyChatScreenState extends State<EmptyChatScreen> {
|
|||||||
CupertinoActionSheetAction(
|
CupertinoActionSheetAction(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
// Проверяем, заблокирован ли пользователь
|
||||||
|
final blockedUsersCubit = sl<BlockedUsersCubit>();
|
||||||
|
await blockedUsersCubit.getBlockedUsers();
|
||||||
|
final blockedState = blockedUsersCubit.state;
|
||||||
|
|
||||||
|
if (blockedState is BlockedUsersStateLoaded) {
|
||||||
|
final isBlocked = blockedState.profilesList.any((profile) => profile.slug == widget.author.authorSlug);
|
||||||
|
if (isBlocked) {
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Вы не можете отправить сообщение заблокированному пользователю'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final picker = ImagePicker();
|
final picker = ImagePicker();
|
||||||
XFile? image = await picker.pickImage(source: ImageSource.camera);
|
List<XFile>? images = await picker.pickMultiImage();
|
||||||
if (image != null) {
|
if (images.isNotEmpty) {
|
||||||
|
List<File> files = images.map((image) => File(image.path)).toList();
|
||||||
await sl<ChatRepository>().sendMessage(
|
await sl<ChatRepository>().sendMessage(
|
||||||
files: [File(image.path)],
|
files: files,
|
||||||
slug: widget.author.authorSlug,
|
slug: widget.author.authorSlug,
|
||||||
);
|
);
|
||||||
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
||||||
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
if (mounted) {
|
||||||
'chatScreen',
|
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
||||||
extra: {
|
'chatScreen',
|
||||||
'chatId': chatIdOrError,
|
extra: {
|
||||||
},
|
'uuid': chatIdOrError,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Row(
|
child: const Row(
|
||||||
@@ -211,12 +261,14 @@ class _EmptyChatScreenState extends State<EmptyChatScreen> {
|
|||||||
slug: widget.author.authorSlug,
|
slug: widget.author.authorSlug,
|
||||||
);
|
);
|
||||||
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
||||||
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
if (mounted) {
|
||||||
'chatScreen',
|
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
||||||
extra: {
|
'chatScreen',
|
||||||
'chatId': chatIdOrError,
|
extra: {
|
||||||
},
|
'uuid': chatIdOrError,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Row(
|
child: const Row(
|
||||||
@@ -261,12 +313,14 @@ class _EmptyChatScreenState extends State<EmptyChatScreen> {
|
|||||||
slug: widget.author.authorSlug,
|
slug: widget.author.authorSlug,
|
||||||
);
|
);
|
||||||
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
final chatIdOrError = await sl<ChatRepository>().getChatByUserSlug(widget.author.authorSlug);
|
||||||
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
if (mounted) {
|
||||||
'chatScreen',
|
AppRouter.navigatorKey.currentContext?.pushReplacementNamed(
|
||||||
extra: {
|
'chatScreen',
|
||||||
'chatId': chatIdOrError,
|
extra: {
|
||||||
},
|
'uuid': chatIdOrError,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Row(
|
child: const Row(
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:dismissible_page/dismissible_page.dart';
|
import 'package:dismissible_page/dismissible_page.dart';
|
||||||
import 'package:eatvio_app/core/const.dart';
|
import 'package:eatvio_app/core/const.dart';
|
||||||
@@ -11,7 +9,7 @@ import 'package:photo_view/photo_view_gallery.dart';
|
|||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class PhotoViewScreen extends StatefulWidget {
|
class PhotoViewScreen extends StatefulWidget {
|
||||||
final List<String> imageUrls;
|
final List<dynamic> imageUrls;
|
||||||
final int index;
|
final int index;
|
||||||
final bool isLocal;
|
final bool isLocal;
|
||||||
|
|
||||||
@@ -50,14 +48,12 @@ class _PhotoViewScreenState extends State<PhotoViewScreen> {
|
|||||||
),
|
),
|
||||||
scrollPhysics: const BouncingScrollPhysics(),
|
scrollPhysics: const BouncingScrollPhysics(),
|
||||||
builder: (BuildContext context, int index) {
|
builder: (BuildContext context, int index) {
|
||||||
|
final imageProvider = widget.isLocal
|
||||||
|
? FileImage(widget.imageUrls[index]) as ImageProvider<Object>
|
||||||
|
: CachedNetworkImageProvider(widget.imageUrls[index]) as ImageProvider<Object>;
|
||||||
|
|
||||||
return PhotoViewGalleryPageOptions(
|
return PhotoViewGalleryPageOptions(
|
||||||
imageProvider: widget.isLocal
|
imageProvider: imageProvider,
|
||||||
? FileImage(
|
|
||||||
File(widget.imageUrls[index]),
|
|
||||||
) as ImageProvider
|
|
||||||
: CachedNetworkImageProvider(
|
|
||||||
widget.imageUrls[index],
|
|
||||||
),
|
|
||||||
initialScale: PhotoViewComputedScale.contained,
|
initialScale: PhotoViewComputedScale.contained,
|
||||||
minScale: PhotoViewComputedScale.contained,
|
minScale: PhotoViewComputedScale.contained,
|
||||||
heroAttributes: PhotoViewHeroAttributes(
|
heroAttributes: PhotoViewHeroAttributes(
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:dismissible_page/dismissible_page.dart';
|
import 'package:dismissible_page/dismissible_page.dart';
|
||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||||
|
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||||
|
import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart';
|
||||||
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
|
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
|
||||||
|
import 'package:eatvio_app/features/chat/presentation/widgets/message_action_bottom_sheet.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class ChatBubbleWidget extends StatelessWidget {
|
class ChatBubbleWidget extends StatelessWidget {
|
||||||
@@ -15,6 +22,9 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
required this.isCurrentUser,
|
required this.isCurrentUser,
|
||||||
required this.mediaData,
|
required this.mediaData,
|
||||||
required this.isRead,
|
required this.isRead,
|
||||||
|
required this.messageState,
|
||||||
|
required this.messageUuid,
|
||||||
|
required this.userSlug
|
||||||
});
|
});
|
||||||
|
|
||||||
final DateTime sendTime;
|
final DateTime sendTime;
|
||||||
@@ -22,7 +32,9 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
final bool isCurrentUser;
|
final bool isCurrentUser;
|
||||||
final bool isRead;
|
final bool isRead;
|
||||||
final List<dynamic> mediaData;
|
final List<dynamic> mediaData;
|
||||||
|
final MessageState messageState;
|
||||||
|
final String messageUuid;
|
||||||
|
final String userSlug;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final size = MediaQuery.sizeOf(context);
|
final size = MediaQuery.sizeOf(context);
|
||||||
@@ -36,17 +48,33 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
mainAxisAlignment: isCurrentUser ? MainAxisAlignment.end : MainAxisAlignment.start,
|
mainAxisAlignment: isCurrentUser ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (isCurrentUser)
|
if (isCurrentUser)
|
||||||
Padding(
|
switch (messageState) {
|
||||||
padding: const EdgeInsets.only(right: 4, bottom: 4),
|
MessageState.loading => Padding(
|
||||||
child: Text(
|
padding: const EdgeInsets.only(right: 4, bottom: 4),
|
||||||
sendTime.format('HH:mm', 'ru'),
|
child: SizedBox(width: 10, height: 10, child: CircularProgressIndicator(strokeWidth: 2, color: appTheme.blueA400)),
|
||||||
style: const TextStyle(
|
|
||||||
color: Color(0xFF7B8794),
|
|
||||||
height: 1,
|
|
||||||
fontSize: 10,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
|
MessageState.sent => Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 4, bottom: 4),
|
||||||
|
child: Text(sendTime.format('HH:mm', 'ru'), style: const TextStyle(color: Color(0xFF7B8794), height: 1, fontSize: 10)),
|
||||||
|
),
|
||||||
|
|
||||||
|
MessageState.error => GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
showMessageActionsBottomSheet(
|
||||||
|
context,
|
||||||
|
resend: () {
|
||||||
|
context.read<ChatRoomCubit>().resendMessage(uuid: messageUuid, userSlug: userSlug);
|
||||||
|
},
|
||||||
|
delete: () {
|
||||||
|
context.read<ChatRoomCubit>().deleteMessage(messageUuid);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Padding(padding: const EdgeInsets.only(right: 4, bottom: 4), child: SvgPicture.asset('assets/icons/error_icon.svg')),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
constraints: BoxConstraints(maxWidth: size.width * 0.7),
|
constraints: BoxConstraints(maxWidth: size.width * 0.7),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -59,8 +87,9 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: mediaData.isNotEmpty
|
||||||
mediaData.isNotEmpty ? const EdgeInsets.all(8) : EdgeInsets.only(top: 8, bottom: 8, left: isCurrentUser ? 16 : 8, right: isCurrentUser ? 8 : 16),
|
? const EdgeInsets.all(8)
|
||||||
|
: EdgeInsets.only(top: 8, bottom: 8, left: isCurrentUser ? 16 : 8, right: isCurrentUser ? 8 : 16),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: isCurrentUser ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
crossAxisAlignment: isCurrentUser ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -84,32 +113,19 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
throw Exception('Could not launch ${mediaData[index].toString()}');
|
throw Exception('Could not launch ${mediaData[index].toString()}');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leading: const Icon(
|
leading: const Icon(Icons.file_copy_outlined, color: Colors.black),
|
||||||
Icons.file_copy_outlined,
|
trailing: const Icon(Icons.download_outlined, color: Colors.black),
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
trailing: const Icon(
|
|
||||||
Icons.download_outlined,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
title: Text(
|
title: Text(
|
||||||
mediaData[index].toString().replaceAll('chat_files/', ''),
|
mediaData[index].toString().replaceAll('chat_files/', ''),
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Colors.black, fontSize: 12, overflow: TextOverflow.ellipsis),
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 12,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.pushTransparentRoute(
|
context.pushTransparentRoute(
|
||||||
PhotoViewScreen(
|
PhotoViewScreen(imageUrls: mediaData, index: index, isLocal: mediaData[index] is File ? true : false),
|
||||||
imageUrls: mediaData.map((e) => '$e').toList(),
|
|
||||||
index: index,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Hero(
|
child: Hero(
|
||||||
@@ -117,9 +133,7 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
transitionOnUserGestures: true,
|
transitionOnUserGestures: true,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: CachedNetworkImage(
|
child: mediaData[index] is File ? Image.file(mediaData[index]) : CachedNetworkImage(imageUrl: '${mediaData[index]}'),
|
||||||
imageUrl: '${mediaData[index]}',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -131,11 +145,7 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (mediaData.isNotEmpty && text.isNotEmpty) const SizedBox(height: 8),
|
if (mediaData.isNotEmpty && text.isNotEmpty) const SizedBox(height: 8),
|
||||||
if (text.isNotEmpty)
|
if (text.isNotEmpty) Text(text, style: TextStyles.textFS13FW400.copyWith(color: appTheme.black, fontSize: 16)),
|
||||||
Text(
|
|
||||||
text,
|
|
||||||
style: TextStyles.textFS13FW400.copyWith(color: appTheme.black, fontSize: 16),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -145,12 +155,7 @@ class ChatBubbleWidget extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(left: 4, bottom: 4),
|
padding: const EdgeInsets.only(left: 4, bottom: 4),
|
||||||
child: Text(
|
child: Text(
|
||||||
sendTime.format('HH:mm', 'ru'),
|
sendTime.format('HH:mm', 'ru'),
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Color(0xFF7B8794), height: 1, fontSize: 10, fontWeight: FontWeight.w500),
|
||||||
color: Color(0xFF7B8794),
|
|
||||||
height: 1,
|
|
||||||
fontSize: 10,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class _ChatEntryWidgetState extends State<ChatEntryWidget> {
|
|||||||
onTap: () => GoRouter.of(context).pushNamed(
|
onTap: () => GoRouter.of(context).pushNamed(
|
||||||
'chatScreen',
|
'chatScreen',
|
||||||
extra: {
|
extra: {
|
||||||
'chatId': widget.chatRoom.id.toString(),
|
'uuid': widget.chatRoom.id.toString(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/bottom_sheet_action_widget.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/custom_divider.dart';
|
||||||
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
void showMessageActionsBottomSheet(BuildContext context, {required void Function() resend, required void Function() delete}) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
builder: (context) => Container(
|
||||||
|
margin: EdgeInsets.only(left: 8, right: 8, bottom: MediaQuery.of(context).padding.bottom + 20),
|
||||||
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: appTheme.whiteA700),
|
||||||
|
child: MessageActionsBottomSheet(resend: resend, delete: delete),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessageActionsBottomSheet extends StatefulWidget {
|
||||||
|
const MessageActionsBottomSheet({super.key, required this.resend, required this.delete});
|
||||||
|
final void Function() resend;
|
||||||
|
final void Function() delete;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MessageActionsBottomSheet> createState() => _MessageActionsBottomSheet();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MessageActionsBottomSheet extends State<MessageActionsBottomSheet> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = S.of(context);
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 7),
|
||||||
|
const BottomSheetHandlerBar(),
|
||||||
|
BottomSheetActionWidget(text: s.resend, iconPath: 'assets/icons/resend.svg', onTap: widget.resend),
|
||||||
|
const CustomDivider(),
|
||||||
|
BottomSheetActionWidget(text: s.delete, iconPath: 'assets/icons/trash_can.svg', onTap: widget.delete, color: appTheme.red),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:eatvio_app/core/token_storage.dart';
|
||||||
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||||
import 'package:eatvio_app/features/chat/models/chat_messages_model.dart';
|
import 'package:eatvio_app/features/chat/models/chat_messages_model.dart';
|
||||||
import 'package:eatvio_app/features/chat/models/chat_room_model.dart';
|
import 'package:eatvio_app/features/chat/models/chat_room_model.dart';
|
||||||
@@ -47,10 +48,11 @@ class ChatRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await chatService.sendMessageByUserSlug(
|
await chatService.sendMessage(
|
||||||
userSlug: slug,
|
slug: slug,
|
||||||
data: data,
|
data: data,
|
||||||
mediaData: multipartFiles.isEmpty ? null : multipartFiles,
|
mediaData: multipartFiles.isEmpty ? null : multipartFiles,
|
||||||
|
socketId: (await SocketIdStorage.getSocketIdFromStorage())!,
|
||||||
);
|
);
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
log(e.toString(), stackTrace: st);
|
log(e.toString(), stackTrace: st);
|
||||||
@@ -58,10 +60,11 @@ class ChatRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ChatRoomModel> getChatRoom(String chatId) async {
|
Future<ChatRoomModel> getChatRoom(String uuid) async {
|
||||||
try {
|
try {
|
||||||
return (await chatService.getChatRoom(id: chatId))['chatRoom']!;
|
return (await chatService.getChatRoom(uuid: uuid));
|
||||||
} catch (e) {
|
} catch (e, st) {
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,9 +77,9 @@ class ChatRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ChatMessagesModel> getChatMessages(String chatId, int page) async {
|
Future<ChatMessagesModel> getChatMessages(String id, int page) async {
|
||||||
try {
|
try {
|
||||||
return (await chatService.getChatMessages(id: chatId, page: page));
|
return (await chatService.getChatMessages(id: id, page: page));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
@@ -90,9 +93,9 @@ class ChatRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> markMessagesAsRead(String chatId, List<int> messageIds) async {
|
Future<void> markMessagesAsRead(String id, List<int> messageIds) async {
|
||||||
try {
|
try {
|
||||||
await chatService.markMessagesAsRead(id: chatId, body: {'messages_ids': messageIds});
|
await chatService.markMessagesAsRead(id: id, body: {'messages_ids': messageIds});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,32 +13,33 @@ part 'chat_service.g.dart';
|
|||||||
abstract class ChatService {
|
abstract class ChatService {
|
||||||
factory ChatService(Dio dio, {String baseUrl}) = _ChatService;
|
factory ChatService(Dio dio, {String baseUrl}) = _ChatService;
|
||||||
|
|
||||||
@GET('/api/chat/index')
|
@GET('/api/v2/chat/index')
|
||||||
Future<ChatRoomPaginationModel> getChatRooms({
|
Future<ChatRoomPaginationModel> getChatRooms({
|
||||||
@Query('page') required int page,
|
@Query('page') required int page,
|
||||||
@Query('find') String? query,
|
@Query('filters[data][\$conversation_name]') String? query,
|
||||||
});
|
});
|
||||||
|
|
||||||
@GET('/api/chat/show/{id}')
|
@GET('/api/v2/chat/show/{uuid}')
|
||||||
Future<Map<String, ChatRoomModel>> getChatRoom({
|
Future<ChatRoomModel> getChatRoom({
|
||||||
@Path() required String id,
|
@Path() required String uuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
@POST('/api/v2/chat/message/send/{id}')
|
@POST('/api/v2/chat/message/send/{slug}')
|
||||||
@MultiPart()
|
@MultiPart()
|
||||||
Future<void> sendMessage({
|
Future<void> sendMessage({
|
||||||
@Path() required String id,
|
@Header('X-Socket-ID') required String socketId,
|
||||||
|
@Path() required String slug,
|
||||||
@Part() String? data,
|
@Part() String? data,
|
||||||
@Part(name: 'media_data[]', contentType: 'multipart/form-data') List<MultipartFile>? mediaData,
|
@Part(name: 'media_data[]', contentType: 'multipart/form-data') List<MultipartFile>? mediaData,
|
||||||
});
|
});
|
||||||
|
|
||||||
@GET('/api/chat/show/{id}/messages?page={page}')
|
@GET('/api/v2/chat/show/{id}/messages?page={page}')
|
||||||
Future<ChatMessagesModel> getChatMessages({
|
Future<ChatMessagesModel> getChatMessages({
|
||||||
@Path() required String id,
|
@Path() required String id,
|
||||||
@Path() required int page,
|
@Path() required int page,
|
||||||
});
|
});
|
||||||
|
|
||||||
@GET('/api/chat/get_by_user/{user}')
|
@GET('/api/v2/chat/get_by_user/{user}')
|
||||||
Future<ChatRoomModel> getChatRoomIdByUserSlug({
|
Future<ChatRoomModel> getChatRoomIdByUserSlug({
|
||||||
@Path() required String user,
|
@Path() required String user,
|
||||||
});
|
});
|
||||||
@@ -81,16 +82,8 @@ abstract class ChatService {
|
|||||||
@Body() required PlanComplainModel body,
|
@Body() required PlanComplainModel body,
|
||||||
});
|
});
|
||||||
|
|
||||||
@GET('/api/v2/chat/get_by_user/{slug}')
|
@GET('/api/chat/get_by_user/{slug}')
|
||||||
Future<HttpResponse> getChatByUserSlug({
|
Future<HttpResponse> getChatByUserSlug({
|
||||||
@Path() required String slug,
|
@Path() required String slug,
|
||||||
});
|
});
|
||||||
|
|
||||||
@POST('/api/v2/chat/message/send/{userSlug}')
|
|
||||||
@MultiPart()
|
|
||||||
Future<void> sendMessageByUserSlug({
|
|
||||||
@Path() required String userSlug,
|
|
||||||
@Part() String? data,
|
|
||||||
@Part(name: 'media_data[]', contentType: 'multipart/form-data') List<MultipartFile>? mediaData,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
|
|||||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||||
import 'package:eatvio_app/features/complaining/presentation/cubit/complaining_cubit.dart';
|
import 'package:eatvio_app/features/complaining/presentation/cubit/complaining_cubit.dart';
|
||||||
import 'package:eatvio_app/features/complaining/presentation/cubit/complaining_state.dart';
|
import 'package:eatvio_app/features/complaining/presentation/cubit/complaining_state.dart';
|
||||||
|
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@@ -194,63 +195,74 @@ class _LawViolationWidgetState extends State<_LawViolationWidget> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
return Column(
|
return BlocBuilder<ComplainingCubit, ComplainingState>(
|
||||||
mainAxisSize: MainAxisSize.min,
|
builder: (context, state) {
|
||||||
children: [
|
return Column(
|
||||||
const BottomSheetHandlerBar(),
|
mainAxisSize: MainAxisSize.min,
|
||||||
const SizedBox(height: 20),
|
children: [
|
||||||
Text(
|
const BottomSheetHandlerBar(),
|
||||||
s.lawViolation,
|
const SizedBox(height: 20),
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
Text(
|
||||||
),
|
s.lawViolation,
|
||||||
const SizedBox(height: 8),
|
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||||
SizedBox(
|
),
|
||||||
width: MediaQuery.sizeOf(context).width * 0.7,
|
const SizedBox(height: 8),
|
||||||
child: Text(
|
SizedBox(
|
||||||
s.what_do_you_want_to_complaint_about,
|
width: MediaQuery.sizeOf(context).width * 0.7,
|
||||||
textAlign: TextAlign.center,
|
child: Text(
|
||||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
s.what_do_you_want_to_complaint_about,
|
||||||
),
|
textAlign: TextAlign.center,
|
||||||
),
|
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||||
const SizedBox(height: 24),
|
),
|
||||||
...tags.mapIndexed((index, element) {
|
),
|
||||||
return Row(
|
const SizedBox(height: 24),
|
||||||
children: [
|
...tags.mapIndexed((index, element) {
|
||||||
Checkbox(
|
return Row(
|
||||||
activeColor: appTheme.blueA400,
|
children: [
|
||||||
side: BorderSide(width: 2, color: tags[index].$1 ? appTheme.blueA400 : appTheme.blueGray),
|
Checkbox(
|
||||||
value: element.$1,
|
activeColor: appTheme.blueA400,
|
||||||
onChanged: (isChecked) {
|
side: BorderSide(width: 2, color: tags[index].$1 ? appTheme.blueA400 : appTheme.blueGray),
|
||||||
setState(() {
|
value: element.$1,
|
||||||
if (isChecked == null) return;
|
onChanged: (isChecked) {
|
||||||
if (index == tags.length - 1 && !isChecked) {
|
setState(() {
|
||||||
context.read<ComplainingCubit>().toggleDescription();
|
if (isChecked == null) return;
|
||||||
}
|
if (index == tags.length - 1 && !isChecked) {
|
||||||
tags[index] = (isChecked, element.$2);
|
context.read<ComplainingCubit>().toggleDescription();
|
||||||
final activeTags = tags.where((elem) => elem.$1).map((e) => e.$2).toList();
|
}
|
||||||
context.read<ComplainingCubit>().setTags(activeTags);
|
tags[index] = (isChecked, element.$2);
|
||||||
});
|
final activeTags = tags.where((elem) => elem.$1).map((e) => e.$2).toList();
|
||||||
|
context.read<ComplainingCubit>().setTags(activeTags);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
element.$2,
|
||||||
|
style: TextStyles.textLSemibold.copyWith(color: appTheme.black),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
if (tags.last.$1) ...[
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
CustomTextFormField(
|
||||||
|
hintText: s.type_here_your_complaint,
|
||||||
|
hasError: (state.complainInfo.description?.length ?? 10) < 10,
|
||||||
|
onChanged: (value) {
|
||||||
|
context.read<ComplainingCubit>().setDescription(value);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(
|
if ((state.complainInfo.description?.length ?? 10) < 10) ...[
|
||||||
element.$2,
|
const SizedBox(height: 4),
|
||||||
style: TextStyles.textLSemibold.copyWith(color: appTheme.black),
|
const ValidationErrorWidget(error: 'Минимум 10 символов'),
|
||||||
),
|
]
|
||||||
],
|
],
|
||||||
);
|
const SizedBox(height: 20),
|
||||||
}),
|
_ComplainButton(
|
||||||
if (tags.last.$1) ...[
|
isDisabled: (state.complainInfo.description?.length ?? 0) < 10,
|
||||||
const SizedBox(height: 12),
|
),
|
||||||
CustomTextFormField(
|
],
|
||||||
hintText: s.type_here_your_complaint,
|
);
|
||||||
onChanged: (value) {
|
},
|
||||||
context.read<ComplainingCubit>().setDescription(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
const _ComplainButton(),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -515,8 +527,8 @@ class _ComplaintFailedWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ComplainButton extends StatelessWidget {
|
class _ComplainButton extends StatelessWidget {
|
||||||
const _ComplainButton();
|
const _ComplainButton({this.isDisabled = false});
|
||||||
|
final bool isDisabled;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
@@ -534,6 +546,10 @@ class _ComplainButton extends StatelessWidget {
|
|||||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
if (isDisabled) {
|
||||||
|
context.read<ComplainingCubit>().setDescription('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
await context.read<ComplainingCubit>().complain();
|
await context.read<ComplainingCubit>().complain();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ class ComplainingCubit extends Cubit<ComplainingState> {
|
|||||||
emit(state.copyWith(wasSentSuccessfully: true));
|
emit(state.copyWith(wasSentSuccessfully: true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case ComplainedContent.comment:
|
||||||
|
if (id != null) {
|
||||||
|
await repository.sendCommentComplain(id: id, category: category.getValue(), body: state.complainInfo);
|
||||||
|
emit(state.copyWith(wasSentSuccessfully: true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
|
|||||||
@@ -64,4 +64,16 @@ class ComplainingRepository {
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> sendCommentComplain({
|
||||||
|
required int id,
|
||||||
|
required String category,
|
||||||
|
required ComplainModel body,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
await service.sendCommentComplain(id: id, category: category, body: body);
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,5 +42,12 @@ abstract class ComplainingService {
|
|||||||
@Path() required String category,
|
@Path() required String category,
|
||||||
@Body() required ComplainModel body,
|
@Body() required ComplainModel body,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@POST('/api/comments/{id}/complain/{category}')
|
||||||
|
Future<void> sendCommentComplain({
|
||||||
|
@Path() required int id,
|
||||||
|
@Path() required String category,
|
||||||
|
@Body() required ComplainModel body,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,24 +25,16 @@ class _LastStepScreenState extends State<LastStepScreen> {
|
|||||||
children: [
|
children: [
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Text(
|
child: Text('Последний шаг', style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, height: 1.1)),
|
||||||
'Последний шаг',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
height: 1.1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
CheckboxListTile(
|
CheckboxListTile(
|
||||||
value: checkboxState,
|
value: checkboxState,
|
||||||
title: const Text(
|
title: Text(
|
||||||
'Я ознакомлен и принимаю договор публичной офёрты',
|
hidePlans
|
||||||
style: TextStyle(
|
? 'Я ознакомлен и принимаю политику конфиденциальности и защиту персональных данных'
|
||||||
fontSize: 18,
|
: 'Я ознакомлен и принимаю договор публичной офёрты',
|
||||||
height: 1,
|
style: const TextStyle(fontSize: 18, height: 1),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onChanged: (_) {
|
onChanged: (_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -53,25 +45,14 @@ class _LastStepScreenState extends State<LastStepScreen> {
|
|||||||
activeColor: appTheme.blueA400,
|
activeColor: appTheme.blueA400,
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), child: _divider(context)),
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 16,
|
|
||||||
vertical: 16,
|
|
||||||
),
|
|
||||||
child: _divider(context),
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () async => await launchUrl(Uri.parse('$baseUrl/oferta_bs.pdf')),
|
onPressed: () async => await launchUrl(Uri.parse(hidePlans ? '$baseUrl/docs/privacy.pdf' : '$baseUrl/oferta_bs.pdf')),
|
||||||
child: const Text(
|
child: Text(
|
||||||
'Договор офёрты',
|
hidePlans ? 'Политика конфиденциальности и пользовательское соглашение' : 'Договор офёрты',
|
||||||
style: TextStyle(
|
style: const TextStyle(height: 1, fontSize: 16, color: Color(0xFF323F4B), decoration: TextDecoration.underline),
|
||||||
height: 1,
|
|
||||||
fontSize: 16,
|
|
||||||
color: Color(0xFF323F4B),
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -84,10 +65,7 @@ class _LastStepScreenState extends State<LastStepScreen> {
|
|||||||
return Container(
|
return Container(
|
||||||
height: 0.4,
|
height: 0.4,
|
||||||
width: MediaQuery.of(context).size.width - 32,
|
width: MediaQuery.of(context).size.width - 32,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(color: Colors.black26, borderRadius: BorderRadius.circular(16)),
|
||||||
color: Colors.black26,
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,81 +23,105 @@ class _RegistrationAsScreenState extends State<RegistrationAsScreen> {
|
|||||||
children: [
|
children: [
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Text(
|
child: Text('Регистрация в качестве', style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, height: 1.1)),
|
||||||
'Регистрация в качестве',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
height: 1.1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
RadioListTile<RegistrationAsType>(
|
Column(
|
||||||
value: RegistrationAsType.physical,
|
children: [
|
||||||
groupValue: registrationAsType,
|
Row(
|
||||||
title: const Text(
|
children: [
|
||||||
'Физического лица',
|
Radio<RegistrationAsType>(
|
||||||
style: TextStyle(
|
value: RegistrationAsType.physical,
|
||||||
fontSize: 18,
|
// ignore: deprecated_member_use
|
||||||
height: 1,
|
groupValue: registrationAsType,
|
||||||
|
activeColor: appTheme.blueA400,
|
||||||
|
// ignore: deprecated_member_use
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
registrationAsType = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: Text('Физического лица', style: TextStyle(fontSize: 18, height: 1)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
Row(
|
||||||
activeColor: appTheme.blueA400,
|
children: [
|
||||||
onChanged: (value) {},
|
Radio<RegistrationAsType>(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
value: RegistrationAsType.selfBusy,
|
||||||
),
|
// ignore: deprecated_member_use
|
||||||
RadioListTile<RegistrationAsType>(
|
groupValue: registrationAsType,
|
||||||
value: RegistrationAsType.selfBusy,
|
activeColor: appTheme.blueA400,
|
||||||
groupValue: registrationAsType,
|
// ignore: deprecated_member_use
|
||||||
title: const Text(
|
onChanged: (value) {
|
||||||
'Самозанятого',
|
setState(() {
|
||||||
style: TextStyle(
|
registrationAsType = value!;
|
||||||
fontSize: 18,
|
});
|
||||||
height: 1,
|
},
|
||||||
|
),
|
||||||
|
const Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: Text('Самозанятого', style: TextStyle(fontSize: 18, height: 1)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
Row(
|
||||||
onChanged: null,
|
children: [
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
Radio<RegistrationAsType>(
|
||||||
),
|
value: RegistrationAsType.iP,
|
||||||
RadioListTile<RegistrationAsType>(
|
// ignore: deprecated_member_use
|
||||||
value: RegistrationAsType.iP,
|
groupValue: registrationAsType,
|
||||||
groupValue: registrationAsType,
|
activeColor: appTheme.blueA400,
|
||||||
title: const Text(
|
// ignore: deprecated_member_use
|
||||||
'Индивидуального предпринимателя',
|
onChanged: (value) {
|
||||||
style: TextStyle(
|
setState(() {
|
||||||
fontSize: 18,
|
registrationAsType = value!;
|
||||||
height: 1,
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: Text('Индивидуального предпринимателя', style: TextStyle(fontSize: 18, height: 1)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
Row(
|
||||||
onChanged: null,
|
children: [
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
Radio<RegistrationAsType>(
|
||||||
),
|
value: RegistrationAsType.ooo,
|
||||||
RadioListTile<RegistrationAsType>(
|
// ignore: deprecated_member_use
|
||||||
value: RegistrationAsType.ooo,
|
groupValue: registrationAsType,
|
||||||
groupValue: registrationAsType,
|
activeColor: appTheme.blueA400,
|
||||||
title: const Text(
|
// ignore: deprecated_member_use
|
||||||
'Общества с ограниченной ответственностью',
|
onChanged: (value) {
|
||||||
style: TextStyle(
|
setState(() {
|
||||||
fontSize: 18,
|
registrationAsType = value!;
|
||||||
height: 1,
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: Text('Общества с ограниченной ответственностью', style: TextStyle(fontSize: 18, height: 1)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
onChanged: null,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 16,
|
|
||||||
vertical: 16,
|
|
||||||
),
|
|
||||||
child: _divider(context),
|
|
||||||
),
|
),
|
||||||
|
Padding(padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), child: _divider(context)),
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Text(
|
child: Text('* На данный момент регистрация доступна только в качестве физического лица. Остальные варианты скоро появятся'),
|
||||||
'* На данный момент регистрация доступна только в качестве физического лица. Остальные варианты скоро появятся',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -108,10 +132,7 @@ class _RegistrationAsScreenState extends State<RegistrationAsScreen> {
|
|||||||
return Container(
|
return Container(
|
||||||
height: 0.4,
|
height: 0.4,
|
||||||
width: MediaQuery.of(context).size.width - 32,
|
width: MediaQuery.of(context).size.width - 32,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(color: Colors.black26, borderRadius: BorderRadius.circular(16)),
|
||||||
color: Colors.black26,
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,42 @@
|
|||||||
|
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
part 'rating_model.freezed.dart';
|
part 'rating_model.freezed.dart';
|
||||||
part 'rating_model.g.dart';
|
part 'rating_model.g.dart';
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
abstract class RatingModel with _$RatingModel {
|
abstract class RatingPaginationModel with _$RatingPaginationModel {
|
||||||
|
factory RatingPaginationModel({
|
||||||
|
required List<RatingModel> data,
|
||||||
|
}) = _RatingPaginationModel;
|
||||||
|
|
||||||
|
factory RatingPaginationModel.fromJson(Map<String, dynamic> json) => _$RatingPaginationModelFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class RatingModel with _$RatingModel {
|
||||||
factory RatingModel({
|
factory RatingModel({
|
||||||
required DateTime date,
|
@JsonKey(name: 'created_at', fromJson: parseDate) required DateTime date,
|
||||||
required String title,
|
@JsonKey(name: 'log_data') required RatingEnum type,
|
||||||
required int amount,
|
@JsonKey(name: 'log_scores') required int amount,
|
||||||
}) = _RatingModel;
|
}) = _RatingModel;
|
||||||
|
|
||||||
factory RatingModel.fromJson(Map<String, dynamic> json) => _$RatingModelFromJson(json);
|
factory RatingModel.fromJson(Map<String, dynamic> json) => _$RatingModelFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum RatingEnum {
|
||||||
|
@JsonValue('ADDED_RECIPE')
|
||||||
|
addedRecipe,
|
||||||
|
@JsonValue('ADDED_PUBLIC_DIET')
|
||||||
|
addedPublicDiet,
|
||||||
|
@JsonValue('ADDED_BLOG_POST')
|
||||||
|
addedBlogPost,
|
||||||
|
@JsonValue('INVITED_A_NEW_USER')
|
||||||
|
invitedUser,
|
||||||
|
@JsonValue('HAS_MEDICAL_DEGREE')
|
||||||
|
hasMedicalDegree,
|
||||||
|
@JsonValue('CONSULTED')
|
||||||
|
consulted,
|
||||||
|
@JsonValue('PRODUCT_NUTRITINAL_VALUE_APPROVED')
|
||||||
|
addedGlossary;
|
||||||
|
}
|
||||||
|
|||||||
19
lib/features/consultant_rating/models/statistics_model.dart
Normal file
19
lib/features/consultant_rating/models/statistics_model.dart
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'statistics_model.freezed.dart';
|
||||||
|
part 'statistics_model.g.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class StatisticsModel with _$StatisticsModel {
|
||||||
|
|
||||||
|
factory StatisticsModel({
|
||||||
|
@JsonKey(name: 'count_referal') int? countReferal,
|
||||||
|
@JsonKey(name: 'count_blog_posts') int? blogPostsCount,
|
||||||
|
@JsonKey(name: 'count_recipes') int? recipesCount,
|
||||||
|
@JsonKey(name: 'count_diets') int? dietsCount,
|
||||||
|
@JsonKey(name: 'count_consultants') int? consultationsCount,
|
||||||
|
@JsonKey(name: 'count_products_nutritional_values') int? qwe,
|
||||||
|
}) = _StatisticsModel;
|
||||||
|
|
||||||
|
factory StatisticsModel.fromJson(Map<String, dynamic> json) => _$StatisticsModelFromJson(json);
|
||||||
|
}
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
|
import 'package:eatvio_app/core/locator_service.dart';
|
||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
|
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/presentation/cubit/consultant_rating_cubit.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/presentation/cubit/consultant_rating_state.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/rating_history_widget.dart';
|
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/rating_history_widget.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/rating_widget.dart';
|
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/rating_widget.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/statistic_widget.dart';
|
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/statistic_widget.dart';
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class ConsultantRatingScreen extends StatelessWidget {
|
class ConsultantRatingScreen extends StatelessWidget {
|
||||||
static const name = 'consultantRatingScreen';
|
static const name = 'consultantRatingScreen';
|
||||||
@@ -15,7 +19,10 @@ class ConsultantRatingScreen extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const ConsultantRatingPageContent();
|
return BlocProvider<ConsultantRatingCubit>(
|
||||||
|
create: (context) => sl<ConsultantRatingCubit>()..getConsultantStatistics()..getScoreLogs(),
|
||||||
|
child: const ConsultantRatingPageContent(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,52 +32,56 @@ class ConsultantRatingPageContent extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
return Scaffold(
|
return BlocBuilder<ConsultantRatingCubit, ConsultantRatingState>(
|
||||||
backgroundColor: appTheme.gray100,
|
builder: (context, state) {
|
||||||
appBar: AppBar(
|
return Scaffold(
|
||||||
centerTitle: true,
|
backgroundColor: appTheme.gray100,
|
||||||
title: Text(
|
appBar: AppBar(
|
||||||
s.rating_and_statistics,
|
centerTitle: true,
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
title: Text(
|
||||||
),
|
s.rating_and_statistics,
|
||||||
),
|
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const RatingWidget(
|
|
||||||
rating: 1058,
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
),
|
||||||
Padding(
|
body: state.error != null
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
? DataErrorWidget(onReload: () async {
|
||||||
child: CustomOutlinedButton(
|
await context.read<ConsultantRatingCubit>().getConsultantStatistics();
|
||||||
text: s.copy_referral_link,
|
if (!context.mounted) return;
|
||||||
height: 52,
|
await context.read<ConsultantRatingCubit>().getScoreLogs();
|
||||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
})
|
||||||
buttonStyle: ButtonStyle(
|
: SingleChildScrollView(
|
||||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
child: Column(
|
||||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
children: [
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
const RatingWidget(
|
||||||
|
rating: 1058,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: CustomOutlinedButton(
|
||||||
|
text: s.copy_referral_link,
|
||||||
|
height: 52,
|
||||||
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||||
|
buttonStyle: ButtonStyle(
|
||||||
|
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||||
|
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||||
|
),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
StatisticWidget(isLoading: state.isStatisticsLoading, statistics: state.statistics,),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
RatingHistoryWidget(
|
||||||
|
isLoading: state.isRatingLoading,
|
||||||
|
ratingHistory: state.ratings,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
);
|
||||||
),
|
},
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const StatisticWidget(),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
RatingHistoryWidget(
|
|
||||||
ratingHistory: [
|
|
||||||
RatingModel(date: DateTime.now(), title: ' djkasjdasjkdkjasjkdjkaskjdjklasjkld', amount: 201300),
|
|
||||||
RatingModel(date: DateTime.now(), title: 'djkasjdasjkdkjasjkdjkaskjdjklasjkld', amount: 89323),
|
|
||||||
RatingModel(date: DateTime.now(), title: 'djkasjdasjkdkjasjkdjkaskjdjklasjkld', amount: 20),
|
|
||||||
RatingModel(date: DateTime.now(), title: 'djkasjdasjkdkjasjkdjkaskjdjklasjkld', amount: 1212),
|
|
||||||
RatingModel(date: DateTime.now(), title: 'qweqweeq', amount: 323),
|
|
||||||
RatingModel(date: DateTime.now(), title: 'ee', amount: 1),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/presentation/cubit/consultant_rating_state.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/repositories/consultant_rating_repository.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
class ConsultantRatingCubit extends Cubit<ConsultantRatingState> {
|
||||||
|
final ConsultantRatingRepository repository;
|
||||||
|
ConsultantRatingCubit(this.repository) : super(ConsultantRatingState());
|
||||||
|
|
||||||
|
Future<void> getConsultantStatistics({String? date}) async {
|
||||||
|
try {
|
||||||
|
emit(state.copyWith(isStatisticsLoading: true));
|
||||||
|
final statistics = await repository.getConsultantStatistics(date: date);
|
||||||
|
emit(state.copyWith(isStatisticsLoading: false, statistics: statistics, error: null));
|
||||||
|
} catch (e, st) {
|
||||||
|
emit(state.copyWith(isStatisticsLoading: true, error: e.toString()));
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> getScoreLogs({String? date}) async {
|
||||||
|
try {
|
||||||
|
emit(state.copyWith(isRatingLoading: true));
|
||||||
|
final scoreLogs = await repository.getScoreLogs(date: date);
|
||||||
|
emit(state.copyWith(isRatingLoading: false, ratings: scoreLogs, error: null));
|
||||||
|
} catch (e, st) {
|
||||||
|
emit(state.copyWith(isRatingLoading: true, error: e.toString()));
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/models/statistics_model.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'consultant_rating_state.freezed.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class ConsultantRatingState with _$ConsultantRatingState {
|
||||||
|
factory ConsultantRatingState({
|
||||||
|
@Default(false) bool isStatisticsLoading,
|
||||||
|
@Default(false) bool isRatingLoading,
|
||||||
|
@Default(null) StatisticsModel? statistics,
|
||||||
|
@Default(null) String? error,
|
||||||
|
@Default(<RatingModel>[]) List<RatingModel> ratings,
|
||||||
|
}) = _ConsultantRatingState;
|
||||||
|
}
|
||||||
@@ -1,42 +1,29 @@
|
|||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
|
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||||
import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/presentation/cubit/consultant_rating_cubit.dart';
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class PeriodFilterWidget extends StatefulWidget {
|
class PeriodFilterWidget extends StatefulWidget {
|
||||||
const PeriodFilterWidget({super.key});
|
const PeriodFilterWidget({super.key, required this.isStatistic});
|
||||||
|
final bool isStatistic;
|
||||||
@override
|
@override
|
||||||
State<PeriodFilterWidget> createState() => _PeriodFilterWidgetState();
|
State<PeriodFilterWidget> createState() => _PeriodFilterWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PeriodFilterWidgetState extends State<PeriodFilterWidget> {
|
class _PeriodFilterWidgetState extends State<PeriodFilterWidget> {
|
||||||
final List<String> periodDropDownTitles = [];
|
PeriodFilterStatus _currentState = PeriodFilterStatus.all;
|
||||||
int periodDropDownIndex = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
super.didChangeDependencies();
|
|
||||||
final s = S.of(context);
|
|
||||||
if (periodDropDownTitles.isEmpty) {
|
|
||||||
periodDropDownTitles.addAll([
|
|
||||||
s.for_whole_period_of_time,
|
|
||||||
s.for_a_year,
|
|
||||||
s.for_a_month,
|
|
||||||
s.for_a_week,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
CustomDropDownButton(
|
CustomDropDownButton<PeriodFilterStatus>(
|
||||||
hint: Text(
|
hint: Text(
|
||||||
s.choose_diet_duration,
|
s.choose_diet_duration,
|
||||||
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
|
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
|
||||||
@@ -44,24 +31,59 @@ class _PeriodFilterWidgetState extends State<PeriodFilterWidget> {
|
|||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
periodDropDownIndex = periodDropDownTitles.indexOf(value);
|
_currentState = value;
|
||||||
});
|
});
|
||||||
|
if (widget.isStatistic) {
|
||||||
|
if (value == PeriodFilterStatus.all) {
|
||||||
|
context.read<ConsultantRatingCubit>().getConsultantStatistics();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context.read<ConsultantRatingCubit>().getConsultantStatistics(date: value.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (value == PeriodFilterStatus.all) {
|
||||||
|
context.read<ConsultantRatingCubit>().getScoreLogs();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context.read<ConsultantRatingCubit>().getScoreLogs(date: value.value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
items: periodDropDownTitles
|
items: PeriodFilterStatus.values
|
||||||
.mapIndexed(
|
.mapIndexed(
|
||||||
(index, value) => DropdownMenuItem(
|
(index, value) => DropdownMenuItem(
|
||||||
value: periodDropDownTitles[index],
|
value: PeriodFilterStatus.values[index],
|
||||||
child: Text(
|
child: Text(
|
||||||
periodDropDownTitles[index],
|
PeriodFilterStatus.values[index].name,
|
||||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
value: periodDropDownTitles[periodDropDownIndex],
|
value: _currentState,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum PeriodFilterStatus {
|
||||||
|
all,
|
||||||
|
month,
|
||||||
|
week,
|
||||||
|
year;
|
||||||
|
|
||||||
|
String get name => switch (this) {
|
||||||
|
PeriodFilterStatus.all => 'Все периоды',
|
||||||
|
PeriodFilterStatus.month => 'За месяц',
|
||||||
|
PeriodFilterStatus.week => 'За неделю',
|
||||||
|
PeriodFilterStatus.year => 'За год',
|
||||||
|
};
|
||||||
|
|
||||||
|
String? get value => switch (this) {
|
||||||
|
PeriodFilterStatus.all => null,
|
||||||
|
PeriodFilterStatus.month => DateTime.now().subtract(const Duration(days: 30)).format('yyyy-MM-dd'),
|
||||||
|
PeriodFilterStatus.week => DateTime.now().subtract(const Duration(days: 7)).format('yyyy-MM-dd'),
|
||||||
|
PeriodFilterStatus.year => DateTime.now().subtract(const Duration(days: 365)).format('yyyy-MM-dd'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ class RatingHistoryItem extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 80,
|
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: appTheme.gray100,
|
color: appTheme.gray100,
|
||||||
@@ -29,7 +28,7 @@ class RatingHistoryItem extends StatelessWidget {
|
|||||||
date.format('dd.MM.yyyy'),
|
date.format('dd.MM.yyyy'),
|
||||||
style: TextStyles.textXSSemibold.copyWith(color: appTheme.gray),
|
style: TextStyles.textXSSemibold.copyWith(color: appTheme.gray),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const SizedBox(height: 12),
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||||
import 'package:eatvio_app/core/widgets/main_background_bouble.dart';
|
import 'package:eatvio_app/core/widgets/main_background_bouble.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
|
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/period_filter_widget.dart';
|
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/period_filter_widget.dart';
|
||||||
@@ -9,7 +10,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
|
||||||
class RatingHistoryWidget extends StatelessWidget {
|
class RatingHistoryWidget extends StatelessWidget {
|
||||||
const RatingHistoryWidget({super.key, required this.ratingHistory});
|
const RatingHistoryWidget({super.key, required this.ratingHistory, required this.isLoading});
|
||||||
|
final bool isLoading;
|
||||||
final List<RatingModel> ratingHistory;
|
final List<RatingModel> ratingHistory;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -20,50 +22,60 @@ class RatingHistoryWidget extends StatelessWidget {
|
|||||||
right: 16,
|
right: 16,
|
||||||
top: 16,
|
top: 16,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: isLoading
|
||||||
children: [
|
? const Center(child: Loader())
|
||||||
Row(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Row(
|
||||||
s.rating_history,
|
children: [
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
Text(
|
||||||
),
|
s.rating_history,
|
||||||
const Spacer(),
|
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||||
SvgPicture.asset(
|
),
|
||||||
'assets/icons/question_mark.svg',
|
const Spacer(),
|
||||||
height: 22,
|
SvgPicture.asset(
|
||||||
width: 22,
|
'assets/icons/question_mark.svg',
|
||||||
colorFilter: ColorFilter.mode(
|
height: 22,
|
||||||
appTheme.blueA400,
|
width: 22,
|
||||||
BlendMode.srcIn,
|
colorFilter: ColorFilter.mode(
|
||||||
|
appTheme.blueA400,
|
||||||
|
BlendMode.srcIn,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
],
|
height: 16,
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 16,
|
|
||||||
),
|
|
||||||
const PeriodFilterWidget(),
|
|
||||||
const SizedBox(
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
ListView.builder(
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return Padding(
|
|
||||||
padding: index == ratingHistory.length - 1 ? EdgeInsets.zero : const EdgeInsets.only(bottom: 12),
|
|
||||||
child: RatingHistoryItem(
|
|
||||||
title: ratingHistory[index].title,
|
|
||||||
amount: ratingHistory[index].amount,
|
|
||||||
date: ratingHistory[index].date,
|
|
||||||
),
|
),
|
||||||
);
|
const PeriodFilterWidget(isStatistic: false),
|
||||||
},
|
const SizedBox(
|
||||||
itemCount: ratingHistory.length,
|
height: 12,
|
||||||
shrinkWrap: true,
|
),
|
||||||
),
|
ListView.builder(
|
||||||
],
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
),
|
itemBuilder: (context, index) {
|
||||||
|
return Padding(
|
||||||
|
padding: index == ratingHistory.length - 1 ? EdgeInsets.zero : const EdgeInsets.only(bottom: 12),
|
||||||
|
child: RatingHistoryItem(
|
||||||
|
title: switch (ratingHistory[index].type) {
|
||||||
|
RatingEnum.addedRecipe => 'Добавление рецепта',
|
||||||
|
RatingEnum.addedPublicDiet => 'Добавление публичной диеты',
|
||||||
|
RatingEnum.addedBlogPost => 'Добавление поста',
|
||||||
|
RatingEnum.invitedUser => 'Регистрация по реф. ссылке',
|
||||||
|
RatingEnum.hasMedicalDegree => 'Получение мед. степени',
|
||||||
|
RatingEnum.consulted => 'Консультация',
|
||||||
|
RatingEnum.addedGlossary => 'Добавление продукта в глоссарий',
|
||||||
|
},
|
||||||
|
amount: ratingHistory[index].amount,
|
||||||
|
date: ratingHistory[index].date,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: ratingHistory.length,
|
||||||
|
shrinkWrap: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||||
import 'package:eatvio_app/core/widgets/main_background_bouble.dart';
|
import 'package:eatvio_app/core/widgets/main_background_bouble.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/models/statistics_model.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/period_filter_widget.dart';
|
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/period_filter_widget.dart';
|
||||||
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/statistic_bouble.dart';
|
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/statistic_bouble.dart';
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
@@ -8,14 +10,15 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
|
||||||
class StatisticWidget extends StatelessWidget {
|
class StatisticWidget extends StatelessWidget {
|
||||||
const StatisticWidget({super.key});
|
const StatisticWidget({super.key, required this.isLoading, required this.statistics});
|
||||||
|
final bool isLoading;
|
||||||
|
final StatisticsModel? statistics;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
return MainBackgroundBouble(
|
return MainBackgroundBouble(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: isLoading ? const Center(child: Loader()) : Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -38,15 +41,17 @@ class StatisticWidget extends StatelessWidget {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
const PeriodFilterWidget(),
|
const PeriodFilterWidget(
|
||||||
|
isStatistic: true,
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: StatisticBouble(number: 12, title: s.invited_people_count)),
|
Expanded(child: StatisticBouble(number: statistics?.countReferal ?? 0, title: s.invited_people_count)),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(child: StatisticBouble(number: 12, title: s.published_posts_count)),
|
Expanded(child: StatisticBouble(number: statistics?.blogPostsCount ?? 0, title: s.published_posts_count)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@@ -54,9 +59,9 @@ class StatisticWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: StatisticBouble(number: 12, title: s.published_recipes_count)),
|
Expanded(child: StatisticBouble(number: statistics?.recipesCount ?? 0, title: s.published_recipes_count)),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(child: StatisticBouble(number: 12, title: s.published_diets_count)),
|
Expanded(child: StatisticBouble(number: statistics?.dietsCount ?? 0, title: s.published_diets_count)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@@ -64,9 +69,9 @@ class StatisticWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: StatisticBouble(number: 12, title: s.consultations_count)),
|
Expanded(child: StatisticBouble(number: statistics?.consultationsCount ?? 0, title: s.consultations_count)),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(child: StatisticBouble(number: 12, title: s.active_consultations_count)),
|
Expanded(child: StatisticBouble(number: statistics?.qwe ?? 0, title: s.active_consultations_count)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/models/statistics_model.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/services/consultant_rating_service.dart';
|
||||||
|
|
||||||
|
class ConsultantRatingRepository {
|
||||||
|
final ConsultantRatingService service;
|
||||||
|
|
||||||
|
ConsultantRatingRepository(this.service);
|
||||||
|
|
||||||
|
Future<StatisticsModel> getConsultantStatistics({String? date}) async {
|
||||||
|
try {
|
||||||
|
return await service.getConsultantStatistics(date: date);
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<RatingModel>> getScoreLogs({String? date}) async {
|
||||||
|
try {
|
||||||
|
final data = (await service.getScoreLogs(date: date)).data;
|
||||||
|
return data;
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
|
||||||
|
import 'package:eatvio_app/features/consultant_rating/models/statistics_model.dart';
|
||||||
|
|
||||||
|
import 'package:retrofit/retrofit.dart';
|
||||||
|
|
||||||
|
part 'consultant_rating_service.g.dart';
|
||||||
|
|
||||||
|
@RestApi()
|
||||||
|
abstract class ConsultantRatingService {
|
||||||
|
factory ConsultantRatingService(Dio dio, {String baseUrl}) = _ConsultantRatingService;
|
||||||
|
|
||||||
|
@GET('/api/consultants/rating/statistics')
|
||||||
|
Future<StatisticsModel> getConsultantStatistics({@Query('filters[duration][\$gte]') String? date});
|
||||||
|
|
||||||
|
@GET('/api/consultants/score/logs')
|
||||||
|
Future<RatingPaginationModel> getScoreLogs({@Query('filters[duration][\$gte]') String? date});
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:eatvio_app/core/const.dart';
|
|
||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
import 'package:eatvio_app/core/widgets/custom_divider.dart';
|
import 'package:eatvio_app/core/widgets/custom_divider.dart';
|
||||||
|
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||||
import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
|
import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
|
||||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||||
import 'package:eatvio_app/features/diary/presentation/pages/diary_screen.dart';
|
import 'package:eatvio_app/features/diary/presentation/pages/diary_screen.dart';
|
||||||
|
import 'package:eatvio_app/features/my_finance/presentation/pages/card_settings.dart';
|
||||||
|
import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
|
||||||
import 'package:eatvio_app/features/user_details/presentation/user_details_screen.dart';
|
import 'package:eatvio_app/features/user_details/presentation/user_details_screen.dart';
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -14,10 +16,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
class ConsultationCardWidget extends StatefulWidget {
|
class ConsultationCardWidget extends StatefulWidget {
|
||||||
final ConsultationModel consultationsModel;
|
final ConsultationModel consultationsModel;
|
||||||
|
|
||||||
const ConsultationCardWidget({
|
const ConsultationCardWidget({super.key, required this.consultationsModel});
|
||||||
super.key,
|
|
||||||
required this.consultationsModel,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ConsultationCardWidget> createState() => _ConsultationCardWidgetState();
|
State<ConsultationCardWidget> createState() => _ConsultationCardWidgetState();
|
||||||
@@ -32,13 +31,7 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
'Дневник заполнен, прокомментирован консультантом и после этого клиент просмотрел комментарии.',
|
'Дневник заполнен, прокомментирован консультантом и после этого клиент просмотрел комментарии.',
|
||||||
];
|
];
|
||||||
|
|
||||||
final List<Color> legendColors = const [
|
final List<Color> legendColors = const [Colors.white, Color(0xFFF0C497), Color(0xFFFF9500), Color(0xFF2F80ED), Color(0xFF4CD964)];
|
||||||
Colors.white,
|
|
||||||
Color(0xFFF0C497),
|
|
||||||
Color(0xFFFF9500),
|
|
||||||
Color(0xFF2F80ED),
|
|
||||||
Color(0xFF4CD964),
|
|
||||||
];
|
|
||||||
|
|
||||||
late final List<(int, DiaryModel)> givenDaysWithDayNumber;
|
late final List<(int, DiaryModel)> givenDaysWithDayNumber;
|
||||||
final List<List<DiaryStateEnum>> legendStates = [
|
final List<List<DiaryStateEnum>> legendStates = [
|
||||||
@@ -46,7 +39,7 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
[DiaryStateEnum.started, DiaryStateEnum.lastDayStarted],
|
[DiaryStateEnum.started, DiaryStateEnum.lastDayStarted],
|
||||||
[DiaryStateEnum.finished, DiaryStateEnum.lastDayFinished],
|
[DiaryStateEnum.finished, DiaryStateEnum.lastDayFinished],
|
||||||
[DiaryStateEnum.commented, DiaryStateEnum.lastDayCommented],
|
[DiaryStateEnum.commented, DiaryStateEnum.lastDayCommented],
|
||||||
[DiaryStateEnum.reviewedByUser]
|
[DiaryStateEnum.reviewedByUser],
|
||||||
];
|
];
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -72,32 +65,19 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
CircleAvatar(radius: 30, backgroundImage: NetworkImage(widget.consultationsModel.userProfilePhotoUrl)),
|
||||||
radius: 30,
|
|
||||||
backgroundImage: NetworkImage(baseUrl + widget.consultationsModel.userProfilePhotoUrl),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
widget.consultationsModel.userName,
|
widget.consultationsModel.userName,
|
||||||
style: const TextStyle(
|
style: const TextStyle(height: 1, color: Color(0xFF323F4B), fontSize: 16, fontWeight: FontWeight.w600),
|
||||||
height: 1,
|
|
||||||
color: Color(0xFF323F4B),
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
widget.consultationsModel.planTitle,
|
widget.consultationsModel.planTitle,
|
||||||
style: const TextStyle(
|
style: const TextStyle(height: 1, color: Color(0xFF88949F), fontSize: 14, fontWeight: FontWeight.w500),
|
||||||
height: 1,
|
|
||||||
color: Color(0xFF88949F),
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -127,12 +107,7 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'День ${widget.consultationsModel.currentDiaryDay} из ${widget.consultationsModel.duration}',
|
'День ${widget.consultationsModel.currentDiaryDay} из ${widget.consultationsModel.duration}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(height: 1, color: Color(0xFF323F4B), fontSize: 16, fontWeight: FontWeight.w500),
|
||||||
height: 1,
|
|
||||||
color: Color(0xFF323F4B),
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -149,12 +124,7 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'Легенда',
|
'Легенда',
|
||||||
style: TextStyle(
|
style: TextStyle(height: 1, fontSize: 20, fontWeight: FontWeight.w700, color: Color(0xFF323F4B)),
|
||||||
height: 1,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: Color(0xFF323F4B),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
ListView.separated(
|
ListView.separated(
|
||||||
@@ -170,11 +140,7 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Icon(
|
child: const Icon(Icons.help_outline_rounded, color: Color(0xFF323F4B), size: 20),
|
||||||
Icons.help_outline_rounded,
|
|
||||||
color: Color(0xFF323F4B),
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -185,7 +151,8 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
children: List.generate(widget.consultationsModel.duration, (index) {
|
children: List.generate(widget.consultationsModel.duration, (index) {
|
||||||
final day = givenDaysWithDayNumber.firstWhereOrNull((e) => e.$1 == index);
|
final day = givenDaysWithDayNumber.firstWhereOrNull((e) => e.$1 == index);
|
||||||
final hasActivity = day != null && day.$2.state != DiaryStateEnum.init;
|
final hasActivity = day != null && day.$2.state != DiaryStateEnum.init;
|
||||||
final canConsultantOpenThisDay = day != null &&
|
final canConsultantOpenThisDay =
|
||||||
|
day != null &&
|
||||||
(day.$2.state != DiaryStateEnum.init && day.$2.state != DiaryStateEnum.started && day.$2.state != DiaryStateEnum.lastDayStarted);
|
(day.$2.state != DiaryStateEnum.init && day.$2.state != DiaryStateEnum.started && day.$2.state != DiaryStateEnum.lastDayStarted);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(right: 12),
|
padding: const EdgeInsets.only(right: 12),
|
||||||
@@ -195,81 +162,74 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!hasActivity || !canConsultantOpenThisDay) {
|
if (!hasActivity || !canConsultantOpenThisDay) {
|
||||||
showErrorDialog(context,
|
showErrorDialog(
|
||||||
title: s.you_can_not_open_this_day, description: '${widget.consultationsModel.userName} ${s.has_not_filled_it_yet}');
|
context,
|
||||||
|
title: s.you_can_not_open_this_day,
|
||||||
|
description: '${widget.consultationsModel.userName} ${s.has_not_filled_it_yet}',
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GoRouter.of(context).push(UserDiaryScreen.path, extra: {
|
GoRouter.of(context).push(UserDiaryScreen.path, extra: {'diaryId': day.$2.id, 'currentDiaryDay': index + 1});
|
||||||
'diaryId': day.$2.id,
|
|
||||||
'currentDiaryDay': index + 1,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(100),
|
borderRadius: BorderRadius.circular(100),
|
||||||
child: Ink(
|
child: Ink(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: hasActivity ? appTheme.dividerColor : appTheme.dividerColor.withValues(alpha: 0.4),
|
color: hasActivity ? appTheme.dividerColor : appTheme.dividerColor.withValues(alpha: 0.4),
|
||||||
borderRadius: BorderRadius.circular(100)),
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
),
|
||||||
width: 58,
|
width: 58,
|
||||||
height: 32,
|
height: 32,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
(index + 1).toString(),
|
(index + 1).toString(),
|
||||||
style: TextStyles.textMSemibold.copyWith(
|
style: TextStyles.textMSemibold.copyWith(color: hasActivity ? appTheme.gray : appTheme.gray.withValues(alpha: 0.4)),
|
||||||
color: hasActivity ? appTheme.gray : appTheme.gray.withValues(alpha: 0.4),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (hasActivity) ...[
|
if (hasActivity) ...[
|
||||||
const SizedBox(
|
const SizedBox(height: 4),
|
||||||
height: 4,
|
|
||||||
),
|
|
||||||
switch (day.$2.state) {
|
switch (day.$2.state) {
|
||||||
DiaryStateEnum.init => const SizedBox.shrink(),
|
DiaryStateEnum.init => const SizedBox.shrink(),
|
||||||
DiaryStateEnum.started => Container(
|
DiaryStateEnum.started => Container(
|
||||||
width: 8,
|
width: 8,
|
||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[1]),
|
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[1]),
|
||||||
),
|
),
|
||||||
DiaryStateEnum.lastDayStarted => Container(
|
DiaryStateEnum.lastDayStarted => Container(
|
||||||
width: 8,
|
width: 8,
|
||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[1]),
|
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[1]),
|
||||||
),
|
),
|
||||||
DiaryStateEnum.finished => Container(
|
DiaryStateEnum.finished => Container(
|
||||||
width: 8,
|
width: 8,
|
||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[2]),
|
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[2]),
|
||||||
),
|
),
|
||||||
DiaryStateEnum.lastDayFinished => Container(
|
DiaryStateEnum.lastDayFinished => Container(
|
||||||
width: 8,
|
width: 8,
|
||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[2]),
|
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[2]),
|
||||||
),
|
),
|
||||||
DiaryStateEnum.commented => Container(
|
DiaryStateEnum.commented => Container(
|
||||||
width: 8,
|
width: 8,
|
||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[3]),
|
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[3]),
|
||||||
),
|
),
|
||||||
DiaryStateEnum.lastDayCommented => Container(
|
DiaryStateEnum.lastDayCommented => Container(
|
||||||
width: 8,
|
width: 8,
|
||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[3]),
|
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[3]),
|
||||||
),
|
),
|
||||||
DiaryStateEnum.reviewedByUser => Container(
|
DiaryStateEnum.reviewedByUser => Container(
|
||||||
width: 8,
|
width: 8,
|
||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[4]),
|
decoration: BoxDecoration(shape: BoxShape.circle, color: legendColors[4]),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
const SizedBox(
|
const SizedBox(height: 12),
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
] else
|
] else
|
||||||
const SizedBox(
|
const SizedBox(height: 24),
|
||||||
height: 24,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -280,11 +240,7 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Text(
|
Text(
|
||||||
'${widget.consultationsModel.consultationOptionPrice.toStringAsFixed(0)} ₽',
|
'${widget.consultationsModel.consultationOptionPrice.toStringAsFixed(0)} ₽',
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Color(0xFF019A3E), fontSize: 20, fontWeight: FontWeight.w600),
|
||||||
color: Color(0xFF019A3E),
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Row(
|
Row(
|
||||||
@@ -293,36 +249,26 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
final lastActiveDay = givenDaysWithDayNumber
|
final lastActiveDay = givenDaysWithDayNumber
|
||||||
.where(
|
.where((e) => e.$2.state == DiaryStateEnum.finished || e.$2.state == DiaryStateEnum.lastDayFinished)
|
||||||
(e) => e.$2.state == DiaryStateEnum.finished || e.$2.state == DiaryStateEnum.lastDayFinished,
|
|
||||||
)
|
|
||||||
.lastOrNull;
|
.lastOrNull;
|
||||||
if (lastActiveDay != null) {
|
if (lastActiveDay != null) {
|
||||||
GoRouter.of(context).push(UserDiaryScreen.path, extra: {
|
GoRouter.of(context).push(UserDiaryScreen.path, extra: {'diaryId': lastActiveDay.$2.id, 'currentDiaryDay': lastActiveDay.$1});
|
||||||
'diaryId': lastActiveDay.$2.id,
|
|
||||||
'currentDiaryDay': lastActiveDay.$1,
|
|
||||||
});
|
|
||||||
GoRouter.of(context).push(UserDiaryScreen.path, extra: lastActiveDay.$2.id);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showErrorDialog(context,
|
showErrorDialog(
|
||||||
title: s.you_can_not_open_this_day, description: '${widget.consultationsModel.userName} ${s.has_not_filled_it_yet}');
|
context,
|
||||||
|
title: s.you_can_not_open_this_day,
|
||||||
|
description: '${widget.consultationsModel.userName} ${s.has_not_filled_it_yet}',
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Ink(
|
child: Ink(
|
||||||
width: MediaQuery.of(context).size.width - 32 - 52 - 8,
|
width: MediaQuery.of(context).size.width - 32 - 52 - 8,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: appTheme.blueA400),
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: appTheme.blueA400,
|
|
||||||
),
|
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Комментировать отчёт',
|
'Комментировать отчёт',
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600),
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -334,20 +280,25 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
child: Ink(
|
child: Ink(
|
||||||
height: 52,
|
height: 52,
|
||||||
width: 52,
|
width: 52,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: const Color(0xFFF6F6F6)),
|
||||||
borderRadius: BorderRadius.circular(20),
|
child: const Center(child: Icon(Icons.chat_outlined, size: 24)),
|
||||||
color: const Color(0xFFF6F6F6),
|
|
||||||
),
|
|
||||||
child: const Center(
|
|
||||||
child: Icon(
|
|
||||||
Icons.chat_outlined,
|
|
||||||
size: 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// Кнопка получения выплаты
|
||||||
|
if (widget.consultationsModel.chosenPlanState == ChosenPlanStateEnum.stateDone) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
CustomOutlinedButton(
|
||||||
|
text: s.collectCharge,
|
||||||
|
height: 52,
|
||||||
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||||
|
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.green)),
|
||||||
|
onPressed: () async {
|
||||||
|
GoRouter.of(context).push(CardSettingsScreen.path, extra: widget.consultationsModel.id);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -361,21 +312,13 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
Container(
|
Container(
|
||||||
height: 20,
|
height: 20,
|
||||||
width: 20,
|
width: 20,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(shape: BoxShape.circle, color: color),
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: color,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
style: const TextStyle(
|
style: const TextStyle(height: 1, fontSize: 16, fontWeight: FontWeight.w500, color: Color(0xFF323F4B)),
|
||||||
height: 1,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Color(0xFF323F4B),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class ConsultationService {
|
|||||||
else if (state != null && stateComparison != null)
|
else if (state != null && stateComparison != null)
|
||||||
'filters[last_state][${stateComparison.value}]': state,
|
'filters[last_state][${stateComparison.value}]': state,
|
||||||
if (dateComparison != null && date != null) 'filters[start_date][${dateComparison.value}]': date,
|
if (dateComparison != null && date != null) 'filters[start_date][${dateComparison.value}]': date,
|
||||||
|
'sort[]': 'created_at:desc',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return ConsultationPaginationModel.fromJson(response.data);
|
return ConsultationPaginationModel.fromJson(response.data);
|
||||||
@@ -77,7 +78,8 @@ class ConsultationService {
|
|||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
'/api/finances/my_finances',
|
'/api/finances/my_finances',
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
if (dateComparison != null && date != null) 'filters[end_date]': date,
|
if (date != null && dateComparison != null) 'filters[start_date][${dateComparison.value}]': date,
|
||||||
|
'sort[]': 'start_date:desc',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
final data = response.data as Map<String, dynamic>;
|
final data = response.data as Map<String, dynamic>;
|
||||||
@@ -96,7 +98,8 @@ class ConsultationService {
|
|||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
'/api/finances/my_purchases',
|
'/api/finances/my_purchases',
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
if (dateComparison != null && date != null) 'filters[start_date]': date,
|
if (date != null && dateComparison != null) 'filters[start_date][${dateComparison.value}]': date,
|
||||||
|
'sort[]': 'start_date:desc',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
final data = response.data as Map<String, dynamic>;
|
final data = response.data as Map<String, dynamic>;
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ class DietPreviewScreen extends StatefulWidget {
|
|||||||
late final List<int> selectedIndexes;
|
late final List<int> selectedIndexes;
|
||||||
static const name = 'createDietScreenPreview';
|
static const name = 'createDietScreenPreview';
|
||||||
static const path = '/create-diet-screen/preview';
|
static const path = '/create-diet-screen/preview';
|
||||||
DietPreviewScreen({
|
DietPreviewScreen({super.key, required this.diet}) {
|
||||||
super.key,
|
|
||||||
required this.diet,
|
|
||||||
}) {
|
|
||||||
selectedIndexes = List.generate(diet.dailySchedule.length, (_) => 0);
|
selectedIndexes = List.generate(diet.dailySchedule.length, (_) => 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +62,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
padding: const EdgeInsets.symmetric(vertical: 12) + (Platform.isIOS ? const EdgeInsets.only(bottom: 16) : EdgeInsets.zero),
|
padding: const EdgeInsets.symmetric(vertical: 12) + (Platform.isIOS ? const EdgeInsets.only(bottom: 16) : EdgeInsets.zero),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
border: Border(
|
border: Border(top: BorderSide(color: Colors.black.withValues(alpha: 0.1))),
|
||||||
top: BorderSide(
|
|
||||||
color: Colors.black.withValues(alpha: 0.1),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
@@ -79,34 +72,16 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: BookmarkButton(
|
||||||
child: FloatingActionButton.extended(
|
isFavorite: widget.diet.isFavorite,
|
||||||
heroTag: 'nextButtonRegistration',
|
onTap: () {},
|
||||||
highlightElevation: 0,
|
width: 52,
|
||||||
elevation: 0,
|
height: 52,
|
||||||
focusElevation: 0,
|
size: 24,
|
||||||
shape: RoundedRectangleBorder(
|
shape: BoxShape.circle,
|
||||||
borderRadius: BorderRadius.circular(16),
|
color: appTheme.gray50,
|
||||||
),
|
|
||||||
backgroundColor: appTheme.greenA700,
|
|
||||||
onPressed: () {},
|
|
||||||
label: Text(
|
|
||||||
s.startDiet,
|
|
||||||
style: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
|
||||||
BookmarkButton(
|
|
||||||
isFavorite: widget.diet.isFavorite,
|
|
||||||
onTap: () {},
|
|
||||||
width: 52,
|
|
||||||
height: 52,
|
|
||||||
size: 24,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: appTheme.gray50,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@@ -133,24 +108,15 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
filled: true,
|
filled: true,
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
borderSide: const BorderSide(
|
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
|
||||||
color: Color(0xFFD1D1D6),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
borderSide: const BorderSide(
|
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
|
||||||
color: Color(0xFFD1D1D6),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
borderSide: const BorderSide(
|
borderSide: const BorderSide(color: Color(0xFFD1D1D6), width: 1),
|
||||||
color: Color(0xFFD1D1D6),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -160,17 +126,10 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(color: textEditingController.text.length > 2 ? appTheme.blueA400 : appTheme.gray50, shape: BoxShape.circle),
|
||||||
color: textEditingController.text.length > 2 ? appTheme.blueA400 : appTheme.gray50,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
height: 32,
|
height: 32,
|
||||||
width: 32,
|
width: 32,
|
||||||
child: Icon(
|
child: Icon(Icons.send_rounded, size: 18, color: textEditingController.text.length > 2 ? appTheme.whiteA700 : appTheme.black),
|
||||||
Icons.send_rounded,
|
|
||||||
size: 18,
|
|
||||||
color: textEditingController.text.length > 2 ? appTheme.whiteA700 : appTheme.black,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -212,12 +171,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
Image.memory(
|
Image.memory(imageData, height: 300, width: MediaQuery.sizeOf(context).width, fit: BoxFit.fill),
|
||||||
imageData,
|
|
||||||
height: 300,
|
|
||||||
width: MediaQuery.sizeOf(context).width,
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
|
||||||
// CachedNetworkImage(
|
// CachedNetworkImage(
|
||||||
// imageUrl: baseUrl + '/storage/' + widget.diet.image,
|
// imageUrl: baseUrl + '/storage/' + widget.diet.image,
|
||||||
// ),
|
// ),
|
||||||
@@ -233,10 +187,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
children: [
|
children: [
|
||||||
SvgPicture.asset('assets/icons/eye.svg', width: 18, height: 12),
|
SvgPicture.asset('assets/icons/eye.svg', width: 18, height: 12),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(widget.diet.totalViews.toString(), style: TextStyles.textXSSemibold.copyWith(color: appTheme.black)),
|
||||||
widget.diet.totalViews.toString(),
|
|
||||||
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
@@ -252,10 +203,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
colorFilter: widget.diet.wasLikedByMe ? ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn) : null,
|
colorFilter: widget.diet.wasLikedByMe ? ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn) : null,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(widget.diet.totalLikes.toString(), style: TextStyles.textXSSemibold.copyWith(color: appTheme.black)),
|
||||||
widget.diet.totalLikes.toString(),
|
|
||||||
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -265,10 +213,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
children: [
|
children: [
|
||||||
SvgPicture.asset('assets/icons/comment2.svg', width: 13, height: 12),
|
SvgPicture.asset('assets/icons/comment2.svg', width: 13, height: 12),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(widget.diet.totalComments.toString(), style: TextStyles.textXSSemibold.copyWith(color: appTheme.black)),
|
||||||
widget.diet.totalComments.toString(),
|
|
||||||
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -279,23 +224,15 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Text(
|
child: Text(s.about_diet, style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||||
s.about_diet,
|
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
InfoRow(diet: widget.diet, type: ProductType.diet,),
|
InfoRow(diet: widget.diet, type: ProductType.diet),
|
||||||
ExpandableText(
|
ExpandableText(text: widget.diet.details),
|
||||||
text: widget.diet.details,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: AuthorCard(
|
child: AuthorCard(author: widget.diet.author, title: s.diet_author),
|
||||||
author: widget.diet.author,
|
|
||||||
title: s.diet_author,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
],
|
],
|
||||||
@@ -308,9 +245,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${s.diet_plan}(${widget.diet.duration.toString()} ${getDayForm(widget.diet.duration, s)})',
|
'${s.diet_plan}(${widget.diet.duration.toString()} ${getDayForm(widget.diet.duration, s)})',
|
||||||
style: TextStyles.headingXLSemibold.copyWith(
|
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||||
color: appTheme.black,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -320,7 +255,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return _dayOfPlan(widget.diet.dailySchedule[index] ?? {}, index, s);
|
return _dayOfPlan(widget.diet.dailySchedule[index + 1] ?? {}, index, s);
|
||||||
},
|
},
|
||||||
itemCount: widget.diet.dailySchedule.length,
|
itemCount: widget.diet.dailySchedule.length,
|
||||||
),
|
),
|
||||||
@@ -331,12 +266,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
child: Text('0 ${getCommentForm(widget.diet.totalComments, s)}', style: TextStyles.textMMedium.copyWith(color: appTheme.gray500)),
|
||||||
'0 ${getCommentForm(widget.diet.totalComments, s)}',
|
|
||||||
style: TextStyles.textMMedium.copyWith(
|
|
||||||
color: appTheme.gray500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
],
|
],
|
||||||
@@ -355,14 +285,10 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
pressElevation: 0,
|
pressElevation: 0,
|
||||||
showCheckmark: false,
|
showCheckmark: false,
|
||||||
side: BorderSide.none,
|
side: BorderSide.none,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
label: Text((index + 1).toString()),
|
label: Text((index + 1).toString()),
|
||||||
labelStyle: TextStyles.textXSSemibold.copyWith(
|
labelStyle: TextStyles.textXSSemibold.copyWith(color: index == widget.selectedIndexes[dayNumber] ? Colors.white : appTheme.gray600),
|
||||||
color: index == widget.selectedIndexes[dayNumber] ? Colors.white : appTheme.gray600,
|
|
||||||
),
|
|
||||||
selected: widget.selectedIndexes[dayNumber] == index,
|
selected: widget.selectedIndexes[dayNumber] == index,
|
||||||
backgroundColor: appTheme.gray100,
|
backgroundColor: appTheme.gray100,
|
||||||
onSelected: (bool selected) {
|
onSelected: (bool selected) {
|
||||||
@@ -376,9 +302,7 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 8),
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
child: MainBackgroundBouble(
|
child: MainBackgroundBouble(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(top: 16),
|
||||||
top: 16,
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
@@ -386,31 +310,12 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text('${s.day} ${dayNumber + 1}', style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||||
'${s.day} ${dayNumber + 1}',
|
const Padding(padding: EdgeInsets.symmetric(vertical: 12), child: CustomDivider()),
|
||||||
style: TextStyles.headingXLSemibold.copyWith(
|
Text(s.meal, style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
||||||
color: appTheme.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 12),
|
|
||||||
child: CustomDivider(),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
s.meal,
|
|
||||||
style: TextStyles.textMMedium.copyWith(
|
|
||||||
color: appTheme.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [choiceChipWidget(0), choiceChipWidget(1), choiceChipWidget(2), choiceChipWidget(3), choiceChipWidget(4)],
|
||||||
choiceChipWidget(0),
|
|
||||||
choiceChipWidget(1),
|
|
||||||
choiceChipWidget(2),
|
|
||||||
choiceChipWidget(3),
|
|
||||||
choiceChipWidget(4),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
@@ -443,20 +348,10 @@ class _DietPreviewScreenState extends State<DietPreviewScreen> {
|
|||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.sizeOf(context).width * 0.6,
|
width: MediaQuery.sizeOf(context).width * 0.6,
|
||||||
child: Text(
|
child: Text(daily.name, style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
||||||
daily.name,
|
|
||||||
style: TextStyles.textMMedium.copyWith(
|
|
||||||
color: appTheme.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Text(
|
Text('${daily.quantity} ${getLocalizedMeasurementUnits(s, daily.portion)}', style: TextStyles.textMSemibold.copyWith(color: appTheme.black)),
|
||||||
'${daily.quantity} ${getLocalizedMeasurementUnits(s, daily.portion)}',
|
|
||||||
style: TextStyles.textMSemibold.copyWith(
|
|
||||||
color: appTheme.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,21 +46,14 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(16) +
|
padding: const EdgeInsets.all(16) + EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||||
EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'Добавление блюда',
|
'Добавление блюда',
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: Color(0xFF323F4B)),
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Color(0xFF323F4B),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Row(
|
Row(
|
||||||
@@ -73,21 +66,17 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
autofocus: true,
|
autofocus: true,
|
||||||
hintText: 'Введите название продукта/блюда',
|
hintText: 'Введите название продукта/блюда',
|
||||||
onChanged: (query) {
|
onChanged: (query) {
|
||||||
EasyDebounce.debounce(
|
EasyDebounce.debounce('glossary-search', const Duration(milliseconds: 250), () async {
|
||||||
'glossary-search',
|
selectedGlossary = null;
|
||||||
const Duration(milliseconds: 250),
|
if (query.isEmpty) {
|
||||||
() async {
|
glossariesList = [];
|
||||||
selectedGlossary = null;
|
selectedGlossary = null;
|
||||||
if (query.isEmpty) {
|
|
||||||
glossariesList = [];
|
|
||||||
selectedGlossary = null;
|
|
||||||
setState(() {});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
glossariesList = await widget.createDietCubit.getGlossaryListByQuery(query);
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
return;
|
||||||
);
|
}
|
||||||
|
glossariesList = await widget.createDietCubit.getGlossaryListByQuery(query);
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -100,22 +89,20 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
hintText: selectedGlossary == null
|
hintText: selectedGlossary == null
|
||||||
? '100'
|
? '100'
|
||||||
: selectedGlossary!.grInPortion == 0
|
: selectedGlossary!.grInPortion == 0
|
||||||
? '100'
|
? '100'
|
||||||
: '1',
|
: '1',
|
||||||
suffixText: selectedGlossary == null
|
suffixText: selectedGlossary == null
|
||||||
? 'гр'
|
? 'гр'
|
||||||
: selectedGlossary?.grInPortion == 0
|
: selectedGlossary?.grInPortion == 0
|
||||||
? 'гр'
|
? 'гр'
|
||||||
: 'шт',
|
: 'шт',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
glossariesList.isEmpty ? const SizedBox(height: 16) : const SizedBox.shrink(),
|
glossariesList.isEmpty ? const SizedBox(height: 16) : const SizedBox.shrink(),
|
||||||
Container(
|
Container(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(maxHeight: 256),
|
||||||
maxHeight: 256,
|
|
||||||
),
|
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
@@ -130,28 +117,12 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
FocusManager.instance.primaryFocus?.nextFocus();
|
FocusManager.instance.primaryFocus?.nextFocus();
|
||||||
},
|
},
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
borderRadius: BorderRadius.circular(20),
|
title: Text(glossariesList[i].name, style: const TextStyle(height: 1)),
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
glossariesList[i].name,
|
|
||||||
style: const TextStyle(
|
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
subtitle: glossariesList[i].grInPortion == 0
|
subtitle: glossariesList[i].grInPortion == 0
|
||||||
? null
|
? null
|
||||||
: Text(
|
: Text('${glossariesList[i].grInPortion} г', style: TextStyle(height: 1, color: Colors.grey.shade600)),
|
||||||
'${glossariesList[i].grInPortion} г',
|
trailing: Icon(Icons.add_rounded, color: Colors.grey.shade400),
|
||||||
style: TextStyle(
|
|
||||||
height: 1,
|
|
||||||
color: Colors.grey.shade600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: Icon(
|
|
||||||
Icons.add_rounded,
|
|
||||||
color: Colors.grey.shade400,
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.only(left: 12),
|
contentPadding: const EdgeInsets.only(left: 12),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -166,25 +137,15 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
if (widget.portionIndex != null)
|
if (widget.portionIndex != null)
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
widget.createDietCubit.removePortion(
|
widget.createDietCubit.removePortion(day: widget.dayIndex, meal: widget.mealIndex, portionIndex: widget.portionIndex!);
|
||||||
day: widget.dayIndex,
|
|
||||||
meal: widget.mealIndex,
|
|
||||||
portionIndex: widget.portionIndex!,
|
|
||||||
);
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
child: Ink(
|
child: Ink(
|
||||||
width: 52,
|
width: 52,
|
||||||
height: 52,
|
height: 52,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: const Color(0xFFF6F6F6)),
|
||||||
borderRadius: BorderRadius.circular(20),
|
child: const Icon(Icons.delete_outline_rounded, color: Colors.red),
|
||||||
color: const Color(0xFFF6F6F6),
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.delete_outline_rounded,
|
|
||||||
color: Colors.red,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.portionIndex != null) const SizedBox(width: 8),
|
if (widget.portionIndex != null) const SizedBox(width: 8),
|
||||||
@@ -194,18 +155,11 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
child: Ink(
|
child: Ink(
|
||||||
width: MediaQuery.of(context).size.width - (widget.portionIndex == null ? 32 : 92),
|
width: MediaQuery.of(context).size.width - (widget.portionIndex == null ? 32 : 92),
|
||||||
height: 52,
|
height: 52,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: appTheme.blueA400),
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: appTheme.blueA400,
|
|
||||||
),
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.portionIndex == null ? 'Добавить' : 'Сохранить',
|
widget.portionIndex == null ? 'Добавить' : 'Сохранить',
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Colors.white),
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -222,8 +176,8 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
var measurementUnits = selectedGlossary?.grInPortion == null
|
var measurementUnits = selectedGlossary?.grInPortion == null
|
||||||
? Portion.pcs
|
? Portion.pcs
|
||||||
: selectedGlossary?.grInPortion == 0
|
: selectedGlossary?.grInPortion == 0
|
||||||
? Portion.grams
|
? Portion.grams
|
||||||
: Portion.pcs;
|
: Portion.pcs;
|
||||||
final glossary = selectedGlossary;
|
final glossary = selectedGlossary;
|
||||||
if (glossary != null) {
|
if (glossary != null) {
|
||||||
final [calories, carbohydrates, proteins, fats] = _getCPFC(glossary, measurementUnits);
|
final [calories, carbohydrates, proteins, fats] = _getCPFC(glossary, measurementUnits);
|
||||||
@@ -235,19 +189,11 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
portion: measurementUnits,
|
portion: measurementUnits,
|
||||||
);
|
);
|
||||||
if (portionIndex == null) {
|
if (portionIndex == null) {
|
||||||
widget.createDietCubit.addPortion(
|
widget.createDietCubit.addPortion(dayIndex: widget.dayIndex, mealIndex: widget.mealIndex, portion: portion);
|
||||||
dayIndex: widget.dayIndex,
|
|
||||||
mealIndex: widget.mealIndex,
|
|
||||||
portion: portion,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
widget.createDietCubit.updatePortion(
|
widget.createDietCubit.updatePortion(dayIndex: widget.dayIndex, mealIndex: widget.mealIndex, portionIndex: portionIndex, portion: portion);
|
||||||
dayIndex: widget.dayIndex,
|
|
||||||
mealIndex: widget.mealIndex,
|
|
||||||
portionIndex: portionIndex,
|
|
||||||
portion: portion,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
Navigator.of(context).pop();
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
final newGlossary = await showModalBottomSheet<GlossaryModel>(
|
final newGlossary = await showModalBottomSheet<GlossaryModel>(
|
||||||
@@ -255,13 +201,8 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => Padding(
|
builder: (context) => Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
child: GlossaryModerationRequestModalWidget(productName: productNameController.text, diaryCubit: sl<DiaryCubit>()),
|
||||||
),
|
|
||||||
child: GlossaryModerationRequestModalWidget(
|
|
||||||
productName: productNameController.text,
|
|
||||||
diaryCubit: sl<DiaryCubit>(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (newGlossary != null) {
|
if (newGlossary != null) {
|
||||||
@@ -275,18 +216,9 @@ class _AddMealWidgetState extends State<AddMealWidget> {
|
|||||||
portion: measurementUnits,
|
portion: measurementUnits,
|
||||||
);
|
);
|
||||||
if (portionIndex == null) {
|
if (portionIndex == null) {
|
||||||
widget.createDietCubit.addPortion(
|
widget.createDietCubit.addPortion(dayIndex: widget.dayIndex, mealIndex: widget.mealIndex, portion: portion);
|
||||||
dayIndex: widget.dayIndex,
|
|
||||||
mealIndex: widget.mealIndex,
|
|
||||||
portion: portion,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
widget.createDietCubit.updatePortion(
|
widget.createDietCubit.updatePortion(dayIndex: widget.dayIndex, mealIndex: widget.mealIndex, portion: portion, portionIndex: portionIndex);
|
||||||
dayIndex: widget.dayIndex,
|
|
||||||
mealIndex: widget.mealIndex,
|
|
||||||
portion: portion,
|
|
||||||
portionIndex: portionIndex,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class RecipeRepository {
|
|||||||
'type': recipe.type,
|
'type': recipe.type,
|
||||||
'state': 'active',
|
'state': 'active',
|
||||||
'title': recipe.title,
|
'title': recipe.title,
|
||||||
'tags': recipe.tags,
|
'tags[]': recipe.tags ?? [],
|
||||||
'description_md': recipe.description,
|
'description_md': recipe.description,
|
||||||
'video_url': recipe.videoUrl,
|
'video_url': recipe.videoUrl,
|
||||||
'ingredients': ingredientsMap,
|
'ingredients': ingredientsMap,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user