diff --git a/android/app/src/main/java/app/organicmaps/MwmActivity.java b/android/app/src/main/java/app/organicmaps/MwmActivity.java index 173d629538..4112f3ceee 100644 --- a/android/app/src/main/java/app/organicmaps/MwmActivity.java +++ b/android/app/src/main/java/app/organicmaps/MwmActivity.java @@ -564,10 +564,11 @@ public class MwmActivity extends BaseMwmFragmentActivity Runnable delayedAction = () -> { CountryItem mCurrentCountry = CountryItem.fill("Tajikistan"); - goToTjkIfNotThere(); if(mCurrentCountry.status != CountryItem.STATUS_DONE) { // navigate to Dushanbe so it automatically downloads Tajikistan map goToDushanbe(); + } else { + goToTjkIfNotThere(); } }; handler.postDelayed(delayedAction, 1000); diff --git a/android/app/src/main/java/app/organicmaps/downloader/OnmapDownloader.java b/android/app/src/main/java/app/organicmaps/downloader/OnmapDownloader.java index 96a16a8467..f4debf1926 100644 --- a/android/app/src/main/java/app/organicmaps/downloader/OnmapDownloader.java +++ b/android/app/src/main/java/app/organicmaps/downloader/OnmapDownloader.java @@ -90,11 +90,13 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener private void navigationToMainActivityHandling() { Handler handler = new Handler(Looper.getMainLooper()); Runnable delayedAction = () -> { - if(mCurrentCountry.present) { + if(mCurrentCountry.present && !alreadyNavigating) { + alreadyNavigating = true; mActivity.removeScreenBlock(); Intent intent = new Intent(mActivity, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(mActivity, intent, null); + alreadyNavigating = true; } }; handler.postDelayed(delayedAction, 1000); @@ -118,10 +120,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener private void updateProgressState(boolean shouldAutoDownload) { - if(!alreadyNavigating) { - alreadyNavigating = true; - navigationToMainActivityHandling(); - } + navigationToMainActivityHandling(); updateStateInternal(shouldAutoDownload); } diff --git a/android/app/src/main/java/app/tourism/Constants.kt b/android/app/src/main/java/app/tourism/Constants.kt index c600b11238..fb83fb3615 100644 --- a/android/app/src/main/java/app/tourism/Constants.kt +++ b/android/app/src/main/java/app/tourism/Constants.kt @@ -1,8 +1,10 @@ package app.tourism +import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -15,7 +17,7 @@ import app.organicmaps.R import app.tourism.ui.theme.getBorderColor const val TAG = "GLOBAL_TAG" -const val BASE_URL = "http://192.168.1.80:8888/api/" +const val BASE_URL = "https://product.rebus.tj" object Constants { // UI @@ -53,13 +55,11 @@ fun Modifier.applyAppBorder() = this @Composable fun Modifier.drawOverlayForTextBehind() = - this.drawBehind { - val colors = listOf( - Color.Black, - Color.Transparent + this.background( + brush = Brush.verticalGradient( + colors = listOf( + Color.Transparent, + Color.Black.copy(alpha = 0.8f), + ) ) - drawRect( - brush = Brush.verticalGradient(colors), - blendMode = BlendMode.DstIn - ) - } + ) diff --git a/android/app/src/main/java/app/tourism/MainActivity.kt b/android/app/src/main/java/app/tourism/MainActivity.kt index 3841c8c118..5010dc9fb2 100644 --- a/android/app/src/main/java/app/tourism/MainActivity.kt +++ b/android/app/src/main/java/app/tourism/MainActivity.kt @@ -46,8 +46,8 @@ class MainActivity : ComponentActivity() { intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION) registerReceiver(wifiReceiver, intentFilter) - navigateToAuthIfNotAuthed() navigateToMapToDownloadIfNotPresent() + navigateToAuthIfNotAuthed() val blackest = resources.getColor(R.color.button_text) // yes, I know enableEdgeToEdge( diff --git a/android/app/src/main/java/app/tourism/data/db/dao/ReviewsDao.kt b/android/app/src/main/java/app/tourism/data/db/dao/ReviewsDao.kt index e00f7d5f0e..e0f384c753 100644 --- a/android/app/src/main/java/app/tourism/data/db/dao/ReviewsDao.kt +++ b/android/app/src/main/java/app/tourism/data/db/dao/ReviewsDao.kt @@ -1,7 +1,6 @@ package app.tourism.data.db.dao import androidx.room.Dao -import androidx.room.Delete import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query diff --git a/android/app/src/main/java/app/tourism/data/db/entities/ReviewToPublishEntity.kt b/android/app/src/main/java/app/tourism/data/db/entities/ReviewToPublishEntity.kt index 54741d908f..044f85eacf 100644 --- a/android/app/src/main/java/app/tourism/data/db/entities/ReviewToPublishEntity.kt +++ b/android/app/src/main/java/app/tourism/data/db/entities/ReviewToPublishEntity.kt @@ -4,7 +4,6 @@ import androidx.room.Entity import androidx.room.PrimaryKey import app.tourism.domain.models.details.ReviewToPost import java.io.File -import java.net.URI @Entity(tableName = "reviews_planned_to_post") data class ReviewPlannedToPostEntity( diff --git a/android/app/src/main/java/app/tourism/data/remote/TourismApi.kt b/android/app/src/main/java/app/tourism/data/remote/TourismApi.kt index 6471195a53..afe922ecf4 100644 --- a/android/app/src/main/java/app/tourism/data/remote/TourismApi.kt +++ b/android/app/src/main/java/app/tourism/data/remote/TourismApi.kt @@ -4,7 +4,6 @@ import app.tourism.data.dto.AllDataDto import app.tourism.data.dto.CategoryDto import app.tourism.data.dto.FavoritesDto import app.tourism.data.dto.FavoritesIdsDto -import app.tourism.data.dto.HashDto import app.tourism.data.dto.auth.AuthResponseDto import app.tourism.data.dto.place.ReviewDto import app.tourism.data.dto.place.ReviewIdsDto @@ -17,7 +16,6 @@ import okhttp3.MultipartBody import okhttp3.RequestBody import retrofit2.Response import retrofit2.http.Body -import retrofit2.http.DELETE import retrofit2.http.Field import retrofit2.http.FormUrlEncoded import retrofit2.http.GET diff --git a/android/app/src/main/java/app/tourism/data/repositories/AuthRepository.kt b/android/app/src/main/java/app/tourism/data/repositories/AuthRepository.kt index 6343c97181..db67281abc 100644 --- a/android/app/src/main/java/app/tourism/data/repositories/AuthRepository.kt +++ b/android/app/src/main/java/app/tourism/data/repositories/AuthRepository.kt @@ -7,7 +7,6 @@ import app.tourism.domain.models.SimpleResponse import app.tourism.domain.models.auth.AuthResponse import app.tourism.domain.models.auth.RegistrationData import app.tourism.domain.models.resource.Resource -import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow diff --git a/android/app/src/main/java/app/tourism/di/NetworkModule.kt b/android/app/src/main/java/app/tourism/di/NetworkModule.kt index 7f715e14d5..c28de5def4 100644 --- a/android/app/src/main/java/app/tourism/di/NetworkModule.kt +++ b/android/app/src/main/java/app/tourism/di/NetworkModule.kt @@ -24,7 +24,7 @@ object NetworkModule { @Singleton fun provideApi(okHttpClient: OkHttpClient): TourismApi { return Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl("$BASE_URL/api/") .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) .build() @@ -66,7 +66,7 @@ object NetworkModule { @Named(CURRENCY_RETROFIT_LABEL) fun provideCurrencyRetrofit(client: OkHttpClient): Retrofit { return Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl("$BASE_URL/api/") .addConverterFactory(GsonConverterFactory.create()) .client(client) .build() diff --git a/android/app/src/main/java/app/tourism/di/RepositoriesModule.kt b/android/app/src/main/java/app/tourism/di/RepositoriesModule.kt index 4c36945f9d..ccaa30a48e 100644 --- a/android/app/src/main/java/app/tourism/di/RepositoriesModule.kt +++ b/android/app/src/main/java/app/tourism/di/RepositoriesModule.kt @@ -1,14 +1,14 @@ package app.tourism.di import android.content.Context +import app.tourism.data.db.Database import app.tourism.data.prefs.UserPreferences import app.tourism.data.remote.CurrencyApi import app.tourism.data.remote.TourismApi import app.tourism.data.repositories.AuthRepository import app.tourism.data.repositories.CurrencyRepository -import app.tourism.data.repositories.ProfileRepository -import app.tourism.data.db.Database import app.tourism.data.repositories.PlacesRepository +import app.tourism.data.repositories.ProfileRepository import app.tourism.data.repositories.ReviewsRepository import dagger.Module import dagger.Provides diff --git a/android/app/src/main/java/app/tourism/ui/common/WebView.kt b/android/app/src/main/java/app/tourism/ui/common/WebView.kt index 427b2e7337..ab60b13be8 100644 --- a/android/app/src/main/java/app/tourism/ui/common/WebView.kt +++ b/android/app/src/main/java/app/tourism/ui/common/WebView.kt @@ -1,11 +1,8 @@ package app.tourism.ui.common import android.webkit.WebView -import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable import androidx.compose.ui.viewinterop.AndroidView -import androidx.webkit.WebSettingsCompat -import androidx.webkit.WebViewFeature @Composable fun WebView(data: String) { diff --git a/android/app/src/main/java/app/tourism/ui/common/special/CountryFlag.kt b/android/app/src/main/java/app/tourism/ui/common/special/CountryFlag.kt new file mode 100644 index 0000000000..e41a615ae5 --- /dev/null +++ b/android/app/src/main/java/app/tourism/ui/common/special/CountryFlag.kt @@ -0,0 +1,22 @@ +package app.tourism.ui.common.special + +import android.view.LayoutInflater +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.viewinterop.AndroidView +import app.organicmaps.R +import com.hbb20.CountryCodePicker + +@Composable +fun CountryFlag(modifier: Modifier = Modifier, countryCodeName: String) { + AndroidView( + modifier = Modifier.then(modifier), + factory = { context -> + val view = LayoutInflater.from(context) + .inflate(R.layout.ccp_country_flag, null, false) + val ccp = view.findViewById(R.id.ccp) + ccp.setCountryForNameCode(countryCodeName) + view + } + ) +} \ No newline at end of file diff --git a/android/app/src/main/java/app/tourism/ui/common/textfields/EditText.kt b/android/app/src/main/java/app/tourism/ui/common/textfields/EditText.kt index c975af5685..835fd0e6e7 100644 --- a/android/app/src/main/java/app/tourism/ui/common/textfields/EditText.kt +++ b/android/app/src/main/java/app/tourism/ui/common/textfields/EditText.kt @@ -4,7 +4,6 @@ import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.animateIntAsState import androidx.compose.animation.core.animateOffsetAsState import androidx.compose.animation.core.tween -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.PaddingValues diff --git a/android/app/src/main/java/app/tourism/ui/screens/auth/sign_in/SignInScreen.kt b/android/app/src/main/java/app/tourism/ui/screens/auth/sign_in/SignInScreen.kt index 3d25f00d81..9a6b2d6dca 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/auth/sign_in/SignInScreen.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/auth/sign_in/SignInScreen.kt @@ -2,7 +2,6 @@ package app.tourism.ui.screens.auth.sign_in import PasswordEditText import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -31,7 +30,6 @@ import app.tourism.BASE_URL import app.tourism.Constants import app.tourism.domain.models.resource.Resource import app.tourism.ui.ObserveAsEvents -import app.tourism.ui.common.BlurryContainer import app.tourism.ui.common.VerticalSpace import app.tourism.ui.common.buttons.PrimaryButton import app.tourism.ui.common.nav.BackButton @@ -128,7 +126,7 @@ fun SignInScreen( onClick = { openUrlInBrowser( context, - "http://192.168.1.80:8888/forgot-password" + "$BASE_URL/forgot-password" ) }, ) { diff --git a/android/app/src/main/java/app/tourism/ui/screens/auth/sign_up/SignUpScreen.kt b/android/app/src/main/java/app/tourism/ui/screens/auth/sign_up/SignUpScreen.kt index ee65fc3e43..ec1f6ab803 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/auth/sign_up/SignUpScreen.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/auth/sign_up/SignUpScreen.kt @@ -31,7 +31,6 @@ import app.organicmaps.R import app.tourism.Constants import app.tourism.domain.models.resource.Resource import app.tourism.ui.ObserveAsEvents -import app.tourism.ui.common.BlurryContainer import app.tourism.ui.common.VerticalSpace import app.tourism.ui.common.buttons.PrimaryButton import app.tourism.ui.common.nav.BackButton diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/CategoriesViewModel.kt b/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/CategoriesViewModel.kt index 2d18a889e9..300cb68283 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/CategoriesViewModel.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/CategoriesViewModel.kt @@ -3,7 +3,6 @@ package app.tourism.ui.screens.main.categories.categories import android.content.Context import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import androidx.lifecycle.viewmodel.compose.viewModel import app.organicmaps.R import app.tourism.data.repositories.PlacesRepository import app.tourism.domain.models.categories.PlaceCategory diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/HorizontalSingleChoice.kt b/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/HorizontalSingleChoice.kt index 017dd25248..524ee45886 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/HorizontalSingleChoice.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/categories/categories/HorizontalSingleChoice.kt @@ -14,7 +14,6 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import app.tourism.applyAppBorder -import app.tourism.ui.common.HorizontalSpace import app.tourism.ui.models.SingleChoiceItem import app.tourism.ui.theme.TextStyles diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/favorites/favorites/FavoritesScreen.kt b/android/app/src/main/java/app/tourism/ui/screens/main/favorites/favorites/FavoritesScreen.kt index 1f0523a454..1160b85598 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/favorites/favorites/FavoritesScreen.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/favorites/favorites/FavoritesScreen.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.material3.ListItem import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/home/HomeViewModel.kt b/android/app/src/main/java/app/tourism/ui/screens/main/home/HomeViewModel.kt index b20782c4ec..5bfa83b421 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/home/HomeViewModel.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/home/HomeViewModel.kt @@ -1,8 +1,10 @@ package app.tourism.ui.screens.main.home import android.content.Context +import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import app.organicmaps.util.log.Logger import app.tourism.data.repositories.PlacesRepository import app.tourism.domain.models.SimpleResponse import app.tourism.domain.models.categories.PlaceCategory @@ -44,32 +46,42 @@ class HomeViewModel @Inject constructor( private val _sights = MutableStateFlow>(emptyList()) val sights = _sights.asStateFlow() private fun getTopSights() { + val categoryId = PlaceCategory.Sights.id viewModelScope.launch(Dispatchers.IO) { - val categoryId = PlaceCategory.Sights.id - placesRepository.getPlacesByCategoryFromApiIfThereIsChange(categoryId) placesRepository.getTopPlaces(categoryId) .collectLatest { resource -> if (resource is Resource.Success) { - resource.data?.let { _sights.value = it } + resource.data?.let { + _sights.value = it + Log.d("lok narosh", it.toString()) + } } } } + viewModelScope.launch(Dispatchers.IO) { + placesRepository.getPlacesByCategoryFromApiIfThereIsChange(categoryId) + } } private val _restaurants = MutableStateFlow>(emptyList()) val restaurants = _restaurants.asStateFlow() private fun getTopRestaurants() { + val categoryId = PlaceCategory.Restaurants.id viewModelScope.launch(Dispatchers.IO) { - val categoryId = PlaceCategory.Restaurants.id - placesRepository.getPlacesByCategoryFromApiIfThereIsChange(categoryId) placesRepository.getTopPlaces(categoryId) .collectLatest { resource -> if (resource is Resource.Success) { - resource.data?.let { _restaurants.value = it } + resource.data?.let { + Log.d("lok narosh", it.toString()) + _restaurants.value = it + } } } } + viewModelScope.launch(Dispatchers.IO) { + placesRepository.getPlacesByCategoryFromApiIfThereIsChange(categoryId) + } } private val _downloadResponse = MutableStateFlow>(Resource.Idle()) diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/place_details/PlaceViewModel.kt b/android/app/src/main/java/app/tourism/ui/screens/main/place_details/PlaceViewModel.kt index 3e40e40bad..cc7f29cf8c 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/place_details/PlaceViewModel.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/place_details/PlaceViewModel.kt @@ -2,12 +2,9 @@ package app.tourism.ui.screens.main.place_details import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import app.tourism.Constants -import app.tourism.data.dto.PlaceLocation import app.tourism.data.repositories.PlacesRepository import app.tourism.domain.models.details.PlaceFull import app.tourism.domain.models.resource.Resource -import app.tourism.utils.makeLongListOfTheSameItem import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.Channel @@ -15,7 +12,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow -import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import javax.inject.Inject diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/PostReviewViewModel.kt b/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/PostReviewViewModel.kt index f29f20bc36..0bb9a9c835 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/PostReviewViewModel.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/PostReviewViewModel.kt @@ -6,7 +6,6 @@ import androidx.lifecycle.viewModelScope import app.organicmaps.R import app.tourism.data.repositories.ReviewsRepository import app.tourism.domain.models.SimpleResponse -import app.tourism.domain.models.details.Review import app.tourism.domain.models.details.ReviewToPost import app.tourism.domain.models.resource.Resource import dagger.hilt.android.lifecycle.HiltViewModel diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/ReviewsScreen.kt b/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/ReviewsScreen.kt index 075f237d05..7da0d9cfe9 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/ReviewsScreen.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/place_details/reviews/ReviewsScreen.kt @@ -33,7 +33,6 @@ import app.tourism.Constants import app.tourism.ui.ObserveAsEvents import app.tourism.ui.common.HorizontalSpace import app.tourism.ui.common.VerticalSpace -import app.tourism.ui.common.special.RatingBar import app.tourism.ui.screens.main.place_details.reviews.components.PostReview import app.tourism.ui.screens.main.place_details.reviews.components.Review import app.tourism.ui.theme.TextStyles @@ -42,7 +41,6 @@ import app.tourism.ui.utils.showToast import app.tourism.ui.utils.showYesNoAlertDialog import kotlinx.coroutines.delay import kotlinx.coroutines.launch -import kotlin.math.roundToInt @OptIn(ExperimentalMaterial3Api::class) @Composable diff --git a/android/app/src/main/java/app/tourism/ui/screens/main/profile/profile/ProfileScreen.kt b/android/app/src/main/java/app/tourism/ui/screens/main/profile/profile/ProfileScreen.kt index f85b9dcae1..2a3d63e1ec 100644 --- a/android/app/src/main/java/app/tourism/ui/screens/main/profile/profile/ProfileScreen.kt +++ b/android/app/src/main/java/app/tourism/ui/screens/main/profile/profile/ProfileScreen.kt @@ -1,11 +1,13 @@ package app.tourism.ui.screens.main.profile.profile import androidx.annotation.DrawableRes +import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement 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.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState @@ -21,7 +23,6 @@ import androidx.compose.material3.SwitchDefaults import androidx.compose.material3.Text import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -52,6 +53,7 @@ import app.tourism.ui.common.buttons.PrimaryButton import app.tourism.ui.common.buttons.SecondaryButton import app.tourism.ui.common.nav.AppTopBar import app.tourism.ui.common.special.CountryAsLabel +import app.tourism.ui.common.special.CountryFlag import app.tourism.ui.common.ui_state.Loading import app.tourism.ui.screens.main.ThemeViewModel import app.tourism.ui.theme.TextStyles @@ -172,36 +174,44 @@ fun ProfileBar(personalData: PersonalData) { @Composable fun CurrencyRates(modifier: Modifier = Modifier, currencyRates: CurrencyRates) { - // todo Row( modifier = Modifier .fillMaxWidth() .applyAppBorder() - .padding(horizontal = 15.dp, vertical = 24.dp) + .padding(horizontal = 15.dp, vertical = 18.dp) .then(modifier), horizontalArrangement = Arrangement.SpaceAround, verticalAlignment = Alignment.CenterVertically ) { CurrencyRatesItem( - currency = stringResource(id = R.string.usd), + countryCode = "US", value = "%.2f".format(currencyRates.usd), ) CurrencyRatesItem( - currency = stringResource(id = R.string.eur), + countryCode = "EU", value = "%.2f".format(currencyRates.eur), ) CurrencyRatesItem( - currency = stringResource(id = R.string.rub), + countryCode = "RU", value = "%.2f".format(currencyRates.rub), ) } } @Composable -fun CurrencyRatesItem(currency: String, value: String) { - Row { - Text(text = currency, style = TextStyles.b1) - HorizontalSpace(width = 4.dp) +fun CurrencyRatesItem(countryCode: String, value: String) { + Row(verticalAlignment = Alignment.CenterVertically) { + if (countryCode == "EU") + Row { + Image( + modifier = Modifier.height(21.dp), + painter = painterResource(id = R.drawable.eu_flag), + contentDescription = null + ) + HorizontalSpace(width = 8.dp) + } + else + CountryFlag(countryCodeName = countryCode) Text(text = value, style = TextStyles.b1.copy(fontWeight = FontWeight.SemiBold)) } } diff --git a/android/app/src/main/java/app/tourism/utils/FileUtils.kt b/android/app/src/main/java/app/tourism/utils/FileUtils.kt index cf56dc2809..bda2790367 100644 --- a/android/app/src/main/java/app/tourism/utils/FileUtils.kt +++ b/android/app/src/main/java/app/tourism/utils/FileUtils.kt @@ -4,7 +4,6 @@ import android.content.Context import android.graphics.Bitmap import id.zelory.compressor.Compressor import id.zelory.compressor.constraint.format -import id.zelory.compressor.constraint.resolution import id.zelory.compressor.constraint.size import java.io.File diff --git a/android/app/src/main/res/drawable/eu_flag.png b/android/app/src/main/res/drawable/eu_flag.png new file mode 100644 index 0000000000..434ad41006 Binary files /dev/null and b/android/app/src/main/res/drawable/eu_flag.png differ diff --git a/android/app/src/main/res/layout/ccp_country_flag.xml b/android/app/src/main/res/layout/ccp_country_flag.xml new file mode 100644 index 0000000000..c0246a4ebe --- /dev/null +++ b/android/app/src/main/res/layout/ccp_country_flag.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file