瀏覽代碼

buid && feat: reimport some components

Bax 6 天之前
父節點
當前提交
2947e4e1c6
共有 15 個文件被更改,包括 339 次插入5 次删除
  1. 1 0
      mobile_app/new/wabi/app/src/main/AndroidManifest.xml
  2. 28 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/navigation/NavigationProvider.kt
  3. 16 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/repository/PrefManager.kt
  4. 5 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/supabase/SupabaseService.kt
  5. 8 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/supabase/SupabaseServiceImpl.kt
  6. 30 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/supabase/SupabaseServiceProvider.kt
  7. 29 4
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/MainActivity.kt
  8. 11 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/MainActivityViewModel.kt
  9. 1 1
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/StartApp.kt
  10. 42 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/ButtonBack.kt
  11. 37 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/ButtonLink.kt
  12. 47 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/MainButton.kt
  13. 50 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/SearchButton.kt
  14. 12 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/texts/Error/ErrorList.kt
  15. 22 0
      mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/texts/Error/ErrorPrint.kt

+ 1 - 0
mobile_app/new/wabi/app/src/main/AndroidManifest.xml

@@ -5,6 +5,7 @@
     <uses-permission android:name="android.permission.INTERNET" />
 
     <application
+        android:name=".view.WabiApp"
         android:allowBackup="true"
         android:dataExtractionRules="@xml/data_extraction_rules"
         android:fullBackupContent="@xml/backup_rules"

+ 28 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/navigation/NavigationProvider.kt

@@ -0,0 +1,28 @@
+package com.example.wabi.domain.navigation
+
+import androidx.navigation.NavHostController
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import javax.inject.Inject
+
+@Module
+@InstallIn(SingletonComponent::class)
+class NavigationProvider @Inject constructor() {
+    @Provides
+    fun goToNextScreen(
+        navHostController: NavHostController,
+        whereFrom: String,
+        where: String
+    ): Boolean {
+        navHostController.popBackStack()
+        navHostController.navigate(where) {
+            popUpTo(whereFrom) {
+                inclusive = true
+            }
+        }
+
+        return true
+    }
+}

+ 16 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/repository/PrefManager.kt

@@ -0,0 +1,16 @@
+package com.example.wabi.domain.repository
+
+import android.content.Context
+import android.content.SharedPreferences
+
+object PrefManager {
+    private lateinit var localDataSp: SharedPreferences
+
+    fun initPrefManager(context: Context) {
+        localDataSp = context.getSharedPreferences("root", Context.MODE_PRIVATE)
+    }
+
+    var onboard: Boolean
+        get() = localDataSp.getBoolean("onboard", true)
+        set(value) = localDataSp.edit().putBoolean("onboard", value).apply()
+}

+ 5 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/supabase/SupabaseService.kt

@@ -0,0 +1,5 @@
+package com.example.wabi.domain.supabase
+
+interface SupabaseService {
+
+}

+ 8 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/supabase/SupabaseServiceImpl.kt

@@ -0,0 +1,8 @@
+package com.example.wabi.domain.supabase
+
+import javax.inject.Inject
+
+
+class SupabaseServiceImpl @Inject constructor(private val supabase: SupabaseServiceProvider) : SupabaseService {
+
+}

+ 30 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/domain/supabase/SupabaseServiceProvider.kt

@@ -0,0 +1,30 @@
+package com.example.wabi.domain.supabase
+
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.components.SingletonComponent
+import io.github.jan.supabase.SupabaseClient
+import io.github.jan.supabase.auth.Auth
+import io.github.jan.supabase.createSupabaseClient
+import io.github.jan.supabase.postgrest.Postgrest
+import io.github.jan.supabase.realtime.Realtime
+import io.github.jan.supabase.storage.Storage
+
+@Module
+@InstallIn(SingletonComponent::class)
+class SupabaseServiceProvider {
+
+    @Provides
+    fun supabaseClient(): SupabaseClient {
+        return createSupabaseClient(
+            supabaseUrl = "https://reusjamfhgxymxwkykmb.supabase.co",
+            supabaseKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJldXNqYW1maGd4eW14d2t5a21iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkwNTUzMDMsImV4cCI6MjA0NDYzMTMwM30.TiQVqChKE8vs-HLtok_-8BrIy7o4pDEiBuziKcvc1Qc"
+        ) {
+            install(Auth)
+            install(Postgrest)
+            install(Realtime)
+            install(Storage)
+        }
+    }
+}

+ 29 - 4
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/MainActivity.kt

@@ -8,8 +8,17 @@ import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.padding
 import androidx.compose.material3.Scaffold
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
 import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
 import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
+import androidx.hilt.navigation.compose.hiltViewModel
+import androidx.navigation.NavHostController
+import androidx.navigation.compose.rememberNavController
+import com.example.wabi.domain.navigation.Navigation
+import com.example.wabi.domain.repository.PrefManager
 import com.example.wabi.ui.theme.WabiTheme
 import dagger.hilt.android.AndroidEntryPoint
 
@@ -21,15 +30,31 @@ class MainActivity : ComponentActivity() {
         enableEdgeToEdge()
 
         setContent {
-            WabiTheme {
-                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
+            val context = LocalContext.current
+            val navHostController = rememberNavController()
+            val isBottomBar = remember { mutableStateOf(false) }
+            val isTopBar = remember { mutableStateOf(false) }
+            PrefManager.initPrefManager(context)
+
+            WabiTheme(themeState = 0) {
+                Scaffold(modifier = Modifier.fillMaxSize(),
+                    containerColor = WabiTheme.colors.backgroundColor,
+                    bottomBar = {},
+                    topBar = {}) { innerPadding ->
                     Box(
-                        modifier = Modifier.padding(innerPadding)
+                        modifier = Modifier
+                            .fillMaxSize()
+                            .padding(innerPadding)
                     ) {
-
+                        InitApp(navHostController)
                     }
                 }
             }
         }
     }
+}
+
+@Composable
+fun InitApp(navHostController: NavHostController, vm: MainActivityViewModel = hiltViewModel()) {
+    Navigation(navHostController)
 }

+ 11 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/MainActivityViewModel.kt

@@ -0,0 +1,11 @@
+package com.example.wabi.view
+
+import androidx.lifecycle.ViewModel
+import com.example.wabi.domain.navigation.NavigationProvider
+import dagger.hilt.android.lifecycle.HiltViewModel
+import javax.inject.Inject
+
+@HiltViewModel
+class MainActivityViewModel @Inject constructor(private val nav: NavigationProvider) : ViewModel() {
+
+}

+ 1 - 1
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/StartApp.kt

@@ -3,6 +3,6 @@ package com.example.wabi.view
 import android.app.Application
 import dagger.hilt.android.HiltAndroidApp
 
-
+//инициализация hilt
 @HiltAndroidApp
 class WabiApp : Application()

+ 42 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/ButtonBack.kt

@@ -0,0 +1,42 @@
+package com.example.wabi.view.components.buttons
+
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.size
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.Icon
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.res.vectorResource
+import androidx.compose.ui.unit.dp
+import com.example.wabi.R
+import com.example.wabi.ui.theme.WabiTheme
+
+//кнопка перехода "назад"
+@Composable
+fun ButtonBack(
+    onClick: () -> Unit, modifier: Modifier = Modifier
+) {
+    Box(
+        modifier = modifier
+    ) {
+        Button(
+            onClick = onClick, modifier = Modifier.size(50.dp), border = BorderStroke(
+                width = 2.dp, color = WabiTheme.colors.mainColor
+            ), contentPadding = PaddingValues(10.dp), colors = ButtonDefaults.buttonColors(
+                containerColor = WabiTheme.colors.backgroundColor,
+                contentColor = WabiTheme.colors.mainColor
+            )
+        ) {
+            Icon(
+                imageVector = ImageVector.vectorResource(id = R.drawable.left_vector),
+                contentDescription = "Back",
+                modifier = Modifier.fillMaxSize()
+            )
+        }
+    }
+}

+ 37 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/ButtonLink.kt

@@ -0,0 +1,37 @@
+package com.example.wabi.view.components.buttons
+
+import android.annotation.SuppressLint
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import com.example.wabi.ui.theme.WabiTheme
+
+//функция, создающая кнопку в виде сслыки (подчёркнутого текста)
+@Composable
+fun ButtonLink(
+    onClick: () -> Unit,
+    textContent: String,
+    colorContent: Color = WabiTheme.colors.mainColor,
+    @SuppressLint("ModifierParameter") modifier: Modifier = Modifier,
+    modifierContetnt: Modifier = Modifier,
+    enabled: Boolean = true
+): Unit {
+    Button(
+        onClick = onClick,
+        colors = ButtonDefaults.buttonColors(
+            contentColor = colorContent,
+            containerColor = Color.Transparent
+        ),
+        modifier = modifier,
+        enabled = enabled
+    ) {
+        Text(
+            text = textContent,
+            style = WabiTheme.fonts.link,
+            modifier = modifierContetnt
+        )
+    }
+}

+ 47 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/MainButton.kt

@@ -0,0 +1,47 @@
+package com.example.wabi.view.components.buttons
+
+import android.annotation.SuppressLint
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonColors
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.dp
+import com.example.wabi.ui.theme.WabiTheme
+
+//функция, создающая кнопку под  основной стить
+@Composable
+fun MainButton(
+    onClick: () -> Unit,
+    enabled: Boolean = true,
+    color: Color = WabiTheme.colors.mainColor,
+    textContent: String,
+    colorContent: Color = WabiTheme.colors.backgroundColor,
+    @SuppressLint("ModifierParameter") modifier: Modifier = Modifier,
+    modifierContetnt: Modifier = Modifier
+): Unit {
+    Button(
+        border = BorderStroke(
+            2.dp,
+            color = color
+        ),
+        onClick = onClick,
+        enabled = enabled,
+        colors = ButtonColors(
+            containerColor = color,
+            contentColor = colorContent,
+            disabledContainerColor = WabiTheme.colors.translucentColor,
+            disabledContentColor = colorContent
+        ),
+        modifier = modifier
+    ) {
+        Text(
+            text = textContent,
+            style = WabiTheme.fonts.buttonFont,
+            color = colorContent,
+            modifier = modifierContetnt
+        )
+    }
+}

+ 50 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/buttons/SearchButton.kt

@@ -0,0 +1,50 @@
+package com.example.wabi.view.components.buttons
+
+import android.annotation.SuppressLint
+import androidx.compose.foundation.BorderStroke
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material3.Button
+import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import com.example.wabi.ui.theme.WabiTheme
+
+//кнопки панели поиска
+@Composable
+fun SearchButton(
+    onClick: () -> Unit,
+    enabled: Boolean = true,
+    textContent: String,
+    @SuppressLint("ModifierParameter") modifier: Modifier = Modifier
+) {
+    Button(
+        onClick = onClick,
+        modifier = modifier,
+        shape = RoundedCornerShape(10.dp),
+        enabled = enabled,
+        colors = ButtonDefaults.buttonColors(
+            contentColor = WabiTheme.colors.mainColor,
+            containerColor = WabiTheme.colors.backgroundColor,
+            disabledContentColor = WabiTheme.colors.translucentColor,
+            disabledContainerColor = WabiTheme.colors.backgroundColor.copy(alpha = 0.5f)
+        ),
+        border = BorderStroke(
+            width = 3.dp, color = if (enabled) {
+                WabiTheme.colors.accentColorOne
+            } else {
+                WabiTheme.colors.accentColorOne.copy(alpha = 0.7f)
+            }
+        )
+    ) {
+        Text(
+            text = textContent,
+            style = WabiTheme.fonts.forTextField,
+            textAlign = TextAlign.Center,
+            fontSize = 15.sp
+        )
+    }
+}

+ 12 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/texts/Error/ErrorList.kt

@@ -0,0 +1,12 @@
+package com.example.wabi.view.components.texts.Error
+
+//список отображаемых ошибок
+object ErrorList {
+    val errorPassOrEmail = "Пароль или почта не верны!"
+    val emailNoCorrect = "Введёная почта не корректна!"
+    val passwordNoCorrect = "Пароль должен быть больше 5 символов!"
+    val existAccountWithEmail = "Акккаунт с данной почтой уже существует!"
+    val emailNotExists = "Аккаунта с данной почтной не существует"
+    val passDontMatch = "Пароли не совпадают!"
+    val noCorrectCode = "Не верный код!"
+}

+ 22 - 0
mobile_app/new/wabi/app/src/main/java/com/example/wabi/view/components/texts/Error/ErrorPrint.kt

@@ -0,0 +1,22 @@
+package com.example.wabi.view.components.texts.Error
+
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.style.TextAlign
+import com.example.wabi.ui.theme.WabiTheme
+
+//вывод ошибки
+@Composable
+fun ErrorPrint(
+    modifier: Modifier = Modifier, text: String
+) {
+    Text(
+        text = text,
+        style = WabiTheme.fonts.error,
+        modifier = modifier,
+        textAlign = TextAlign.Center,
+        minLines = 2,
+        maxLines = 2
+    )
+}