forked from eatvio/eatvio_app
Compare commits
22 Commits
issue-687
...
8816b67ff5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8816b67ff5 | ||
|
|
053cf781c3 | ||
|
|
46d0e31f5f | ||
|
|
c88b010cc5 | ||
|
|
a0b29f42df | ||
|
|
96b3bd1637 | ||
|
|
fc09fa36b8 | ||
|
|
68ea8da6e3 | ||
|
|
052c4fedca | ||
|
|
ad777c695b | ||
|
|
e6df89c98a | ||
|
|
fef4451f4e | ||
|
|
c68f86eeb7 | ||
|
|
fafc2aa1f7 | ||
|
|
ca49415ef6 | ||
|
|
2600b8cc79 | ||
| e1f25a63bc | |||
|
|
c295c06565 | ||
|
|
b146295996 | ||
|
|
41f77bd373 | ||
|
|
d4a8cbc637 | ||
|
|
2300bc4ab6 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -17,4 +17,6 @@
|
|||||||
android/build/
|
android/build/
|
||||||
ios/XCBuildData/
|
ios/XCBuildData/
|
||||||
env/.env
|
env/.env
|
||||||
.env
|
.env
|
||||||
|
android/key.properties
|
||||||
|
app/upload-keystore.jks
|
||||||
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,6 +14,8 @@ 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
|
||||||
@@ -33,6 +36,10 @@ android {
|
|||||||
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 * { *; }
|
||||||
@@ -11,6 +11,16 @@
|
|||||||
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
@@ -12,6 +12,7 @@ pluginManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url 'https://developer.huawei.com/repo/' }
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 = 72;
|
CURRENT_PROJECT_VERSION = 74;
|
||||||
DEVELOPMENT_TEAM = VL68C36HYS;
|
DEVELOPMENT_TEAM = VL68C36HYS;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@@ -539,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 = 72;
|
CURRENT_PROJECT_VERSION = 74;
|
||||||
DEVELOPMENT_TEAM = VL68C36HYS;
|
DEVELOPMENT_TEAM = VL68C36HYS;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@@ -578,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 = 72;
|
CURRENT_PROJECT_VERSION = 74;
|
||||||
DEVELOPMENT_TEAM = VL68C36HYS;
|
DEVELOPMENT_TEAM = VL68C36HYS;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>72</string>
|
<string>74</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class AppRouter {
|
|||||||
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',
|
||||||
|
|||||||
@@ -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,28 +1,39 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
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:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.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: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 {
|
Future<void> registerPushToken() async {
|
||||||
if (await TokenStorage.haveTokenInStorage()) {
|
if (await TokenStorage.haveTokenInStorage()) {
|
||||||
try {
|
try {
|
||||||
final deviceInfo = DeviceInfoPlugin();
|
final deviceInfo = DeviceInfoPlugin();
|
||||||
|
final isHuawei = Platform.isAndroid ? await _isHuaweiDevice() : false;
|
||||||
await sl<Dio>().post(
|
await sl<Dio>().post(
|
||||||
'/api/profile/notification/token/register',
|
'/api/profile/notification/token/register',
|
||||||
data: {
|
data: {
|
||||||
'platform': Platform.isIOS ? 'ios' : 'android',
|
'platform': Platform.isIOS ? 'ios' : (isHuawei ? 'huawei' : 'android'),
|
||||||
'hw_id': Platform.isIOS ? (await deviceInfo.iosInfo).identifierForVendor : (await deviceInfo.androidInfo).id,
|
'hw_id': Platform.isIOS ? (await deviceInfo.iosInfo).identifierForVendor : (await deviceInfo.androidInfo).id,
|
||||||
'token': await getToken(),
|
'token': await getToken(),
|
||||||
},
|
},
|
||||||
@@ -32,4 +43,32 @@ class FirebaseApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ 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/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';
|
||||||
@@ -183,6 +184,7 @@ Future<void> init() async {
|
|||||||
sl.registerFactory<NotificationSettingsCubit>(() => NotificationSettingsCubit(notificationSettingsRepository: sl()));
|
sl.registerFactory<NotificationSettingsCubit>(() => NotificationSettingsCubit(notificationSettingsRepository: sl()));
|
||||||
sl.registerFactory<ConsultantRatingCubit>(() => ConsultantRatingCubit(sl()));
|
sl.registerFactory<ConsultantRatingCubit>(() => ConsultantRatingCubit(sl()));
|
||||||
sl.registerFactory<ViewsCubit>(() => ViewsCubit(viewsRepository: 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()));
|
||||||
|
|||||||
@@ -204,6 +204,8 @@ class PrimaryColors {
|
|||||||
Color get commentBg => const Color(0XFFFFFDD8);
|
Color get commentBg => const Color(0XFFFFFDD8);
|
||||||
|
|
||||||
Color get cardNotificationsBG => const Color(0xFFA4A4A4);
|
Color get cardNotificationsBG => const Color(0xFFA4A4A4);
|
||||||
|
|
||||||
|
Color get grey7B => const Color(0xFF7B7B7B);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimaryColors get appTheme => ThemeHelper().themeColor();
|
PrimaryColors get appTheme => ThemeHelper().themeColor();
|
||||||
|
|||||||
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,3 +1,5 @@
|
|||||||
|
// 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';
|
||||||
@@ -24,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});
|
||||||
@@ -165,6 +168,52 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// 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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Center(
|
Center(
|
||||||
child: RichText(
|
child: RichText(
|
||||||
@@ -317,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});
|
||||||
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,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';
|
||||||
@@ -63,7 +65,7 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(radius: 30, backgroundImage: NetworkImage(baseUrl + widget.consultationsModel.userProfilePhotoUrl)),
|
CircleAvatar(radius: 30, backgroundImage: NetworkImage(widget.consultationsModel.userProfilePhotoUrl)),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -284,6 +286,19 @@ class _ConsultationCardWidgetState extends State<ConsultationCardWidget> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// Кнопка получения выплаты
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
builder: (BuildContext context, DiaryState state) {
|
builder: (BuildContext context, DiaryState state) {
|
||||||
if (state is DiaryStateLoaded) {
|
if (state is DiaryStateLoaded) {
|
||||||
final selectedIndex = state.selectedMeal - 1;
|
final selectedIndex = state.selectedMeal - 1;
|
||||||
if (isFirstFetch[selectedIndex]) {
|
final meals = state.diary.meals;
|
||||||
currentSelectedRating[selectedIndex] = state.diary.meals[selectedIndex].mood.toDouble() + 1;
|
if (selectedIndex >= 0 && selectedIndex < meals.length) {
|
||||||
isFirstFetch[selectedIndex] = false;
|
if (isFirstFetch[selectedIndex]) {
|
||||||
|
currentSelectedRating[selectedIndex] = meals[selectedIndex].mood.toDouble() + 1;
|
||||||
|
isFirstFetch[selectedIndex] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(top: 24),
|
padding: const EdgeInsets.only(top: 24),
|
||||||
@@ -35,21 +38,17 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
Text(
|
Text(
|
||||||
state.isConsultantView ? 'Настроение пользователя после приема пищи' : 'Ваше настроение после приёма пищи',
|
state.isConsultantView ? 'Настроение пользователя после приема пищи' : 'Ваше настроение после приёма пищи',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 16),
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset('assets/icons/mood_1.svg', height: 32, width: 32),
|
||||||
'assets/icons/mood_1.svg',
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
),
|
|
||||||
RatingBar.builder(
|
RatingBar.builder(
|
||||||
ignoreGestures: state.isConsultantView || state.isDiaryFinished || state.isDiaryCommented,
|
ignoreGestures: state.isConsultantView || state.isDiaryFinished || state.isDiaryCommented,
|
||||||
initialRating: state.diary.meals[selectedIndex].mood.toDouble() + 1,
|
initialRating: (selectedIndex >= 0 && selectedIndex < state.diary.meals.length)
|
||||||
|
? state.diary.meals[selectedIndex].mood.toDouble() + 1
|
||||||
|
: 3,
|
||||||
itemCount: 6,
|
itemCount: 6,
|
||||||
itemSize: MediaQuery.of(context).size.width / 6 - (124 / 6),
|
itemSize: MediaQuery.of(context).size.width / 6 - (124 / 6),
|
||||||
updateOnDrag: true,
|
updateOnDrag: true,
|
||||||
@@ -63,20 +62,11 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFC82222),
|
color: const Color(0xFFC82222),
|
||||||
border: currentSelectedRating[selectedIndex] == 1
|
border: currentSelectedRating[selectedIndex] == 1
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFFAA3333), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFFAA3333),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 1
|
borderRadius: currentSelectedRating[selectedIndex] == 1
|
||||||
? const BorderRadius.horizontal(
|
? const BorderRadius.horizontal(left: Radius.circular(8), right: Radius.circular(2))
|
||||||
left: Radius.circular(8),
|
: const BorderRadius.horizontal(left: Radius.circular(8)),
|
||||||
right: Radius.circular(2),
|
|
||||||
)
|
|
||||||
: const BorderRadius.horizontal(
|
|
||||||
left: Radius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case 1:
|
case 1:
|
||||||
@@ -87,11 +77,7 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFFF3E3E),
|
color: const Color(0xFFFF3E3E),
|
||||||
border: currentSelectedRating[selectedIndex] == 2
|
border: currentSelectedRating[selectedIndex] == 2
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF550000), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF550000),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 2 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 2 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -104,11 +90,7 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFF8C926),
|
color: const Color(0xFFF8C926),
|
||||||
border: currentSelectedRating[selectedIndex] == 3
|
border: currentSelectedRating[selectedIndex] == 3
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF8C5D00), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF8C5D00),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 3 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 3 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -121,11 +103,7 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFFFF3BF),
|
color: const Color(0xFFFFF3BF),
|
||||||
border: currentSelectedRating[selectedIndex] == 4
|
border: currentSelectedRating[selectedIndex] == 4
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFFB5911B), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFFB5911B),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 4 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 4 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -138,11 +116,7 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF62E833),
|
color: const Color(0xFF62E833),
|
||||||
border: currentSelectedRating[selectedIndex] == 5
|
border: currentSelectedRating[selectedIndex] == 5
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF276918), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF276918),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 5 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 5 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -155,20 +129,11 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF4DCE20),
|
color: const Color(0xFF4DCE20),
|
||||||
border: currentSelectedRating[selectedIndex] == 6
|
border: currentSelectedRating[selectedIndex] == 6
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF184D12), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF184D12),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 6
|
borderRadius: currentSelectedRating[selectedIndex] == 6
|
||||||
? const BorderRadius.horizontal(
|
? const BorderRadius.horizontal(left: Radius.circular(2), right: Radius.circular(8))
|
||||||
left: Radius.circular(2),
|
: const BorderRadius.horizontal(right: Radius.circular(8)),
|
||||||
right: Radius.circular(8),
|
|
||||||
)
|
|
||||||
: const BorderRadius.horizontal(
|
|
||||||
right: Radius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -177,20 +142,12 @@ class _MoodRatingWidgetState extends State<MoodRatingWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
currentSelectedRating[selectedIndex] = value;
|
currentSelectedRating[selectedIndex] = value;
|
||||||
});
|
});
|
||||||
EasyDebounce.debounce(
|
EasyDebounce.debounce('change-satiety', const Duration(milliseconds: 250), () {
|
||||||
'change-satiety',
|
context.read<DiaryCubit>().fillMood(diaryId: state.diary.id, mood: currentSelectedRating[selectedIndex].toInt() - 1);
|
||||||
const Duration(milliseconds: 250),
|
});
|
||||||
() {
|
|
||||||
context.read<DiaryCubit>().fillMood(diaryId: state.diary.id, mood: currentSelectedRating[selectedIndex].toInt() - 1);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SvgPicture.asset(
|
SvgPicture.asset('assets/icons/mood_2.svg', height: 32, width: 32),
|
||||||
'assets/icons/mood_2.svg',
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
builder: (BuildContext context, DiaryState state) {
|
builder: (BuildContext context, DiaryState state) {
|
||||||
if (state is DiaryStateLoaded) {
|
if (state is DiaryStateLoaded) {
|
||||||
final selectedIndex = state.selectedMeal - 1;
|
final selectedIndex = state.selectedMeal - 1;
|
||||||
if (isFirstFetch[selectedIndex]) {
|
final meals = state.diary.meals;
|
||||||
currentSelectedRating[selectedIndex] = state.diary.meals[selectedIndex].satiety.toDouble() + 1;
|
if (selectedIndex >= 0 && selectedIndex < meals.length) {
|
||||||
isFirstFetch[selectedIndex] = false;
|
if (isFirstFetch[selectedIndex]) {
|
||||||
|
currentSelectedRating[selectedIndex] = meals[selectedIndex].satiety.toDouble() + 1;
|
||||||
|
isFirstFetch[selectedIndex] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(top: 24),
|
padding: const EdgeInsets.only(top: 24),
|
||||||
@@ -35,21 +38,17 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
Text(
|
Text(
|
||||||
state.isConsultantView ? 'Сытость пользователя после приема пищи' : 'Ваша сытость после приёма пищи',
|
state.isConsultantView ? 'Сытость пользователя после приема пищи' : 'Ваша сытость после приёма пищи',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 16),
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset('assets/icons/satiety_emoji_left.svg', height: 32, width: 32),
|
||||||
'assets/icons/satiety_emoji_left.svg',
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
),
|
|
||||||
RatingBar.builder(
|
RatingBar.builder(
|
||||||
ignoreGestures: state.isConsultantView || state.isDiaryFinished || state.isDiaryCommented,
|
ignoreGestures: state.isConsultantView || state.isDiaryFinished || state.isDiaryCommented,
|
||||||
initialRating: state.diary.meals[selectedIndex].satiety.toDouble() + 1,
|
initialRating: (selectedIndex >= 0 && selectedIndex < state.diary.meals.length)
|
||||||
|
? state.diary.meals[selectedIndex].satiety.toDouble() + 1
|
||||||
|
: 3,
|
||||||
itemCount: 6,
|
itemCount: 6,
|
||||||
itemSize: MediaQuery.of(context).size.width / 6 - (124 / 6),
|
itemSize: MediaQuery.of(context).size.width / 6 - (124 / 6),
|
||||||
updateOnDrag: true,
|
updateOnDrag: true,
|
||||||
@@ -63,20 +62,11 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFC82222),
|
color: const Color(0xFFC82222),
|
||||||
border: currentSelectedRating[selectedIndex] == 1
|
border: currentSelectedRating[selectedIndex] == 1
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFFAA3333), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFFAA3333),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 1
|
borderRadius: currentSelectedRating[selectedIndex] == 1
|
||||||
? const BorderRadius.horizontal(
|
? const BorderRadius.horizontal(left: Radius.circular(8), right: Radius.circular(2))
|
||||||
left: Radius.circular(8),
|
: const BorderRadius.horizontal(left: Radius.circular(8)),
|
||||||
right: Radius.circular(2),
|
|
||||||
)
|
|
||||||
: const BorderRadius.horizontal(
|
|
||||||
left: Radius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case 1:
|
case 1:
|
||||||
@@ -87,11 +77,7 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFFF3E3E),
|
color: const Color(0xFFFF3E3E),
|
||||||
border: currentSelectedRating[selectedIndex] == 2
|
border: currentSelectedRating[selectedIndex] == 2
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF550000), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF550000),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 2 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 2 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -104,11 +90,7 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFF8C926),
|
color: const Color(0xFFF8C926),
|
||||||
border: currentSelectedRating[selectedIndex] == 3
|
border: currentSelectedRating[selectedIndex] == 3
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF8C5D00), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF8C5D00),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 3 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 3 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -121,11 +103,7 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFFFF3BF),
|
color: const Color(0xFFFFF3BF),
|
||||||
border: currentSelectedRating[selectedIndex] == 4
|
border: currentSelectedRating[selectedIndex] == 4
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFFB5911B), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFFB5911B),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 4 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 4 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -138,11 +116,7 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF62E833),
|
color: const Color(0xFF62E833),
|
||||||
border: currentSelectedRating[selectedIndex] == 5
|
border: currentSelectedRating[selectedIndex] == 5
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF276918), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF276918),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 5 ? BorderRadius.circular(2) : null,
|
borderRadius: currentSelectedRating[selectedIndex] == 5 ? BorderRadius.circular(2) : null,
|
||||||
),
|
),
|
||||||
@@ -155,20 +129,11 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFF4DCE20),
|
color: const Color(0xFF4DCE20),
|
||||||
border: currentSelectedRating[selectedIndex] == 6
|
border: currentSelectedRating[selectedIndex] == 6
|
||||||
? Border.all(
|
? Border.all(width: 2, color: const Color(0xFF184D12), strokeAlign: BorderSide.strokeAlignOutside)
|
||||||
width: 2,
|
|
||||||
color: const Color(0xFF184D12),
|
|
||||||
strokeAlign: BorderSide.strokeAlignOutside,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
borderRadius: currentSelectedRating[selectedIndex] == 6
|
borderRadius: currentSelectedRating[selectedIndex] == 6
|
||||||
? const BorderRadius.horizontal(
|
? const BorderRadius.horizontal(left: Radius.circular(2), right: Radius.circular(8))
|
||||||
left: Radius.circular(2),
|
: const BorderRadius.horizontal(right: Radius.circular(8)),
|
||||||
right: Radius.circular(8),
|
|
||||||
)
|
|
||||||
: const BorderRadius.horizontal(
|
|
||||||
right: Radius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -178,20 +143,12 @@ class _SatietyRatingWidgetState extends State<SatietyRatingWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
currentSelectedRating[selectedIndex] = value;
|
currentSelectedRating[selectedIndex] = value;
|
||||||
});
|
});
|
||||||
EasyDebounce.debounce(
|
EasyDebounce.debounce('change-satiety', const Duration(milliseconds: 250), () {
|
||||||
'change-satiety',
|
context.read<DiaryCubit>().fillSatiety(diaryId: state.diary.id, satiety: currentSelectedRating[selectedIndex].toInt() - 1);
|
||||||
const Duration(milliseconds: 250),
|
});
|
||||||
() {
|
|
||||||
context.read<DiaryCubit>().fillSatiety(diaryId: state.diary.id, satiety: currentSelectedRating[selectedIndex].toInt() - 1);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SvgPicture.asset(
|
SvgPicture.asset('assets/icons/satiety_emoji_right.svg', height: 32, width: 32),
|
||||||
'assets/icons/satiety_emoji_right.svg',
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -82,7 +82,53 @@ class DiaryRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<DiaryDayModel> getDiaryDay(int diaryId) async {
|
Future<DiaryDayModel> getDiaryDay(int diaryId) async {
|
||||||
return (await diaryService.getDiaryDay(diary: diaryId)).diary;
|
// Align with getDiaryByDate: enrich portions with glossary nutritional info
|
||||||
|
final diaryWrapper = await diaryService.getDiaryDay(diary: diaryId);
|
||||||
|
final DiaryDayModel diaryDay = diaryWrapper.diary;
|
||||||
|
Set<int> ids = {};
|
||||||
|
for (var meal in diaryDay.meals) {
|
||||||
|
for (var portion in meal.portions) {
|
||||||
|
if (portion.productNutritionalValueId != null) {
|
||||||
|
ids.add(portion.productNutritionalValueId!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ids.isNotEmpty) {
|
||||||
|
final glossary = await getGlossariesIndex(ids: ids.toList());
|
||||||
|
final List<MealModel> updatedMeals = List.from(diaryDay.meals);
|
||||||
|
for (var mealIndex = 0; mealIndex < updatedMeals.length; mealIndex++) {
|
||||||
|
final meal = updatedMeals[mealIndex];
|
||||||
|
final updatedPortions = meal.portions.map((portion) {
|
||||||
|
if (portion.productNutritionalValueId != null) {
|
||||||
|
try {
|
||||||
|
final glossaryItem = glossary.glossariesList.firstWhere((g) => g.id == portion.productNutritionalValueId);
|
||||||
|
return portion.copyWith(
|
||||||
|
productCaloriesInfo: ProductCaloriesInfoModel(
|
||||||
|
id: glossaryItem.id,
|
||||||
|
productName: glossaryItem.name,
|
||||||
|
calories: glossaryItem.energyOn100Gr,
|
||||||
|
proteins: glossaryItem.proteinsOn100Gr,
|
||||||
|
fats: glossaryItem.fatsOn100Gr,
|
||||||
|
carbohydrates: glossaryItem.carbohydratesOn100Gr,
|
||||||
|
energyOnPortion: glossaryItem.energyOnPortion,
|
||||||
|
proteinsOnPortion: glossaryItem.proteinsOnPortion,
|
||||||
|
fatsOnPortion: glossaryItem.fatsOnPortion,
|
||||||
|
carbohydratesOnPortion: glossaryItem.carbohydratesOnPortion,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
return portion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return portion;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
updatedMeals[mealIndex] = meal.copyWith(portions: updatedPortions);
|
||||||
|
}
|
||||||
|
final updatedDiaryDay = diaryDay.copyWith(meals: updatedMeals);
|
||||||
|
return updatedDiaryDay;
|
||||||
|
}
|
||||||
|
return diaryDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<NutritionDataModel> getNutritionData(int index) async {
|
Future<NutritionDataModel> getNutritionData(int index) async {
|
||||||
|
|||||||
@@ -15,13 +15,12 @@ class FeedCubit extends Cubit<FeedState> {
|
|||||||
FeedCubit({required this.feedRepository}) : super(const FeedState.loading());
|
FeedCubit({required this.feedRepository}) : super(const FeedState.loading());
|
||||||
|
|
||||||
void updateFeedBlogPostList(FeedBlogPostModel? feedBlogPostModel, bool wasLikedByMe) {
|
void updateFeedBlogPostList(FeedBlogPostModel? feedBlogPostModel, bool wasLikedByMe) {
|
||||||
if (feedBlogPostModel == null || isClosed) return;
|
if (feedBlogPostModel == null || isClosed || state is! FeedStateLoaded) return;
|
||||||
List<FeedBlogPostModel> feedBlogPostList = [...(state as FeedStateLoaded).feedBlogPostList];
|
final List<FeedBlogPostModel> feedBlogPostList = [...(state as FeedStateLoaded).feedBlogPostList];
|
||||||
final int index = feedBlogPostList.indexOf(feedBlogPostModel);
|
final int index = feedBlogPostList.indexWhere((e) => e.id == feedBlogPostModel.id);
|
||||||
feedBlogPostList[index] = feedBlogPostModel.copyWith(
|
if (index == -1) return;
|
||||||
wasLikedByMe: wasLikedByMe,
|
final current = feedBlogPostList[index];
|
||||||
totalLikes: wasLikedByMe == false ? feedBlogPostList[index].totalLikes - 1 : feedBlogPostList[index].totalLikes + 1,
|
feedBlogPostList[index] = current.copyWith(wasLikedByMe: wasLikedByMe, totalLikes: wasLikedByMe ? current.totalLikes + 1 : current.totalLikes - 1);
|
||||||
);
|
|
||||||
if (!isClosed) {
|
if (!isClosed) {
|
||||||
emit(FeedState.loaded(feedBlogPostList: feedBlogPostList, isLoading: isLoading));
|
emit(FeedState.loaded(feedBlogPostList: feedBlogPostList, isLoading: isLoading));
|
||||||
}
|
}
|
||||||
@@ -81,5 +80,4 @@ class FeedCubit extends Cubit<FeedState> {
|
|||||||
Future<void> viewRecipe(String slug) async => await feedRepository.viewRecipe(slug);
|
Future<void> viewRecipe(String slug) async => await feedRepository.viewRecipe(slug);
|
||||||
Future<void> viewDiet(int id) async => await feedRepository.viewDiet(id);
|
Future<void> viewDiet(int id) async => await feedRepository.viewDiet(id);
|
||||||
Future<void> viewPlan(String slug) async => await feedRepository.viewPlan(slug);
|
Future<void> viewPlan(String slug) async => await feedRepository.viewPlan(slug);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class FeedScreen extends StatelessWidget {
|
|||||||
providers: [
|
providers: [
|
||||||
BlocProvider<RecipesCubit>(create: (context) => sl<RecipesCubit>()..loadRecipesList()),
|
BlocProvider<RecipesCubit>(create: (context) => sl<RecipesCubit>()..loadRecipesList()),
|
||||||
BlocProvider<FeedProfileCubit>(create: (context) => sl<FeedProfileCubit>()..getProfile()),
|
BlocProvider<FeedProfileCubit>(create: (context) => sl<FeedProfileCubit>()..getProfile()),
|
||||||
BlocProvider<FeedCubit>(create: (context) => sl<FeedCubit>()..loadFeedBlogPostList()),
|
|
||||||
BlocProvider<DietsCubit>(create: (context) => sl<DietsCubit>()..loadDiets()),
|
BlocProvider<DietsCubit>(create: (context) => sl<DietsCubit>()..loadDiets()),
|
||||||
if (!hidePlans) BlocProvider<PlansCubit>(create: (context) => sl<PlansCubit>()..loadPlans()),
|
if (!hidePlans) BlocProvider<PlansCubit>(create: (context) => sl<PlansCubit>()..loadPlans()),
|
||||||
BlocProvider<ConsultantsCubit>(create: (context) => sl<ConsultantsCubit>()..getConsultants()),
|
BlocProvider<ConsultantsCubit>(create: (context) => sl<ConsultantsCubit>()..getConsultants()),
|
||||||
@@ -78,8 +77,6 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
|||||||
if (consultantsScrollController.offset >= consultantsScrollController.position.maxScrollExtent && !consultantsScrollController.position.outOfRange) {}
|
if (consultantsScrollController.offset >= consultantsScrollController.position.maxScrollExtent && !consultantsScrollController.position.outOfRange) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
blogPostsScrollController.dispose();
|
blogPostsScrollController.dispose();
|
||||||
@@ -90,8 +87,6 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
FlutterNativeSplash.remove();
|
FlutterNativeSplash.remove();
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ import 'package:share_plus/share_plus.dart';
|
|||||||
class BlogPostWidget extends StatefulWidget {
|
class BlogPostWidget extends StatefulWidget {
|
||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
const BlogPostWidget({
|
const BlogPostWidget({super.key, required this.index});
|
||||||
super.key,
|
|
||||||
required this.index,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<BlogPostWidget> createState() => _BlogPostWidgetState();
|
State<BlogPostWidget> createState() => _BlogPostWidgetState();
|
||||||
@@ -44,10 +41,7 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
totalLikes = state.feedBlogPostList[widget.index].totalLikes;
|
totalLikes = state.feedBlogPostList[widget.index].totalLikes;
|
||||||
return InkWell(
|
return InkWell(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
onTap: () => GoRouter.of(context).pushNamed(
|
onTap: () => GoRouter.of(context).pushNamed('blogPostScreen', extra: state.feedBlogPostList[widget.index].id),
|
||||||
'blogPostScreen',
|
|
||||||
extra: state.feedBlogPostList[widget.index].id,
|
|
||||||
),
|
|
||||||
child: Material(
|
child: Material(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@@ -95,21 +89,12 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
Text(
|
Text(
|
||||||
state.feedBlogPostList[widget.index].author.authorName,
|
state.feedBlogPostList[widget.index].author.authorName,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
style: const TextStyle(height: 1, color: Colors.black87, fontWeight: FontWeight.w500, fontSize: 16),
|
||||||
height: 1,
|
|
||||||
color: Colors.black87,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
'${calculateDifference(state.feedBlogPostList[widget.index].createdAt)} в ${state.feedBlogPostList[widget.index].createdAt.hour.toString().padLeft(2, '0')}:${state.feedBlogPostList[widget.index].createdAt.minute.toString().padLeft(2, '0')}',
|
'${calculateDifference(state.feedBlogPostList[widget.index].createdAt)} в ${state.feedBlogPostList[widget.index].createdAt.hour.toString().padLeft(2, '0')}:${state.feedBlogPostList[widget.index].createdAt.minute.toString().padLeft(2, '0')}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(height: 1, color: Colors.black45, fontSize: 14),
|
||||||
height: 1,
|
|
||||||
color: Colors.black45,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -119,9 +104,7 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
!state.feedBlogPostList[widget.index].author.authorIsMe)
|
!state.feedBlogPostList[widget.index].author.authorIsMe)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 8),
|
padding: const EdgeInsets.only(right: 8),
|
||||||
child: SubscribeButtonWidget(
|
child: SubscribeButtonWidget(slug: state.feedBlogPostList[widget.index].author.authorSlug),
|
||||||
slug: state.feedBlogPostList[widget.index].author.authorSlug,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
// Кнопка меню
|
// Кнопка меню
|
||||||
CustomPopup(
|
CustomPopup(
|
||||||
@@ -141,11 +124,7 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Text(
|
child: Text(
|
||||||
state.feedBlogPostList[widget.index].title,
|
state.feedBlogPostList[widget.index].title,
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Colors.black87),
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -156,15 +135,12 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Html(
|
child: Html(
|
||||||
data: (state.feedBlogPostList[widget.index].description.length > 200
|
data:
|
||||||
? state.feedBlogPostList[widget.index].description.substring(0, 200)
|
(state.feedBlogPostList[widget.index].description.length > 200
|
||||||
: state.feedBlogPostList[widget.index].description).replaceAll('\n', '<br>'),
|
? state.feedBlogPostList[widget.index].description.substring(0, 200)
|
||||||
style: {
|
: state.feedBlogPostList[widget.index].description)
|
||||||
"*": Style(
|
.replaceAll('\n', '<br>'),
|
||||||
fontSize: FontSize(16),
|
style: {"*": Style(fontSize: FontSize(16), color: Colors.black87)},
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (state.feedBlogPostList[widget.index].description.length > 200)
|
if (state.feedBlogPostList[widget.index].description.length > 200)
|
||||||
@@ -172,12 +148,7 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Показать ещё',
|
'Показать ещё',
|
||||||
style: TextStyle(
|
style: TextStyle(height: 1, color: Color(0xFF8B8B8B), fontSize: 14, fontWeight: FontWeight.w600),
|
||||||
height: 1,
|
|
||||||
color: Color(0xFF8B8B8B),
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (state.feedBlogPostList[widget.index].title.isNotEmpty || state.feedBlogPostList[widget.index].description.isNotEmpty)
|
if (state.feedBlogPostList[widget.index].title.isNotEmpty || state.feedBlogPostList[widget.index].description.isNotEmpty)
|
||||||
@@ -186,10 +157,7 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.pushTransparentRoute(
|
context.pushTransparentRoute(
|
||||||
rootNavigator: true,
|
rootNavigator: true,
|
||||||
PhotoViewScreen(
|
PhotoViewScreen(imageUrls: ['$baseUrl/storage/${state.feedBlogPostList[widget.index].image}'], index: 0),
|
||||||
imageUrls: ['$baseUrl/storage/${state.feedBlogPostList[widget.index].image}'],
|
|
||||||
index: 0,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Hero(
|
child: Hero(
|
||||||
@@ -218,11 +186,14 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
isLiked = !isLiked;
|
isLiked = !isLiked;
|
||||||
isLiked ? totalLikes++ : totalLikes--;
|
isLiked ? totalLikes++ : totalLikes--;
|
||||||
});
|
});
|
||||||
isLiked
|
// Update feed list immediately by ID (no reload)
|
||||||
? await context.read<FeedCubit>().likePost(state.feedBlogPostList[widget.index].id)
|
context.read<FeedCubit>().updateFeedBlogPostList(state.feedBlogPostList[widget.index], isLiked);
|
||||||
: await context.read<FeedCubit>().unlikedPost(state.feedBlogPostList[widget.index].id);
|
// Fire network call without introducing UI delay
|
||||||
if (!context.mounted) return;
|
if (isLiked) {
|
||||||
await context.read<FeedCubit>().loadFeedBlogPostList();
|
await context.read<FeedCubit>().likePost(state.feedBlogPostList[widget.index].id);
|
||||||
|
} else {
|
||||||
|
await context.read<FeedCubit>().unlikedPost(state.feedBlogPostList[widget.index].id);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
@@ -231,16 +202,10 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
'assets/icons/comment.svg',
|
'assets/icons/comment.svg',
|
||||||
height: 20,
|
height: 20,
|
||||||
width: 20,
|
width: 20,
|
||||||
colorFilter: ColorFilter.mode(
|
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn),
|
||||||
appTheme.gray600,
|
|
||||||
BlendMode.srcIn,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
text: state.feedBlogPostList[widget.index].totalComments.toString(),
|
text: state.feedBlogPostList[widget.index].totalComments.toString(),
|
||||||
onTap: () => GoRouter.of(context).pushNamed(
|
onTap: () => GoRouter.of(context).pushNamed('blogPostScreen', extra: state.feedBlogPostList[widget.index].id),
|
||||||
'blogPostScreen',
|
|
||||||
extra: state.feedBlogPostList[widget.index].id,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
FeedIconButton(
|
FeedIconButton(
|
||||||
@@ -254,28 +219,18 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
|||||||
final box = context.findRenderObject() as RenderBox?;
|
final box = context.findRenderObject() as RenderBox?;
|
||||||
SharePlus.instance.share(
|
SharePlus.instance.share(
|
||||||
ShareParams(
|
ShareParams(
|
||||||
uri: Uri.parse(
|
uri: Uri.parse('$baseUrl/ru/blog_post/${state.feedBlogPostList[widget.index].id}'),
|
||||||
'$baseUrl/ru/blog_post/${state.feedBlogPostList[widget.index].id}',
|
|
||||||
),
|
|
||||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Icon(
|
Icon(Icons.visibility_rounded, size: 16, color: appTheme.gray500),
|
||||||
Icons.visibility_rounded,
|
|
||||||
size: 16,
|
|
||||||
color: appTheme.gray500,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
state.feedBlogPostList[widget.index].totalViews.toString(),
|
state.feedBlogPostList[widget.index].totalViews.toString(),
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 12, color: appTheme.gray500, fontWeight: FontWeight.w400),
|
||||||
fontSize: 12,
|
|
||||||
color: appTheme.gray500,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
class GlossaryScreen extends StatefulWidget {
|
class GlossaryScreen extends StatefulWidget {
|
||||||
const GlossaryScreen({super.key});
|
const GlossaryScreen({super.key, required this.passKey});
|
||||||
|
final String passKey;
|
||||||
@override
|
@override
|
||||||
State<GlossaryScreen> createState() => _GlossaryScreenState();
|
State<GlossaryScreen> createState() => _GlossaryScreenState();
|
||||||
}
|
}
|
||||||
@@ -18,15 +18,13 @@ class _GlossaryScreenState extends State<GlossaryScreen> {
|
|||||||
|
|
||||||
_controller = WebViewController()
|
_controller = WebViewController()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
..loadRequest(Uri.parse('$baseUrl/product_nutritional_value'));
|
..loadRequest(Uri.parse('$baseUrl/login_with_pass_key?id=${widget.passKey}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(title: const Text('Глоссарий')),
|
||||||
title: const Text('Глоссарий'),
|
|
||||||
),
|
|
||||||
body: WebViewWidget(controller: _controller),
|
body: WebViewWidget(controller: _controller),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:eatvio_app/features/menu/presentation/bloc/menu_cubit/menu_state.dart';
|
||||||
|
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
class MenuCubit extends Cubit<MenuState> {
|
||||||
|
final ProfileRepository profileRepository;
|
||||||
|
MenuCubit(this.profileRepository) : super(MenuState());
|
||||||
|
|
||||||
|
Future<String?> makePassKey() async {
|
||||||
|
try {
|
||||||
|
final passKey = await profileRepository.getPassKey(routeName: 'product_nutritional_value.index', routeParams: {});
|
||||||
|
return passKey;
|
||||||
|
} catch (e) {
|
||||||
|
log(e.toString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
class MenuState {}
|
||||||
@@ -9,12 +9,14 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|||||||
import 'package:eatvio_app/features/consultant_rating/presentation/consultant_rating_screen.dart';
|
import 'package:eatvio_app/features/consultant_rating/presentation/consultant_rating_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/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/bloc/menu_cubit/menu_cubit.dart';
|
||||||
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
|
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
|
||||||
import 'package:eatvio_app/features/my_plans/presentation/my_plans_screen.dart';
|
import 'package:eatvio_app/features/my_plans/presentation/my_plans_screen.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||||
import 'package:eatvio_app/features/recipe/presentation/pages/my_recipes_screen.dart';
|
import 'package:eatvio_app/features/recipe/presentation/pages/my_recipes_screen.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.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:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
@@ -26,66 +28,86 @@ class MenuScreen extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return BlocProvider(
|
||||||
appBar: AppBar(centerTitle: false, title: const Text('Меню')),
|
create: (context) => sl<MenuCubit>(),
|
||||||
body: SingleChildScrollView(
|
child: Builder(
|
||||||
child: Column(
|
builder: (context) {
|
||||||
children: [
|
return Scaffold(
|
||||||
_tile(title: 'Настройки профиля', leading: ImageConstant.icnProfileSettings, onTap: () => GoRouter.of(context).push('/settings-screen')),
|
appBar: AppBar(centerTitle: false, title: const Text('Меню')),
|
||||||
if (profileModel.roles.contains('consultant')) _divider(context),
|
body: SingleChildScrollView(
|
||||||
if (profileModel.roles.contains('consultant'))
|
child: Column(
|
||||||
_tile(leading: ImageConstant.icnRecipes, title: 'Мои рецепты', onTap: () => GoRouter.of(context).push(MyRecipesScreen.path)),
|
children: [
|
||||||
if (profileModel.roles.contains('consultant')) _divider(context),
|
_tile(title: 'Настройки профиля', leading: ImageConstant.icnProfileSettings, onTap: () => GoRouter.of(context).push('/settings-screen')),
|
||||||
if (profileModel.roles.contains('consultant'))
|
if (profileModel.roles.contains('consultant')) _divider(context),
|
||||||
_tile(leading: 'assets/icons/diets.svg', title: 'Мои диеты', onTap: () => GoRouter.of(context).push(MyDietsScreen.path)),
|
if (profileModel.roles.contains('consultant'))
|
||||||
if (profileModel.roles.contains('consultant')) _divider(context),
|
_tile(leading: ImageConstant.icnRecipes, title: 'Мои рецепты', onTap: () => GoRouter.of(context).push(MyRecipesScreen.path)),
|
||||||
if (profileModel.roles.contains('consultant'))
|
if (profileModel.roles.contains('consultant')) _divider(context),
|
||||||
_tile(leading: ImageConstant.icnPlans, title: 'Мои планы', onTap: () => GoRouter.of(context).push(MyPlansScreen.path)),
|
if (profileModel.roles.contains('consultant'))
|
||||||
if (!hidePlans) ...[
|
_tile(leading: 'assets/icons/diets.svg', title: 'Мои диеты', onTap: () => GoRouter.of(context).push(MyDietsScreen.path)),
|
||||||
_divider(context),
|
if (profileModel.roles.contains('consultant')) _divider(context),
|
||||||
_tile(
|
if (profileModel.roles.contains('consultant'))
|
||||||
leading: 'assets/icons/finance.svg',
|
_tile(leading: ImageConstant.icnPlans, title: 'Мои планы', onTap: () => GoRouter.of(context).push(MyPlansScreen.path)),
|
||||||
title: 'Мои финансы',
|
if (!hidePlans) ...[
|
||||||
onTap: () {
|
_divider(context),
|
||||||
if (profileModel.roles.contains('consultant')) {
|
_tile(
|
||||||
GoRouter.of(context).push(ConsultantFinancesScreen.path);
|
leading: 'assets/icons/finance.svg',
|
||||||
return;
|
title: 'Мои финансы',
|
||||||
}
|
onTap: () {
|
||||||
GoRouter.of(context).push(UserPurchasesScreen.path);
|
if (profileModel.roles.contains('consultant')) {
|
||||||
},
|
GoRouter.of(context).push(ConsultantFinancesScreen.path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GoRouter.of(context).push(UserPurchasesScreen.path);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (profileModel.roles.contains('consultant')) _divider(context),
|
||||||
|
if (profileModel.roles.contains('consultant'))
|
||||||
|
_tile(
|
||||||
|
leading: 'assets/icons/finance.svg',
|
||||||
|
title: 'Мой рейтинг',
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).push(ConsultantRatingScreen.path);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_divider(context),
|
||||||
|
_tile(
|
||||||
|
leading: ImageConstant.icnGlossary,
|
||||||
|
title: 'Глоссарий',
|
||||||
|
onTap: () async {
|
||||||
|
final passKey = await context.read<MenuCubit>().makePassKey();
|
||||||
|
if (passKey != null && context.mounted) {
|
||||||
|
GoRouter.of(context).push('/glossary-screen', extra: passKey);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_divider(context),
|
||||||
|
_tile(
|
||||||
|
leading: 'assets/icons/notifications.svg',
|
||||||
|
title: 'Уведомления',
|
||||||
|
onTap: () => GoRouter.of(context).pushNamed('notificationsSettingsScreen'),
|
||||||
|
),
|
||||||
|
_divider(context),
|
||||||
|
_tile(leading: ImageConstant.icnSupport, title: 'Поддержка', onTap: () => GoRouter.of(context).push('/support-screen')),
|
||||||
|
_divider(context),
|
||||||
|
_tile(leading: 'assets/icons/blocked_users.svg', title: 'Чёрный список', onTap: () => GoRouter.of(context).pushNamed('blockedUsersScreen')),
|
||||||
|
// _divider(context),
|
||||||
|
// _tile(
|
||||||
|
// leading: ImageConstant.icnDevTools,
|
||||||
|
// title: 'Для разработчиков',
|
||||||
|
// onTap: () {
|
||||||
|
// GoRouter.of(context).pushNamed(DevToolsScreen.name);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
_divider(context),
|
||||||
|
_tile(leading: ImageConstant.icnExit, title: 'Выход', onTap: _onTapLogout(context)),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const AppInfo(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
if (profileModel.roles.contains('consultant')) _divider(context),
|
);
|
||||||
if (profileModel.roles.contains('consultant'))
|
},
|
||||||
_tile(
|
|
||||||
leading: 'assets/icons/finance.svg',
|
|
||||||
title: 'Мой рейтинг',
|
|
||||||
onTap: () {
|
|
||||||
GoRouter.of(context).push(ConsultantRatingScreen.path);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
_divider(context),
|
|
||||||
_tile(leading: ImageConstant.icnGlossary, title: 'Глоссарий', onTap: () => GoRouter.of(context).push('/glossary-screen')),
|
|
||||||
_divider(context),
|
|
||||||
_tile(leading: 'assets/icons/notifications.svg', title: 'Уведомления', onTap: () => GoRouter.of(context).pushNamed('notificationsSettingsScreen')),
|
|
||||||
_divider(context),
|
|
||||||
_tile(leading: ImageConstant.icnSupport, title: 'Поддержка', onTap: () => GoRouter.of(context).push('/support-screen')),
|
|
||||||
_divider(context),
|
|
||||||
_tile(leading: 'assets/icons/blocked_users.svg', title: 'Чёрный список', onTap: () => GoRouter.of(context).pushNamed('blockedUsersScreen')),
|
|
||||||
// _divider(context),
|
|
||||||
// _tile(
|
|
||||||
// leading: ImageConstant.icnDevTools,
|
|
||||||
// title: 'Для разработчиков',
|
|
||||||
// onTap: () {
|
|
||||||
// GoRouter.of(context).pushNamed(DevToolsScreen.name);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
_divider(context),
|
|
||||||
_tile(leading: ImageConstant.icnExit, title: 'Выход', onTap: _onTapLogout(context)),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
const AppInfo(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import 'package:eatvio_app/features/feed/presentation/widgets/plans_filter_botto
|
|||||||
import 'package:eatvio_app/features/my_plans/presentation/cubit/my_plans_cubit.dart';
|
import 'package:eatvio_app/features/my_plans/presentation/cubit/my_plans_cubit.dart';
|
||||||
import 'package:eatvio_app/features/my_plans/presentation/cubit/my_plans_state.dart';
|
import 'package:eatvio_app/features/my_plans/presentation/cubit/my_plans_state.dart';
|
||||||
import 'package:eatvio_app/features/my_plans/presentation/widgets/my_plan_widget.dart';
|
import 'package:eatvio_app/features/my_plans/presentation/widgets/my_plan_widget.dart';
|
||||||
import 'package:eatvio_app/features/my_plans/presentation/widgets/my_plans_tab.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';
|
||||||
@@ -64,9 +63,7 @@ class MyPlansScreenContent extends StatelessWidget {
|
|||||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||||
return [
|
return [
|
||||||
SliverAppBar(
|
SliverAppBar(
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(bottom: Radius.circular(12))),
|
||||||
borderRadius: BorderRadius.vertical(bottom: Radius.circular(12)),
|
|
||||||
),
|
|
||||||
backgroundColor: appTheme.gray100,
|
backgroundColor: appTheme.gray100,
|
||||||
foregroundColor: appTheme.gray100,
|
foregroundColor: appTheme.gray100,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
@@ -76,21 +73,12 @@ class MyPlansScreenContent extends StatelessWidget {
|
|||||||
snap: true,
|
snap: true,
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
bottom: PreferredSize(
|
bottom: PreferredSize(
|
||||||
preferredSize: Size(
|
preferredSize: Size(MediaQuery.sizeOf(context).width, 32),
|
||||||
MediaQuery.sizeOf(context).width,
|
|
||||||
64,
|
|
||||||
),
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 0),
|
padding: const EdgeInsets.only(bottom: 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 8),
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
|
||||||
child: MyPlansTab(),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
@@ -104,20 +92,14 @@ class MyPlansScreenContent extends StatelessWidget {
|
|||||||
_ => activePlansSearchController,
|
_ => activePlansSearchController,
|
||||||
},
|
},
|
||||||
onChanged: (query) {
|
onChanged: (query) {
|
||||||
EasyDebounce.debounce(
|
EasyDebounce.debounce('searchPlans', const Duration(milliseconds: 500), () {
|
||||||
'searchPlans',
|
context.read<MyPlansCubit>().loadPlans(query: query == '' ? null : query);
|
||||||
const Duration(milliseconds: 500),
|
});
|
||||||
() {
|
|
||||||
context.read<MyPlansCubit>().loadPlans(query: query == '' ? null : query);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
AddItemButton(
|
AddItemButton(onTap: () => GoRouter.of(context).pushNamed(CreatePlanScreen.name)),
|
||||||
onTap: () => GoRouter.of(context).pushNamed(CreatePlanScreen.name),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -134,10 +116,7 @@ class MyPlansScreenContent extends StatelessWidget {
|
|||||||
child: BlocBuilder<MyPlansCubit, MyPlansState>(
|
child: BlocBuilder<MyPlansCubit, MyPlansState>(
|
||||||
builder: (BuildContext context, MyPlansState state) {
|
builder: (BuildContext context, MyPlansState state) {
|
||||||
if (state.isLoading) {
|
if (state.isLoading) {
|
||||||
return Scaffold(
|
return Scaffold(backgroundColor: Colors.grey.shade200, body: const Loader());
|
||||||
backgroundColor: Colors.grey.shade200,
|
|
||||||
body: const Loader(),
|
|
||||||
);
|
|
||||||
} else if (state.error != null) {
|
} else if (state.error != null) {
|
||||||
return DataErrorWidget(onReload: () => context.read<MyPlansCubit>().loadPlans());
|
return DataErrorWidget(onReload: () => context.read<MyPlansCubit>().loadPlans());
|
||||||
} else {
|
} else {
|
||||||
@@ -162,11 +141,7 @@ class MyPlansScreenContent extends StatelessWidget {
|
|||||||
Positioned(
|
Positioned(
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 74,
|
bottom: 74,
|
||||||
child: FilterBadge(
|
child: FilterBadge(filterBottomSheet: PlansFilterBottomSheet(myPlansCubit: context.read<MyPlansCubit>())),
|
||||||
filterBottomSheet: PlansFilterBottomSheet(
|
|
||||||
myPlansCubit: context.read<MyPlansCubit>(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,16 +14,13 @@ 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';
|
||||||
import 'package:flutter_html/flutter_html.dart';
|
import 'package:flutter_html/flutter_html.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
// Removed SVG icon usage after switching to text buttons
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
class MyPlanWidget extends StatefulWidget {
|
class MyPlanWidget extends StatefulWidget {
|
||||||
final PlanModel plan;
|
final PlanModel plan;
|
||||||
const MyPlanWidget({
|
const MyPlanWidget({super.key, required this.plan});
|
||||||
super.key,
|
|
||||||
required this.plan,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MyPlanWidget> createState() => _MyPlanWidgetState();
|
State<MyPlanWidget> createState() => _MyPlanWidgetState();
|
||||||
@@ -34,10 +31,7 @@ class _MyPlanWidgetState extends State<MyPlanWidget> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -48,23 +42,14 @@ class _MyPlanWidgetState extends State<MyPlanWidget> {
|
|||||||
onTap: () => GoRouter.of(context).pushNamed('aboutPlanScreen', extra: {'slug': widget.plan.slug, 'navigateToComments': false}),
|
onTap: () => GoRouter.of(context).pushNamed('aboutPlanScreen', extra: {'slug': widget.plan.slug, 'navigateToComments': false}),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(12)),
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(12)),
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(imageUrl: '$baseUrl/storage/${widget.plan.image}', fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width),
|
||||||
imageUrl: '$baseUrl/storage/${widget.plan.image}',
|
|
||||||
fit: BoxFit.fitWidth,
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 16,
|
bottom: 16,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
child: InfoRow(
|
child: InfoRow(plan: widget.plan, itemsBackgroundColor: appTheme.whiteA700, disableDescriptionOfTypes: true, type: ProductType.plan),
|
||||||
plan: widget.plan,
|
|
||||||
itemsBackgroundColor: appTheme.whiteA700,
|
|
||||||
disableDescriptionOfTypes: true,
|
|
||||||
type: ProductType.plan,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -75,19 +60,16 @@ class _MyPlanWidgetState extends State<MyPlanWidget> {
|
|||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Text(
|
child: Text(widget.plan.name, style: TextStyles.textMSemibold.copyWith(color: appTheme.black)),
|
||||||
widget.plan.name,
|
|
||||||
style: TextStyles.textMSemibold.copyWith(color: appTheme.black),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (widget.plan.details.isNotEmpty) ...[
|
if (widget.plan.details.isNotEmpty) ...[
|
||||||
const SizedBox(
|
const SizedBox(height: 12),
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Html(
|
child: Html(
|
||||||
data: widget.plan.details.length > 200 ? '${widget.plan.details.substring(0, 200).replaceAll('\n', '<br>')}...' : widget.plan.details.replaceAll('\n', '<br>'),
|
data: widget.plan.details.length > 200
|
||||||
|
? '${widget.plan.details.substring(0, 200).replaceAll('\n', '<br>')}...'
|
||||||
|
: widget.plan.details.replaceAll('\n', '<br>'),
|
||||||
style: {
|
style: {
|
||||||
"*": Style(
|
"*": Style(
|
||||||
margin: Margins.zero,
|
margin: Margins.zero,
|
||||||
@@ -116,26 +98,61 @@ class _MyPlanWidgetState extends State<MyPlanWidget> {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
// Buttons aligned with MyRecipeWidget: Delete (gray) and Share (blue)
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: CustomOutlinedButton(
|
child: CustomOutlinedButton(
|
||||||
text: switch (state.selectedStateIndex) {
|
onPressed: () async {
|
||||||
1 => s.publish,
|
final result = await context.read<MyPlansCubit>().deletePlan(widget.plan.slug);
|
||||||
_ => s.edit,
|
if (result) {
|
||||||
|
Future.delayed(const Duration(seconds: 3), () {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
showBottomSheetWithBlur(
|
||||||
|
context: context,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const BottomSheetHandlerBar(),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(widget.plan.name, style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||||
|
Text(s.deleted, style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: CustomOutlinedButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
text: 'Хорошо',
|
||||||
|
height: 52,
|
||||||
|
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
|
||||||
|
buttonStyle: ButtonStyle(
|
||||||
|
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||||
|
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
text: 'Удалить',
|
||||||
height: 52,
|
height: 52,
|
||||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.black),
|
||||||
buttonStyle: ButtonStyle(
|
buttonStyle: ButtonStyle(
|
||||||
shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(20))),
|
shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(20))),
|
||||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
backgroundColor: WidgetStatePropertyAll(appTheme.lightGray0),
|
||||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (state.selectedStateIndex == 0) ...[
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 6),
|
Expanded(
|
||||||
CustomOutlinedButton(
|
child: CustomOutlinedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final box = context.findRenderObject() as RenderBox?;
|
final box = context.findRenderObject() as RenderBox?;
|
||||||
await SharePlus.instance.share(
|
await SharePlus.instance.share(
|
||||||
@@ -146,109 +163,14 @@ class _MyPlanWidgetState extends State<MyPlanWidget> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
height: 52,
|
height: 52,
|
||||||
width: 52,
|
|
||||||
leftIcon: SvgPicture.asset(
|
|
||||||
'assets/icons/share2.svg',
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
colorFilter: ColorFilter.mode(appTheme.whiteA700, BlendMode.srcIn),
|
|
||||||
),
|
|
||||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.red),
|
|
||||||
buttonStyle: ButtonStyle(
|
buttonStyle: ButtonStyle(
|
||||||
shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(20))),
|
shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(20))),
|
||||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||||
),
|
),
|
||||||
text: '',
|
text: s.share,
|
||||||
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: CustomOutlinedButton(
|
|
||||||
text: switch (state.selectedStateIndex) {
|
|
||||||
0 => s.removeFromActive,
|
|
||||||
_ => s.edit,
|
|
||||||
},
|
|
||||||
height: 52,
|
|
||||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.black),
|
|
||||||
buttonStyle: ButtonStyle(
|
|
||||||
shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(20))),
|
|
||||||
backgroundColor: WidgetStatePropertyAll(appTheme.lightGray0),
|
|
||||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
CustomOutlinedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final result = await context.read<MyPlansCubit>().deletePlan(widget.plan.slug);
|
|
||||||
if (result) {
|
|
||||||
Future.delayed(const Duration(seconds: 3), () {
|
|
||||||
if (!context.mounted) return;
|
|
||||||
showBottomSheetWithBlur(
|
|
||||||
context: context,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
const BottomSheetHandlerBar(),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
widget.plan.name,
|
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
s.deleted,
|
|
||||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
child: CustomOutlinedButton(
|
|
||||||
onPressed: () {
|
|
||||||
context.pop();
|
|
||||||
},
|
|
||||||
text: 'Хорошо',
|
|
||||||
height: 52,
|
|
||||||
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
|
|
||||||
buttonStyle: ButtonStyle(
|
|
||||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
|
||||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
height: 52,
|
|
||||||
width: 52,
|
|
||||||
leftIcon: SvgPicture.asset(
|
|
||||||
'assets/icons/trash_can.svg',
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.red),
|
|
||||||
buttonStyle: ButtonStyle(
|
|
||||||
shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(20))),
|
|
||||||
backgroundColor: WidgetStatePropertyAll(appTheme.lightGray0),
|
|
||||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
|
||||||
),
|
|
||||||
text: '',
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,71 +1,3 @@
|
|||||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
// File intentionally left minimal after removing tabs for My Plans
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
||||||
import 'package:eatvio_app/core/widgets/animated_option_button.dart';
|
|
||||||
import 'package:eatvio_app/features/my_plans/presentation/cubit/my_plans_cubit.dart';
|
|
||||||
import 'package:eatvio_app/features/my_plans/presentation/cubit/my_plans_state.dart';
|
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
|
|
||||||
class MyPlansTab extends StatefulWidget {
|
// Drafts/published tab UI removed per requirements
|
||||||
const MyPlansTab({super.key, this.additionalOnTap});
|
|
||||||
final void Function()? additionalOnTap;
|
|
||||||
@override
|
|
||||||
State<MyPlansTab> createState() => _MyPlansTabState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyPlansTabState extends State<MyPlansTab> {
|
|
||||||
final List<String> tabTitles = [];
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
final s = S.of(context);
|
|
||||||
if (tabTitles.isEmpty) {
|
|
||||||
tabTitles.add(s.published);
|
|
||||||
tabTitles.add(s.drafted);
|
|
||||||
}
|
|
||||||
super.didChangeDependencies();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return BlocBuilder<MyPlansCubit, MyPlansState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
return Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
height: 48,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: appTheme.whiteA700,
|
|
||||||
borderRadius: BorderRadius.circular(100),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.all(4),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
...List.generate(
|
|
||||||
2,
|
|
||||||
(index) => Expanded(
|
|
||||||
child: AnimatedOptionButton(
|
|
||||||
textStyle: TextStyles.textSMedium,
|
|
||||||
isSelected: state.selectedStateIndex == index,
|
|
||||||
text: tabTitles[index],
|
|
||||||
onTap: () {
|
|
||||||
widget.additionalOnTap?.call();
|
|
||||||
context.read<MyPlansCubit>().changeSelectedStateIndex(index);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class _ChosenPlanFinishedToConsultantWidget extends StatelessWidget {
|
|||||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||||
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.green)),
|
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.green)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
GoRouter.of(context).pushNamed(CardSettingsScreen.name, extra: notification.planId);
|
GoRouter.of(context).push(CardSettingsScreen.path, extra: notification.planId);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
15
lib/features/profile/models/pass_key_params.dart
Normal file
15
lib/features/profile/models/pass_key_params.dart
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'pass_key_params.freezed.dart';
|
||||||
|
part 'pass_key_params.g.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class PassKeyParams with _$PassKeyParams {
|
||||||
|
|
||||||
|
factory PassKeyParams({
|
||||||
|
@JsonKey(name: 'route_name') required String routeName,
|
||||||
|
@JsonKey(name: 'route_params') Map<String, dynamic>? routeParams,
|
||||||
|
}) = _PassKeyParams;
|
||||||
|
|
||||||
|
factory PassKeyParams.fromJson(Map<String, dynamic> json) => _$PassKeyParamsFromJson(json);
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ abstract class ProfileModel with _$ProfileModel {
|
|||||||
@JsonKey(name: "updated_at") DateTime? updatedAt,
|
@JsonKey(name: "updated_at") DateTime? updatedAt,
|
||||||
@JsonKey(name: "is_public_profile", fromJson: parseBool) required bool isPublicProfile,
|
@JsonKey(name: "is_public_profile", fromJson: parseBool) required bool isPublicProfile,
|
||||||
@JsonKey(name: "is_blocked_by_me", fromJson: parseBool) required bool isBlockedByMe,
|
@JsonKey(name: "is_blocked_by_me", fromJson: parseBool) required bool isBlockedByMe,
|
||||||
|
@JsonKey(name: "is_blocked_by_author", fromJson: parseBool) required bool isBlockedByAuthor,
|
||||||
@JsonKey(name: "is_blocked_by_user", fromJson: parseBool, defaultValue: false) required bool isBlockedByUser,
|
@JsonKey(name: "is_blocked_by_user", fromJson: parseBool, defaultValue: false) required bool isBlockedByUser,
|
||||||
@JsonKey(name: 'is_entity_subscribed_by_me') required bool isEntitySubscribedByMe,
|
@JsonKey(name: 'is_entity_subscribed_by_me') required bool isEntitySubscribedByMe,
|
||||||
@JsonKey(name: "slug") required String slug,
|
@JsonKey(name: "slug") required String slug,
|
||||||
|
|||||||
@@ -18,11 +18,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
final ConsultantRepository consultantRepository;
|
final ConsultantRepository consultantRepository;
|
||||||
String _currentPeriod = '1';
|
String _currentPeriod = '1';
|
||||||
|
|
||||||
ProfileCubit({
|
ProfileCubit({required this.profileRepository, required this.chatRepository, required this.consultantRepository}) : super(const ProfileState.loading());
|
||||||
required this.profileRepository,
|
|
||||||
required this.chatRepository,
|
|
||||||
required this.consultantRepository,
|
|
||||||
}) : super(const ProfileState.loading());
|
|
||||||
|
|
||||||
Future<void> getProfileBySlug(String slug) async {
|
Future<void> getProfileBySlug(String slug) async {
|
||||||
emit(const ProfileState.loading());
|
emit(const ProfileState.loading());
|
||||||
@@ -42,9 +38,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getMyProfile({
|
Future<void> getMyProfile({String period = '1'}) async {
|
||||||
String period = '1',
|
|
||||||
}) async {
|
|
||||||
emit(const ProfileState.loading());
|
emit(const ProfileState.loading());
|
||||||
_currentPeriod = period;
|
_currentPeriod = period;
|
||||||
try {
|
try {
|
||||||
@@ -77,15 +71,14 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
profile: (state as ProfileStateLoaded).profile,
|
profile: (state as ProfileStateLoaded).profile,
|
||||||
profileDetails: (state as ProfileStateLoaded).profileDetails,
|
profileDetails: (state as ProfileStateLoaded).profileDetails,
|
||||||
blogPosts: feedBlogPostList,
|
blogPosts: feedBlogPostList,
|
||||||
|
weightPoints: (state as ProfileStateLoaded).weightPoints,
|
||||||
|
circumferencePoints: (state as ProfileStateLoaded).circumferencePoints,
|
||||||
|
consultantInfo: (state as ProfileStateLoaded).consultantInfo,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addCircumference({
|
Future<void> addCircumference({required int chestCircumference, required int waistCircumference, required int hipCircumference}) async {
|
||||||
required int chestCircumference,
|
|
||||||
required int waistCircumference,
|
|
||||||
required int hipCircumference,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
await profileRepository.addCircumference(
|
await profileRepository.addCircumference(
|
||||||
chestCircumference: chestCircumference,
|
chestCircumference: chestCircumference,
|
||||||
@@ -98,9 +91,7 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addWeight({
|
Future<void> addWeight({required double weight}) async {
|
||||||
required double weight,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
await profileRepository.addWeight(weight: weight);
|
await profileRepository.addWeight(weight: weight);
|
||||||
await getMyProfile(period: _currentPeriod);
|
await getMyProfile(period: _currentPeriod);
|
||||||
@@ -109,25 +100,15 @@ class ProfileCubit extends Cubit<ProfileState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> getChatRoomIdBySlug({
|
Future<String?> getChatRoomIdBySlug({required Author author}) async {
|
||||||
required Author author,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
final chatIdOrError = await chatRepository.getChatByUserSlug(author.authorSlug);
|
final chatIdOrError = await chatRepository.getChatByUserSlug(author.authorSlug);
|
||||||
if (chatIdOrError == '404') {
|
if (chatIdOrError == '404') {
|
||||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
AppRouter.navigatorKey.currentContext?.pushNamed('emptyChatScreen', extra: author);
|
||||||
'emptyChatScreen',
|
|
||||||
extra: author,
|
|
||||||
);
|
|
||||||
} else if (chatIdOrError == 'error') {
|
} else if (chatIdOrError == 'error') {
|
||||||
showErrorToast('Ошибка создания чата');
|
showErrorToast('Ошибка создания чата');
|
||||||
} else {
|
} else {
|
||||||
AppRouter.navigatorKey.currentContext?.pushNamed(
|
AppRouter.navigatorKey.currentContext?.pushNamed('chatScreen', extra: {'uuid': chatIdOrError});
|
||||||
'chatScreen',
|
|
||||||
extra: {
|
|
||||||
'uuid': chatIdOrError,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return chatIdOrError;
|
return chatIdOrError;
|
||||||
}
|
}
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import 'dart:io';
|
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/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/enums/complained_content.dart';
|
import 'package:eatvio_app/core/enums/complained_content.dart';
|
||||||
import 'package:eatvio_app/core/permission_handler/permission_handler.dart';
|
import 'package:eatvio_app/core/permission_handler/permission_handler.dart';
|
||||||
|
import 'package:eatvio_app/core/theme/custom_text_style.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/core/widgets/data_error_widget.dart';
|
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
|
||||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||||
@@ -94,30 +94,6 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
isFirstFetch = false;
|
isFirstFetch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверяем, заблокировал ли пользователь меня
|
|
||||||
if (state.profile.isBlockedByUser) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(),
|
|
||||||
body: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(32.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.block, size: 64, color: Colors.grey[400]),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Text(
|
|
||||||
'Пользователь ограничил доступ к своей странице',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500, color: Colors.grey[600]),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return widget.author == null || widget.author!.authorIsMe ? _myProfileScreen(state) : _profileScreen(state);
|
return widget.author == null || widget.author!.authorIsMe ? _myProfileScreen(state) : _profileScreen(state);
|
||||||
} else if (state is ProfileStateError) {
|
} else if (state is ProfileStateError) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -199,11 +175,34 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
),
|
),
|
||||||
_subscriptionsAndSubscribers(state),
|
_subscriptionsAndSubscribers(state),
|
||||||
if (state.profile.badges.isNotEmpty) Padding(padding: const EdgeInsets.only(bottom: 16), child: _badges(state)),
|
if (state.profile.badges.isNotEmpty) Padding(padding: const EdgeInsets.only(bottom: 16), child: _badges(state)),
|
||||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe) _socialLinks(state),
|
if (state.profile.isBlockedByAuthor)
|
||||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe) _education(state),
|
Column(
|
||||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe) _diplomasAndCertificates(state),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !hidePlans && !state.profile.isBlockedByMe) _activePlans(state),
|
children: [
|
||||||
if (state.blogPosts.isNotEmpty)
|
Icon(Icons.block, size: 48, color: appTheme.grey7B),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
'Пользователь ограничил доступ\nк своей странице',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyles.textMSemibold.copyWith(color: appTheme.grey7B),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe && !state.profile.isBlockedByAuthor)
|
||||||
|
_socialLinks(state),
|
||||||
|
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe && !state.profile.isBlockedByAuthor)
|
||||||
|
_education(state),
|
||||||
|
if (state.profile.roles.contains('consultant') && state.consultantInfo != null && !state.profile.isBlockedByMe && !state.profile.isBlockedByAuthor)
|
||||||
|
_diplomasAndCertificates(state),
|
||||||
|
if (state.profile.roles.contains('consultant') &&
|
||||||
|
state.consultantInfo != null &&
|
||||||
|
!hidePlans &&
|
||||||
|
!state.profile.isBlockedByMe &&
|
||||||
|
!state.profile.isBlockedByAuthor)
|
||||||
|
_activePlans(state),
|
||||||
|
if (state.blogPosts.isNotEmpty && !state.profile.isBlockedByAuthor && !state.profile.isBlockedByMe)
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.only(left: 8, top: 16, bottom: 8),
|
padding: EdgeInsets.only(left: 8, top: 16, bottom: 8),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -211,7 +210,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
style: TextStyle(color: Color(0xFF323F4B), fontSize: 24, fontWeight: FontWeight.w600),
|
style: TextStyle(color: Color(0xFF323F4B), fontSize: 24, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_blogPosts(state),
|
if (state.blogPosts.isNotEmpty && !state.profile.isBlockedByAuthor && !state.profile.isBlockedByMe) _blogPosts(state),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'dart:io';
|
|||||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/chosen_diets_pagination_model.dart';
|
import 'package:eatvio_app/features/profile/models/chosen_diets_pagination_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
|
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
|
||||||
|
import 'package:eatvio_app/features/profile/models/pass_key_params.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/sub_model.dart';
|
import 'package:eatvio_app/features/profile/models/sub_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/weight_model.dart';
|
import 'package:eatvio_app/features/profile/models/weight_model.dart';
|
||||||
@@ -154,10 +155,10 @@ class ProfileRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getPassKey(String phone) async {
|
Future<String> getPassKey({required String routeName, Map<String, dynamic>? routeParams}) async {
|
||||||
return (jsonDecode(
|
return (await profileService.getPassKey(
|
||||||
(await profileService.getPassKey(json: '{"route_name": "user_detailz.change-phone-verify", "route_params": {"phone": "$phone"}}')),
|
json: PassKeyParams(routeName: routeName, routeParams: routeParams),
|
||||||
))['key_is']!;
|
)).data['key_is']!;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getMyPhone() async {
|
Future<String> getMyPhone() async {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/chosen_diets_pagination_model.dart';
|
import 'package:eatvio_app/features/profile/models/chosen_diets_pagination_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
|
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
|
||||||
|
import 'package:eatvio_app/features/profile/models/pass_key_params.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/sub_model.dart';
|
import 'package:eatvio_app/features/profile/models/sub_model.dart';
|
||||||
import 'package:eatvio_app/features/profile/models/weight_model.dart';
|
import 'package:eatvio_app/features/profile/models/weight_model.dart';
|
||||||
@@ -75,7 +76,7 @@ abstract class ProfileService {
|
|||||||
Future<ChosenDietsPaginationModel> getChosenDiets();
|
Future<ChosenDietsPaginationModel> getChosenDiets();
|
||||||
|
|
||||||
@POST('/api/profile/make_pass_key')
|
@POST('/api/profile/make_pass_key')
|
||||||
Future<String> getPassKey({@Body() required String json});
|
Future<HttpResponse> getPassKey({@Body() required PassKeyParams json});
|
||||||
|
|
||||||
@GET('/api/profile/my_phone')
|
@GET('/api/profile/my_phone')
|
||||||
Future<String> getMyPhone();
|
Future<String> getMyPhone();
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ class _UserDetailsContentState extends State<UserDetailsContent> {
|
|||||||
children: [
|
children: [
|
||||||
Text(s.has_hypo, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
Text(s.has_hypo, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CustomTextFormField(readOnly: true, controller: TextEditingController(text: profileDetails.hasHypo.toString())),
|
CustomTextFormField(readOnly: true, controller: TextEditingController(text: profileDetails.hasHypo ? 'да' : 'нет')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -242,7 +242,7 @@ class _UserDetailsContentState extends State<UserDetailsContent> {
|
|||||||
children: [
|
children: [
|
||||||
Text(s.has_hyper, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
Text(s.has_hyper, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
CustomTextFormField(readOnly: true, controller: TextEditingController(text: profileDetails.hasHyper.toString())),
|
CustomTextFormField(readOnly: true, controller: TextEditingController(text: profileDetails.hasHyper ? 'да' : 'нет')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ class S {
|
|||||||
static const AppLocalizationDelegate delegate = AppLocalizationDelegate();
|
static const AppLocalizationDelegate delegate = AppLocalizationDelegate();
|
||||||
|
|
||||||
static Future<S> load(Locale locale) {
|
static Future<S> load(Locale locale) {
|
||||||
final name = (locale.countryCode?.isEmpty ?? false)
|
final name =
|
||||||
? locale.languageCode
|
(locale.countryCode?.isEmpty ?? false)
|
||||||
: locale.toString();
|
? locale.languageCode
|
||||||
|
: locale.toString();
|
||||||
final localeName = Intl.canonicalizedLocale(name);
|
final localeName = Intl.canonicalizedLocale(name);
|
||||||
return initializeMessages(localeName).then((_) {
|
return initializeMessages(localeName).then((_) {
|
||||||
Intl.defaultLocale = localeName;
|
Intl.defaultLocale = localeName;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: eatvio_app
|
name: eatvio_app
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
version: 1.2.12+72
|
version: 1.2.14+74
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
@@ -74,6 +74,8 @@ dependencies:
|
|||||||
flutter_dotenv: ^5.2.1
|
flutter_dotenv: ^5.2.1
|
||||||
uuid: ^4.5.1
|
uuid: ^4.5.1
|
||||||
appmetrica_plugin: ^3.3.0
|
appmetrica_plugin: ^3.3.0
|
||||||
|
vk_id: ^1.0.3
|
||||||
|
flutter_login_yandex: ^0.0.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^2.7.0
|
build_runner: ^2.7.0
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ void main() {
|
|||||||
badges: [],
|
badges: [],
|
||||||
subscriptions: [],
|
subscriptions: [],
|
||||||
subscribers: [],
|
subscribers: [],
|
||||||
|
isBlockedByAuthor: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -72,23 +73,17 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getBlogPostByAuthorSlug', () async {
|
test('getBlogPostByAuthorSlug', () async {
|
||||||
when(mockProfileService.getBlogPostByAuthorSlug(slug: '')).thenAnswer(
|
when(mockProfileService.getBlogPostByAuthorSlug(slug: '')).thenAnswer((_) async => []);
|
||||||
(_) async => [],
|
|
||||||
);
|
|
||||||
expect(await mockProfileService.getBlogPostByAuthorSlug(slug: 'slug'), isA<List<FeedBlogPostModel>>());
|
expect(await mockProfileService.getBlogPostByAuthorSlug(slug: 'slug'), isA<List<FeedBlogPostModel>>());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getWeight', () async {
|
test('getWeight', () async {
|
||||||
when(mockProfileService.getWeight(period: '')).thenAnswer(
|
when(mockProfileService.getWeight(period: '')).thenAnswer((_) async => []);
|
||||||
(_) async => [],
|
|
||||||
);
|
|
||||||
expect(await mockProfileService.getWeight(period: ''), isA<List<WeightModel>>());
|
expect(await mockProfileService.getWeight(period: ''), isA<List<WeightModel>>());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getCircumferences', () async {
|
test('getCircumferences', () async {
|
||||||
when(mockProfileService.getCircumferences(period: '')).thenAnswer(
|
when(mockProfileService.getCircumferences(period: '')).thenAnswer((_) async => []);
|
||||||
(_) async => [],
|
|
||||||
);
|
|
||||||
expect(await mockProfileService.getCircumferences(period: ''), isA<List<CircumferenceModel>>());
|
expect(await mockProfileService.getCircumferences(period: ''), isA<List<CircumferenceModel>>());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user