Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_function_naming_ignore_when_annotated_with = Composable
ktlint_standard_annotation = disabled
ktlint_standard_function-expression-body = disabled
27 changes: 27 additions & 0 deletions .github/workflows/pr_checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Checks for pr
run-name: Checks for pr "${{ github.event.pull_request.title }}" by ${{ github.actor }}

on:
pull_request:

# cancel previous running work flow on new one with same workflow name and pull_request_number
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
ktlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.2.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
- name: run ktlint
run: |
ktlint --reporter=checkstyle,output=build/ktlint-report.xml
continue-on-error: true
- uses: yutailang0119/action-ktlint@v4
with:
report-path: build/*.xml # Support glob patterns by https://www.npmjs.com/package/@actions/glob
ignore-warnings: true # Ignore Lint Warnings
continue-on-error: false # If annotations contain error of severity, action-ktlint exit 1.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}
Expand Down Expand Up @@ -94,4 +94,4 @@ dependencies {
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class FlowerAndroidApp : Application()
class FlowerAndroidApp : Application()
4 changes: 2 additions & 2 deletions app/src/main/java/com/shurdev/flowerapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import com.shurdev.flowerapp.presentation.FlowerApp
import com.shurdev.ui_kit.theme.FlowerAppTheme
import com.shurdev.uiKit.theme.FlowerAppTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand All @@ -19,4 +19,4 @@ class MainActivity : ComponentActivity() {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,29 @@ package com.shurdev.flowerapp.presentation

import com.shurdev.flowerapp.R
import com.shurdev.gallery.navigation.GalleryNavGraph
import com.shurdev.my_plants.navigation.MyPlantsNavGraph
import com.shurdev.myPlants.navigation.MyPlantsNavGraph
import kotlinx.serialization.Serializable

@Serializable
sealed class BottomNavigationItems<T>(
val name: String,
val selectedIconResId: Int,
val unSelectedIconResId: Int,
val route: T
val route: T,
) {

@Serializable
data object MyPlants : BottomNavigationItems<MyPlantsNavGraph>(
name = "Мои растения",
selectedIconResId = R.drawable.icon_home_filled,
unSelectedIconResId = R.drawable.icon_home_unfilled,
route = MyPlantsNavGraph
route = MyPlantsNavGraph,
)

@Serializable
data object Gallery : BottomNavigationItems<GalleryNavGraph>(
name = "Галерея",
selectedIconResId = R.drawable.icon_flower_filled,
unSelectedIconResId = R.drawable.icon_flower_unfilled,
route = GalleryNavGraph
route = GalleryNavGraph,
)

// TODO
/*
@Serializable
data object Settings : BottomNavigationItems<SettingsGraph>{

}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import androidx.navigation.compose.rememberNavController
import com.shurdev.flowerapp.presentation.composables.AppBottomNavigation
import com.shurdev.gallery.navigation.galleryNavGraph
import com.shurdev.gallery.navigation.navigateToGalleryPlantDetailsScreen
import com.shurdev.my_plants.navigation.MyPlantsNavGraph
import com.shurdev.my_plants.navigation.myPlantsNavGraph
import com.shurdev.my_plants.navigation.navigateToMyPlantDetailsScreen
import com.shurdev.myPlants.navigation.MyPlantsNavGraph
import com.shurdev.myPlants.navigation.myPlantsNavGraph
import com.shurdev.myPlants.navigation.navigateToMyPlantDetailsScreen

@Composable
fun FlowerApp() {
Expand All @@ -23,30 +23,29 @@ fun FlowerApp() {
BottomAppBar {
AppBottomNavigation(navController)
}
}
},
) { padding ->
NavHost(
modifier = Modifier.padding(padding),
navController = navController,
startDestination = MyPlantsNavGraph,
) {

galleryNavGraph(
onPop = navController::navigateUp,
onPlantClick = { plant ->
plant.id?.let {
navController.navigateToGalleryPlantDetailsScreen(plantId = it)
}
}
},
)

myPlantsNavGraph(
onPlantClick = { plant ->
plant.id?.let {
navController.navigateToMyPlantDetailsScreen(plantId = it)
}
}
},
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,38 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import com.shurdev.flowerapp.presentation.BottomNavigationItems

@Composable
fun AppBottomNavigation(navController: NavController) {

fun AppBottomNavigation(
navController: NavController,
modifier: Modifier = Modifier,
) {
val bottomNavigationItems = remember {
listOf(
BottomNavigationItems.MyPlants,
BottomNavigationItems.Gallery,
)
}

NavigationBar {
NavigationBar(
modifier = modifier,
) {
val currentDestination = navController.currentBackStackEntryAsState().value?.destination

bottomNavigationItems.forEach { item ->

val isSelected = currentDestination?.hierarchy?.any {
it.hasRoute(item.route::class)
} ?: false
val isSelected =
currentDestination?.hierarchy?.any {
it.hasRoute(item.route::class)
} ?: false

NavigationBarItem(
icon = {
Icon(
modifier = Modifier.size(24.dp),
painter = painterResource(
id = if (isSelected) item.selectedIconResId else item.unSelectedIconResId
),
contentDescription = item.name
painter =
painterResource(
id = if (isSelected) item.selectedIconResId else item.unSelectedIconResId,
),
contentDescription = item.name,
)
},
label = {
Expand All @@ -58,8 +64,8 @@ fun AppBottomNavigation(navController: NavController) {
launchSingleTop = true
// restoreState = true
}
}
},
)
}
}
}
}
17 changes: 0 additions & 17 deletions app/src/test/java/com/shurdev/flowerapp/ExampleUnitTest.kt

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ plugins {
alias(libs.plugins.jetbrains.kotlin.jvm) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.android.library) apply false
}
}
2 changes: 1 addition & 1 deletion data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ dependencies {
// Retrofit
implementation(libs.retrofit)
implementation(libs.converter.gson)
}
}
3 changes: 1 addition & 2 deletions data/src/main/java/com/shurdev/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import dagger.hilt.android.scopes.ViewModelScoped
@Module
@InstallIn(ViewModelComponent::class)
interface RepositoryModule {

@Binds
@ViewModelScoped
fun bindPlantRepository(impl: PlantRepositoryImpl): PlantRepository
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.shurdev.domain.repositories.PlantRepository
import javax.inject.Inject

class PlantRepositoryImpl @Inject constructor() : PlantRepository {

override suspend fun getPlants(filters: PlantFilters?): List<Plant> {
return plants.filter { item ->
filters?.let {
Expand All @@ -23,12 +22,15 @@ class PlantRepositoryImpl @Inject constructor() : PlantRepository {
name = "Подсолнух обыкновенный",
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"
.repeat(10),
imageLink = "https://cdn.britannica.com/84/73184-050-05ED59CB/Sunflower-field-Fargo-North-Dakota.jpg"
imageLink = "https://cdn.britannica.com/84/73184-050-05ED59CB/Sunflower-field-Fargo-North-Dakota.jpg",
)
}

private fun doesPlantMatchFilters(plant: Plant, filters: PlantFilters): Boolean {
return plant.name.contains(filters.name ?: "", ignoreCase = true)
|| plant.description.contains(filters.description ?: "", ignoreCase = true)
private fun doesPlantMatchFilters(
plant: Plant,
filters: PlantFilters,
): Boolean {
return plant.name.contains(filters.name ?: "", ignoreCase = true) ||
plant.description.contains(filters.description ?: "", ignoreCase = true)
}
}
}
2 changes: 1 addition & 1 deletion domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ plugins {

dependencies {
implementation(libs.kotlinx.coroutines.core)
}
}
2 changes: 1 addition & 1 deletion domain/src/main/java/com/shurdev/domain/models/Plant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ data class Plant(
val name: String,
val description: String,
val imageLink: String,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.shurdev.domain.models

data class PlantFilters(
val name: String?,
val description: String?
val description: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ interface PlantRepository {
suspend fun getPlants(filters: PlantFilters? = null): List<Plant>

suspend fun getPlantById(id: Int): Plant?
}
}
2 changes: 1 addition & 1 deletion features/gallery/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ dependencies {
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import androidx.compose.ui.unit.dp

@Composable
internal fun PlantCategoriesList(
modifier: Modifier = Modifier,
categories: List<String>,
onCategoryClick: (String) -> Unit
onCategoryClick: (String) -> Unit,
modifier: Modifier = Modifier,
) {
LazyRow(
modifier = modifier
.padding(top = 12.dp),
contentPadding = PaddingValues(start = 16.dp)
contentPadding = PaddingValues(start = 16.dp),
) {
items(categories) { category ->
PlantCategoryItem(
category = category,
onCategoryClick = onCategoryClick
onCategoryClick = onCategoryClick,
)
}
}
}
}
Loading