Skip to content

Commit

Permalink
add icon, splash screen & adjust the dropping item color
Browse files Browse the repository at this point in the history
  • Loading branch information
nabilBouzineDev committed Oct 23, 2024
1 parent 5e4310c commit 0394f1e
Show file tree
Hide file tree
Showing 45 changed files with 122 additions and 215 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {

buildTypes {
release {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SearchFlight"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".SplashActivity"
android:exported="true"
android:theme="@style/Theme.SearchFlight">
android:theme="@style/Theme.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="false">
</activity>
</application>

</manifest>
60 changes: 60 additions & 0 deletions app/src/main/java/com/nabilbdev/searchflight/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.nabilbdev.searchflight

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.res.painterResource
import com.nabilbdev.searchflight.ui.theme.SearchFlightTheme
import kotlinx.coroutines.delay

@SuppressLint("CustomSplashScreen")
class SplashActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
SearchFlightTheme {
SplashScreen()
}
}
}

@Composable
private fun SplashScreen() {
val alpha = remember { Animatable(0f) }

LaunchedEffect(key1 = true) {
alpha.animateTo(1f, animationSpec = tween(1500))
delay(2000)
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
}

Box(
modifier = Modifier
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Image(
modifier = Modifier
.aspectRatio(3f / 2f)
.alpha(alpha.value),
painter = painterResource(id = R.drawable.app_logo),
contentDescription = null
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.nabilbdev.searchflight.data.local.entity.Airport
import com.nabilbdev.searchflight.ui.screens.route.CompactAirportSelection
Expand All @@ -17,6 +19,7 @@ import com.nabilbdev.searchflight.ui.screens.search.utils.AIRPORT_DEFAULT
@Composable
fun FavoriteRouteTicket(
modifier: Modifier = Modifier,
containerColor: Color = MaterialTheme.colorScheme.surfaceContainer,
fromAirport: Airport = AIRPORT_DEFAULT,
toAirport: Airport = AIRPORT_DEFAULT
) {
Expand All @@ -26,7 +29,9 @@ fun FavoriteRouteTicket(
.padding(24.dp),
shape = CardDefaults.elevatedShape,
elevation = CardDefaults.elevatedCardElevation(),
colors = CardDefaults.elevatedCardColors(),
colors = CardDefaults.cardColors(
containerColor = containerColor
),
) {
CustomCurvedFlightPath {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ fun FavoriteScreen(
FavoriteRouteTicket(
fromAirport = favoriteRouteItem.first,
toAirport = favoriteRouteItem.second,
containerColor =
if (viewModel.isCurrentlyDragging && viewModel.isOverDropItem)
Color.Red.copy(.65f)
else
MaterialTheme.colorScheme.surfaceContainer,
modifier = Modifier
.width(325.dp)
)
Expand Down Expand Up @@ -131,6 +136,7 @@ fun BinDropItem(
}
}
if (isInBound) {
viewModel.onDropItem()
BinIconDropItem(iconColor = Color.Red)
} else {
BinIconDropItem(iconColor = Color.DarkGray)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ class FavoriteViewModel(

private val _favoriteAirports = MutableStateFlow<List<Pair<Airport, Airport>>>(emptyList())
private val _deletedOrNoFavoriteStatusMessage = MutableStateFlow<String?>(null)
private val _favoriteStatus = MutableStateFlow<FavoriteStatus>(FavoriteStatus.NONE)
private val _favoriteStatus = MutableStateFlow(FavoriteStatus.NONE)

var isCurrentlyDragging by mutableStateOf(false)
private set

var isOverDropItem by mutableStateOf(false)
private set

val favoriteUiState: StateFlow<FavoriteUiState> = combine(
_favoriteAirports, _deletedOrNoFavoriteStatusMessage, _favoriteStatus
) { favoriteAirports, deletedOrNoFavoriteStatusMessage, favoriteStatus ->
Expand Down Expand Up @@ -121,17 +124,23 @@ class FavoriteViewModel(

fun startDragging() {
isCurrentlyDragging = true
isOverDropItem = false
}

fun stopDragging() {
isCurrentlyDragging = false
isOverDropItem = false
}

fun clearFavoriteStatusAndMessage() {
_deletedOrNoFavoriteStatusMessage.value = null
_favoriteStatus.value = FavoriteStatus.NONE
}

fun onDropItem() {
isOverDropItem = true
}

companion object {
private const val TIMEOUT_MILLIS = 5_000L
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/nabilbdev/searchflight/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
Expand Down Expand Up @@ -50,6 +55,15 @@ fun SearchFlightTheme(
else -> LightColorScheme
}

val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = Color.Transparent.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
Expand Down
Binary file added app/src/main/res/drawable/app_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/app_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- drawable/airplane_search.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#ffffff"
android:pathData="M9.55 9.63L10.9 12.22C11.5 11.17 12.41 10.31 13.5 9.74L12.73 6.45L16.62 2.56C17.2 1.97 17.2 1 16.62 .438S15.08-.148 14.5 .438L10.61 4.33L1.41 2.21L0 3.62L7.43 7.5L3.54 11.4L1.06 11.05L0 12.11L3.18 13.87L4.95 17.06L6 16L5.66 13.5L9.55 9.63M16.5 11C19 11 21 13 21 15.5C21 16.38 20.75 17.21 20.31 17.9L23.39 21L22 22.39L18.88 19.32C18.19 19.75 17.37 20 16.5 20C14 20 12 18 12 15.5S14 11 16.5 11M16.5 13C15.12 13 14 14.12 14 15.5S15.12 18 16.5 18 19 16.88 19 15.5 17.88 13 16.5 13" />
</vector>
Loading

0 comments on commit 0394f1e

Please sign in to comment.