Skip to content

Commit

Permalink
Merge pull request #76 from eshc123/dev
Browse files Browse the repository at this point in the history
[RELEASE]
  • Loading branch information
eshc123 authored May 4, 2024
2 parents 434e607 + 0ac4dd2 commit 09f78d7
Show file tree
Hide file tree
Showing 92 changed files with 2,958 additions and 1,967 deletions.
18 changes: 9 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ dependencies {
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.lifecycle.viewmodel.compose)

implementation(platform("androidx.compose:compose-bom:2024.02.02"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation(platform(libs.compose.bom))
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.compose.material3)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform("androidx.compose:compose-bom:2024.02.02"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
androidTestImplementation(platform(libs.compose.bom))
androidTestImplementation(libs.compose.ui.test.junit4)
debugImplementation(libs.compose.ui.tooling)
debugImplementation(libs.compose.ui.test.manifest)

implementation(libs.androidx.navigation.compose)

Expand Down
41 changes: 29 additions & 12 deletions app/src/main/java/com/eshc/goonersapp/ui/GnrApp.kt
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
package com.eshc.goonersapp.ui

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
Expand All @@ -39,6 +36,8 @@ import com.eshc.goonersapp.core.designsystem.component.TopLevelTopBar
import com.eshc.goonersapp.core.designsystem.iconpack.IcInfo
import com.eshc.goonersapp.core.designsystem.iconpack.IcSearch
import com.eshc.goonersapp.core.designsystem.iconpack.IcUser
import com.eshc.goonersapp.core.designsystem.theme.ColorFF181818
import com.eshc.goonersapp.core.designsystem.theme.GnrTypography
import com.eshc.goonersapp.feature.home.navigation.navigateToHome
import com.eshc.goonersapp.feature.login.navigation.navigateToLogin
import com.eshc.goonersapp.feature.match.navigation.navigateToMatch
Expand Down Expand Up @@ -136,6 +135,7 @@ fun GnrApp(
bottomBar = {
GnrBottomBar(
destinations = TopLevelDestination.entries,
currentDestination = navController.currentBackStackEntryAsState().value?.destination,
onNavigateToDestination = {
val topLevelNavOptions = navOptions {
popUpTo(navController.graph.findStartDestination().id) {
Expand Down Expand Up @@ -184,33 +184,50 @@ fun GnrTopLevelBar(
fun GnrBottomBar(
destinations: List<TopLevelDestination>,
onNavigateToDestination: (TopLevelDestination) -> Unit,
currentDestination: NavDestination?,
modifier: Modifier = Modifier
) {
GnrNavigationBar(
modifier = modifier
) {
destinations.forEach { destination ->
val selected = currentDestination.isTopLevelDestinationInHierarchy(destination)

GnrNavigationBarItem(
selected = false,
selected = selected,
onClick = {
onNavigateToDestination(destination)
},
icon = {
Icon(
modifier = Modifier.padding(bottom = 4.dp).heightIn(max = 18.dp),
imageVector = destination.unselectedIcon,
tint = Color(0xFF888888),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
selectedIcon = {
Icon(
modifier = Modifier.padding(bottom = 4.dp).heightIn(max = 18.dp),
imageVector = destination.selectedIcon,
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
label = {
Text(
text = stringResource(id = destination.iconTextId),
style = GnrTypography.body2Regular.copy(
color = if(selected) ColorFF181818 else Color(0xFF888888)
)
)
}
)
}

}
}
}

private fun NavDestination?.isTopLevelDestinationInHierarchy(destination: TopLevelDestination) =
this?.hierarchy?.any {
it.route?.contains(destination.name, true) ?: false
} ?: false
46 changes: 7 additions & 39 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.hilt.android)
id("java-library")
alias(libs.plugins.org.jetbrains.kotlin.jvm)
alias(libs.plugins.kotlin.kapt)
}

android {
namespace = "com.eshc.goonersapp.core.common"
compileSdk = 34

defaultConfig {
minSdk = 26

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.appcompat)
implementation(libs.material)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
implementation(libs.hilt.android)
implementation(libs.hilt.core)
implementation(libs.kotlinx.coroutines)
kapt(libs.hilt.compiler)
}
Empty file removed core/common/consumer-rules.pro
Empty file.
21 changes: 0 additions & 21 deletions core/common/proguard-rules.pro

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions core/common/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.eshc.goonersapp.core.domain.model.DataResult
import com.eshc.goonersapp.core.domain.model.match.Match
import com.eshc.goonersapp.core.domain.model.match.MatchInformation
import com.eshc.goonersapp.core.domain.model.match.MatchRecently
import com.eshc.goonersapp.core.domain.model.match.MatchUpcoming
import com.eshc.goonersapp.core.domain.repository.MatchRepository
import com.eshc.goonersapp.core.network.fake.FakeMatchDataSource
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -48,7 +47,7 @@ class FakeMatchRepositoryImpl @Inject constructor(
emit(result)
}

override fun getUpcomingMatches(): Flow<DataResult<List<MatchUpcoming>>> = flow {
override fun getUpcomingMatches(): Flow<DataResult<List<Match>>> = flow {
val result = fakeMatchDataSource
.getUpcomingMatches()
.toDataResult { remote -> remote.map { response -> response.toModel() } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import com.eshc.goonersapp.core.domain.model.match.Match
import com.eshc.goonersapp.core.domain.model.match.MatchDetail
import com.eshc.goonersapp.core.domain.model.match.MatchInformation
import com.eshc.goonersapp.core.domain.model.match.MatchRecently
import com.eshc.goonersapp.core.domain.model.match.MatchUpcoming
import com.eshc.goonersapp.core.domain.model.match.NotablePlayer
import com.eshc.goonersapp.core.domain.model.match.Performance
import com.eshc.goonersapp.core.network.model.match.RemoteMatchDetail
import com.eshc.goonersapp.core.network.model.match.RemoteMatchInformation
import com.eshc.goonersapp.core.network.model.match.RemoteMatchTeam
import com.eshc.goonersapp.core.network.model.match.RemoteMatchUpcoming
import com.eshc.goonersapp.core.network.model.match.RemoteMatch
import com.eshc.goonersapp.core.network.model.match.RemoteRecentlyMatch

/**
* [RemoteMatchTeam] Mapper
* - Mapping [RemoteMatchTeam] to [Match]
* [RemoteMatch] Mapper
* - Mapping [RemoteMatch] to [Match]
*/
fun RemoteMatchTeam.toModel() = Match(
fun RemoteMatch.toModel() = Match(
id = matchId,
homeTeamId = homeTeamId,
homeTeamName = homeTeamName,
Expand All @@ -33,28 +31,10 @@ fun RemoteMatchTeam.toModel() = Match(
awayScore = awayScore,
round = round,
isFinished = isFinished == 1,
stadiumName = venueName,
stadiumName = venueName.toString(),
leagueImageUrl = leagueImage
)

/**
* [RemoteMatchUpcoming] Mapper
* - Mapping [RemoteMatchUpcoming] to [MatchUpcoming]
*/
fun RemoteMatchUpcoming.toModel() = MatchUpcoming(
matchId = matchId,
homeTeamId = homeTeamId,
homeTeamNickname = homeTeamNickname,
homeTeamName = homeTeamName,
homeTeamImageUrl = homeTeamImage,
awayTeamId = awayTeamId,
awayTeamNickname = awayTeamNickname,
awayTeamName = awayTeamName,
awayTeamImageUrl = awayTeamImage,
matchDate = matchDate,
stadiumName = stadiumName,
leagueImageUrl = leagueImage
)

/**
* [RemoteMatchInformation] Mapper
Expand Down Expand Up @@ -88,13 +68,12 @@ fun RemoteMatchInformation.toModel() = MatchInformation(
positionInitial = remote.positionInitial
)
},
performance = performance.map { remote ->
Performance(
result = remote.result,
count = remote.count,
opponentImageUrl = remote.opponentImage
)
}
performance = Performance(
opponentImageUrl = performance.opponentImage,
win = performance.win,
draw = performance.draw,
lose = performance.lose
)
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ fun RemotePlayer.toModel() = Player(
position = position ?: "",
positionInitial = positionInitial ?: "",
positionCategory = positionCategory ?: "",
nationality = nationality ?: ""
nationality = nationality ?: "",
nationalityImageUrl = nationalityImageUrl ?: ""
)

fun RemotePlayer.toEntity() = PlayerEntity(
Expand All @@ -31,7 +32,8 @@ fun RemotePlayer.toEntity() = PlayerEntity(
contractStartDate = "",
contractEndDate = "",
position = position ?: "",
nationality = nationality ?: ""
nationality = nationality ?: "",
nationalityImageUrl = nationalityImageUrl ?: ""
)

fun PlayerEntity.toModel() = Player(
Expand All @@ -45,5 +47,6 @@ fun PlayerEntity.toModel() = Player(
contractStartDate = contractStartDate,
contractEndDate = contractEndDate,
position = position,
nationality = nationality
nationality = nationality,
nationalityImageUrl = nationalityImageUrl
)
Loading

0 comments on commit 09f78d7

Please sign in to comment.