feat: implement Film Library and Detail screens
This commit is contained in:
1 parent
ff3cca99b6
commit
36d12908c9
15 files changed
+5041
-3
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -69,7 +69,10 @@ import com.hinnka.mycamera.lut.creator.LutCreatorScreen
|
||||
import com.hinnka.mycamera.lut.creator.LutCreatorViewModel
|
||||
import com.hinnka.mycamera.screencapture.ScreenCaptureRenderConfigStore
|
||||
import com.hinnka.mycamera.ui.camera.CameraScreen
|
||||
import com.hinnka.mycamera.data.FilmData
|
||||
import com.hinnka.mycamera.ui.camera.ColorWalkScreen
|
||||
import com.hinnka.mycamera.ui.camera.FilmDetailScreen
|
||||
import com.hinnka.mycamera.ui.camera.FilmLibraryScreen
|
||||
import com.hinnka.mycamera.ui.camera.ToolboxScreen
|
||||
import com.hinnka.mycamera.ui.gallery.BurstDetailScreen
|
||||
import com.hinnka.mycamera.ui.gallery.GalleryDetailScreen
|
||||
@@ -108,6 +111,10 @@ object Routes {
|
||||
const val TOOLBOX = "toolbox"
|
||||
const val PHANTOM_PIP_CROP = "phantom_pip_crop"
|
||||
const val COLOR_WALK = "color_walk"
|
||||
const val FILM_LIBRARY = "film_library"
|
||||
const val FILM_DETAIL = "film_detail/{filmId}"
|
||||
|
||||
fun filmDetail(filmId: String) = "film_detail/$filmId"
|
||||
|
||||
fun photoDetail(tab: GalleryTab = GalleryTab.PHOTON, index: Int = 0, photoId: String? = null) =
|
||||
"photo_detail/$tab/$index" + (if (photoId != null) "?photoId=$photoId" else "")
|
||||
@@ -205,6 +212,10 @@ class MainActivity : ComponentActivity() {
|
||||
handleIntent(intent)
|
||||
StartupTrace.mark("MainActivity.intent handled", "pendingRoute=$pendingRoute")
|
||||
|
||||
lifecycleScope.launch {
|
||||
FilmData.init(this@MainActivity)
|
||||
}
|
||||
|
||||
splashScreen.setKeepOnScreenCondition {
|
||||
val cameraInitialized = cameraViewModel.isInitialized.value
|
||||
val galleryInitialized = galleryViewModel.isInitialized.value
|
||||
@@ -700,10 +711,34 @@ fun NavigationHost(
|
||||
ToolboxScreen(
|
||||
onBack = { navController.popBackStack() },
|
||||
onLutCreatorClick = { navController.navigate(Routes.LUT_CREATOR) },
|
||||
onColorWalkClick = { navController.navigate(Routes.COLOR_WALK) }
|
||||
onColorWalkClick = { navController.navigate(Routes.COLOR_WALK) },
|
||||
onFilmLibraryClick = { navController.navigate(Routes.FILM_LIBRARY) }
|
||||
)
|
||||
}
|
||||
|
||||
composable(Routes.FILM_LIBRARY) {
|
||||
FilmLibraryScreen(
|
||||
onBack = { navController.popBackStack() },
|
||||
onFilmClick = { film ->
|
||||
navController.navigate(Routes.filmDetail(film.id ?: ""))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
composable(
|
||||
route = Routes.FILM_DETAIL,
|
||||
arguments = listOf(navArgument("filmId") { type = NavType.StringType })
|
||||
) { backStackEntry ->
|
||||
val filmId = backStackEntry.arguments?.getString("filmId") ?: ""
|
||||
val film = FilmData.getFilmById(filmId)
|
||||
if (film != null) {
|
||||
FilmDetailScreen(
|
||||
film = film,
|
||||
onBack = { navController.popBackStack() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
composable(Routes.COLOR_WALK) {
|
||||
ColorWalkScreen(
|
||||
viewModel = cameraViewModel,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.hinnka.mycamera.data
|
||||
|
||||
import android.content.Context
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.hinnka.mycamera.model.Film
|
||||
import com.hinnka.mycamera.utils.PLog
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
object FilmData {
|
||||
private var _films: List<Film> = emptyList()
|
||||
val films: List<Film> get() = _films
|
||||
|
||||
suspend fun init(context: Context) = withContext(Dispatchers.IO) {
|
||||
if (_films.isNotEmpty()) return@withContext
|
||||
try {
|
||||
val jsonString = context.assets.open("films.json").bufferedReader().use { it.readText() }
|
||||
val type = object : TypeToken<List<Film>>() {}.type
|
||||
_films = Gson().fromJson(jsonString, type)
|
||||
PLog.d("FilmData", "Loaded ${_films.size} films from assets")
|
||||
} catch (e: Exception) {
|
||||
PLog.e("FilmData", "Error loading films", e)
|
||||
}
|
||||
}
|
||||
|
||||
fun getFilmById(id: String): Film? = _films.find { it.id == id }
|
||||
}
|
||||
@@ -157,7 +157,8 @@ data class UserPreferences(
|
||||
val defaultVirtualAperture: Float = 0f, // 默认虚化光圈,0表示关闭
|
||||
val customFocalLengths: List<Float> = emptyList(), // 自定义焦段 (35mm等效),最多8个
|
||||
val customLensIds: List<String> = emptyList(), // 自定义镜头 ID,逗号分隔存储
|
||||
val hiddenFocalLengths: List<Float> = emptyList() // 隐藏的焦段 (35mm等效)
|
||||
val hiddenFocalLengths: List<Float> = emptyList(), // 隐藏的焦段 (35mm等效)
|
||||
val referencePhotoUrl: String? = null
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -273,6 +274,7 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
private val CUSTOM_LENS_IDS = stringPreferencesKey("custom_lens_ids")
|
||||
private val HIDDEN_FOCAL_LENGTHS = stringPreferencesKey("hidden_focal_lengths")
|
||||
private val USE_HDR_SCREEN_MODE = booleanPreferencesKey("use_hdr_screen_mode")
|
||||
private val REFERENCE_PHOTO_URL = stringPreferencesKey("reference_photo_url")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,7 +419,8 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
?.split(",")?.filter { it.isNotEmpty() }
|
||||
?.mapNotNull { it.toFloatOrNull() }
|
||||
?: emptyList(),
|
||||
useHdrScreenMode = preferences[USE_HDR_SCREEN_MODE] ?: true
|
||||
useHdrScreenMode = preferences[USE_HDR_SCREEN_MODE] ?: true,
|
||||
referencePhotoUrl = preferences[REFERENCE_PHOTO_URL]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -533,6 +536,19 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
return AspectRatio.sanitizeTopSheetRatios(ratios)
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存参考图 URL
|
||||
*/
|
||||
suspend fun saveReferencePhotoUrl(url: String?) {
|
||||
context.dataStore.edit { preferences ->
|
||||
if (url != null) {
|
||||
preferences[REFERENCE_PHOTO_URL] = url
|
||||
} else {
|
||||
preferences.remove(REFERENCE_PHOTO_URL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存最近拍摄模式
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hinnka.mycamera.model
|
||||
|
||||
data class Film(
|
||||
val id: String?,
|
||||
val name: String?,
|
||||
val type: String?,
|
||||
val iso: String?,
|
||||
val canisterUrl: String? = null,
|
||||
val manufacturer: String? = null,
|
||||
val origin: String? = null,
|
||||
val formats: List<String>? = null,
|
||||
val grain: String? = null,
|
||||
val contrast: String? = null,
|
||||
val bestFor: List<String>? = null,
|
||||
val examples: List<String>? = null
|
||||
)
|
||||
@@ -0,0 +1,316 @@
|
||||
package com.hinnka.mycamera.ui.camera
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Business
|
||||
import androidx.compose.material.icons.filled.Contrast
|
||||
import androidx.compose.material.icons.filled.Flag
|
||||
import androidx.compose.material.icons.filled.Grain
|
||||
import androidx.compose.material.icons.filled.Image
|
||||
import androidx.compose.material.icons.filled.Iso
|
||||
import androidx.compose.material.icons.filled.Layers
|
||||
import androidx.compose.material.icons.filled.LocationOn
|
||||
import androidx.compose.material.icons.filled.Photo
|
||||
import androidx.compose.material.icons.filled.Public
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.model.Film
|
||||
import android.widget.Toast
|
||||
import android.content.Context
|
||||
import androidx.compose.material.icons.filled.Bookmark
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun FilmDetailScreen(
|
||||
film: Film,
|
||||
onBack: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
CenterAlignedTopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
text = film.name ?: "Unknown",
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = "Back"
|
||||
)
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
|
||||
containerColor = Color.White,
|
||||
titleContentColor = Color.Black,
|
||||
navigationIconContentColor = Color.Black
|
||||
)
|
||||
)
|
||||
},
|
||||
containerColor = Color.White,
|
||||
modifier = modifier.fillMaxSize()
|
||||
) { padding ->
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.padding(padding)
|
||||
.fillMaxSize(),
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(24.dp)
|
||||
) {
|
||||
// Header Card
|
||||
item {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
film.canisterUrl?.let {
|
||||
AsyncImage(
|
||||
model = it,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(120.dp)
|
||||
.padding(bottom = 16.dp),
|
||||
contentScale = ContentScale.Fit
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = film.name ?: "Unknown",
|
||||
color = Color.Black,
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
InfoItem(Icons.Default.Layers, film.type ?: stringResource(R.string.unknown))
|
||||
InfoItem(Icons.Default.Business, film.manufacturer ?: "N/A")
|
||||
}
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
InfoItem(Icons.Default.Photo, film.formats?.joinToString(", ") ?: "N/A")
|
||||
InfoItem(Icons.Default.Public, film.origin ?: "N/A")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Specs Section
|
||||
item {
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(R.string.film_specs),
|
||||
color = Color.Black,
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(bottom = 12.dp)
|
||||
)
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
SpecRow(Icons.Default.Layers, film.type ?: stringResource(R.string.unknown))
|
||||
SpecRow(Icons.Default.Iso, film.iso ?: stringResource(R.string.unknown))
|
||||
SpecRow(Icons.Default.Grain, film.grain ?: "N/A")
|
||||
SpecRow(Icons.Default.Contrast, film.contrast ?: "N/A")
|
||||
|
||||
if (!film.bestFor.isNullOrEmpty()) {
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
FlowRow(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
film.bestFor?.forEach { tag ->
|
||||
Surface(
|
||||
color = Color.Black.copy(alpha = 0.05f),
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = tag,
|
||||
color = Color.Black.copy(alpha = 0.7f),
|
||||
fontSize = 12.sp,
|
||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Examples Section
|
||||
if (!film.examples.isNullOrEmpty()) {
|
||||
item {
|
||||
Text(
|
||||
text = stringResource(R.string.film_example_photos),
|
||||
color = Color.Black,
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(bottom = 12.dp)
|
||||
)
|
||||
}
|
||||
items(film.examples) { example ->
|
||||
ExamplePhotoCard(example)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InfoItem(icon: ImageVector, text: String) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
tint = Color.Gray,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = text,
|
||||
color = Color.Black.copy(alpha = 0.7f),
|
||||
fontSize = 14.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SpecRow(icon: ImageVector, text: String) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
tint = Color.Gray,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Text(
|
||||
text = text,
|
||||
color = Color.Black.copy(alpha = 0.8f),
|
||||
fontSize = 15.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ExamplePhotoCard(example: String) {
|
||||
val context = LocalContext.current
|
||||
val userPreferencesRepository = remember {
|
||||
com.hinnka.mycamera.data.ContentRepository.getInstance(context).userPreferencesRepository
|
||||
}
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
AsyncImage(
|
||||
model = example,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(1.5f),
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
Button(
|
||||
onClick = {
|
||||
coroutineScope.launch {
|
||||
userPreferencesRepository.saveReferencePhotoUrl(example)
|
||||
Toast.makeText(context, R.string.reference_photo_set_success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color.Black.copy(alpha = 0.6f),
|
||||
contentColor = Color.White
|
||||
),
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp),
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(8.dp)
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Bookmark,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = Color(0xFFFFD700)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.set_as_reference),
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun FlowRow(
|
||||
modifier: Modifier = Modifier,
|
||||
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
|
||||
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
androidx.compose.foundation.layout.FlowRow(
|
||||
modifier = modifier,
|
||||
horizontalArrangement = horizontalArrangement,
|
||||
verticalArrangement = verticalArrangement
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.hinnka.mycamera.ui.camera
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.data.FilmData
|
||||
import com.hinnka.mycamera.model.Film
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun FilmLibraryScreen(
|
||||
onBack: () -> Unit,
|
||||
onFilmClick: (Film) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
CenterAlignedTopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.film_library_title),
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = "Back"
|
||||
)
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
|
||||
containerColor = Color.White,
|
||||
titleContentColor = Color.Black,
|
||||
navigationIconContentColor = Color.Black
|
||||
)
|
||||
)
|
||||
},
|
||||
containerColor = Color.White,
|
||||
modifier = modifier.fillMaxSize()
|
||||
) { padding ->
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(2),
|
||||
modifier = Modifier
|
||||
.padding(padding)
|
||||
.fillMaxSize(),
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
items(FilmData.films) { film ->
|
||||
FilmGridItem(film, onClick = { onFilmClick(film) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FilmGridItem(film: Film, onClick: () -> Unit) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { onClick() },
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = Color.White
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
film.canisterUrl?.let {
|
||||
AsyncImage(
|
||||
model = it,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(100.dp)
|
||||
.padding(bottom = 12.dp),
|
||||
contentScale = ContentScale.Fit
|
||||
)
|
||||
} ?: Box(modifier = Modifier.size(100.dp))
|
||||
|
||||
Text(
|
||||
text = film.name ?: stringResource(R.string.unknown),
|
||||
color = Color.Black,
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center,
|
||||
lineHeight = 18.sp,
|
||||
minLines = 2
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = "ISO ${film.iso ?: stringResource(R.string.unknown)} · ${film.type ?: stringResource(R.string.unknown)}",
|
||||
color = Color.Gray,
|
||||
fontSize = 11.sp,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.DirectionsWalk
|
||||
import androidx.compose.material.icons.filled.FilterFrames
|
||||
import androidx.compose.material.icons.filled.Palette
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -38,6 +39,7 @@ fun ToolboxScreen(
|
||||
onBack: () -> Unit,
|
||||
onLutCreatorClick: () -> Unit,
|
||||
onColorWalkClick: () -> Unit,
|
||||
onFilmLibraryClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val items = listOf(
|
||||
@@ -52,6 +54,12 @@ fun ToolboxScreen(
|
||||
descriptionRes = R.string.color_walk_short_desc,
|
||||
icon = Icons.Default.DirectionsWalk,
|
||||
onClick = onColorWalkClick
|
||||
),
|
||||
ToolboxItem(
|
||||
titleRes = R.string.film_library_title,
|
||||
descriptionRes = R.string.film_library_desc,
|
||||
icon = Icons.Default.FilterFrames,
|
||||
onClick = onFilmLibraryClick
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.*
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
|
||||
import androidx.compose.foundation.gestures.detectDragGestures
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import kotlin.math.roundToInt
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.PushPin
|
||||
import androidx.compose.ui.zIndex
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -117,6 +123,12 @@ fun PhotoEditScreen(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val userPreferencesRepository = remember {
|
||||
com.hinnka.mycamera.data.ContentRepository.getInstance(context).userPreferencesRepository
|
||||
}
|
||||
val userPreferences by userPreferencesRepository.userPreferences.collectAsState(
|
||||
initial = com.hinnka.mycamera.data.UserPreferences()
|
||||
)
|
||||
val currentPhoto = viewModel.getCurrentPhoto()
|
||||
val editLutId by viewModel.editLutId.collectAsState()
|
||||
val editLutRecipeParams by viewModel.editLutRecipeParams.collectAsState()
|
||||
@@ -343,6 +355,142 @@ fun PhotoEditScreen(
|
||||
.padding(paddingValues)
|
||||
.animateContentSize()
|
||||
) {
|
||||
// Draggable Floating Reference Photo
|
||||
val referencePhotoUrl = userPreferences.referencePhotoUrl
|
||||
var isMinimized by remember { mutableStateOf(false) }
|
||||
var isLarge by remember { mutableStateOf(false) }
|
||||
|
||||
referencePhotoUrl?.let { url ->
|
||||
val density = androidx.compose.ui.platform.LocalDensity.current
|
||||
val initialOffsetX = remember(density) { with(density) { 20.dp.toPx() } }
|
||||
val initialOffsetY = remember(density) { with(density) { 80.dp.toPx() } }
|
||||
|
||||
var offsetX by remember { mutableStateOf(initialOffsetX) }
|
||||
var offsetY by remember { mutableStateOf(initialOffsetY) }
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.offset { IntOffset(offsetX.roundToInt(), offsetY.roundToInt()) }
|
||||
.pointerInput(Unit) {
|
||||
detectDragGestures { change, dragAmount ->
|
||||
change.consume()
|
||||
offsetX += dragAmount.x
|
||||
offsetY += dragAmount.y
|
||||
}
|
||||
}
|
||||
.zIndex(10f)
|
||||
) {
|
||||
if (isMinimized) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.size(48.dp)
|
||||
.clickable { isMinimized = false },
|
||||
shape = CircleShape,
|
||||
colors = CardDefaults.cardColors(containerColor = Color.Black.copy(alpha = 0.8f)),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 8.dp),
|
||||
border = BorderStroke(1.5.dp, Color.White)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.PushPin,
|
||||
contentDescription = "Show Reference",
|
||||
tint = Color(0xFFFFD700),
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val cardSize = if (isLarge) 240.dp else 120.dp
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.width(cardSize),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = Color(0xFF1E1E1E)),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 8.dp),
|
||||
border = BorderStroke(2.dp, Color.White)
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
coil.compose.AsyncImage(
|
||||
model = ImageRequest.Builder(LocalContext.current)
|
||||
.data(url)
|
||||
.placeholder(R.mipmap.ic_launcher)
|
||||
.build(),
|
||||
contentDescription = "Reference Photo",
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
contentScale = ContentScale.FillWidth
|
||||
)
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(4.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color.Black.copy(alpha = 0.6f))
|
||||
.clickable { isMinimized = true },
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.PushPin,
|
||||
contentDescription = "Minimize",
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(12.dp)
|
||||
)
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color.Black.copy(alpha = 0.6f))
|
||||
.clickable {
|
||||
scope.launch {
|
||||
userPreferencesRepository.saveReferencePhotoUrl(null)
|
||||
}
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Close,
|
||||
contentDescription = "Close",
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(12.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(Color.White)
|
||||
.padding(horizontal = 8.dp, vertical = 6.dp)
|
||||
.clickable { isLarge = !isLarge },
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = if (isLarge) stringResource(R.string.zoom_out) else stringResource(R.string.zoom_in),
|
||||
color = Color.Black,
|
||||
fontSize = 11.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 预览区域
|
||||
Box(
|
||||
modifier = Modifier
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
<string name="timer">定时器</string>
|
||||
<string name="toolbox_title">工具箱</string>
|
||||
<string name="toolbox_description">实用工具与创意功能</string>
|
||||
<string name="film_library_title">胶卷库</string>
|
||||
<string name="film_library_desc">探索各种经典胶卷及其特性。</string>
|
||||
<string name="color_walk_title">Color Walk</string>
|
||||
<string name="color_walk_desc">“Color Walk(色彩漫步)”是一种观察世界的正念练习。通过专注于特定的颜色,我们能够放慢脚步,在平凡的日常中发现被忽视的美。选择一个此刻最能触动你的颜色,开启一段专属于你的视觉探索之旅。</string>
|
||||
<string name="color_walk_short_desc">开启一段专注色彩的正念观察之旅</string>
|
||||
@@ -20,6 +22,7 @@
|
||||
<string name="histogram">直方图</string>
|
||||
<string name="grid">网格</string>
|
||||
<string name="back">返回</string>
|
||||
<string name="unknown">未知</string>
|
||||
<string name="take_photo">拍照</string>
|
||||
<string name="pause">暂停</string>
|
||||
<string name="resume">继续</string>
|
||||
@@ -883,4 +886,19 @@
|
||||
<string name="avg">平均</string>
|
||||
<string name="spot">点测光</string>
|
||||
<string name="frame_editor_text_type_filter_name">滤镜名称</string>
|
||||
|
||||
<!-- 胶卷详情 -->
|
||||
<string name="film_specs">规格参数</string>
|
||||
<string name="film_example_photos">样片展示</string>
|
||||
<string name="film_type">类型</string>
|
||||
<string name="film_manufacturer">厂商</string>
|
||||
<string name="film_formats">画幅</string>
|
||||
<string name="film_origin">产地</string>
|
||||
<string name="film_iso">感光度</string>
|
||||
<string name="film_grain">颗粒感</string>
|
||||
<string name="film_contrast">对比度</string>
|
||||
<string name="set_as_reference">设为参考</string>
|
||||
<string name="reference_photo_set_success">已设为编辑参考图。下次进入编辑界面时将显示该悬浮图片!</string>
|
||||
<string name="zoom_in">放大</string>
|
||||
<string name="zoom_out">缩小</string>
|
||||
</resources>
|
||||
@@ -9,6 +9,8 @@
|
||||
<string name="timer">Timer</string>
|
||||
<string name="toolbox_title">Toolbox</string>
|
||||
<string name="toolbox_description">Utility tools and creative features</string>
|
||||
<string name="film_library_title">Film Library</string>
|
||||
<string name="film_library_desc">Explore a wide range of film stocks and their characteristics.</string>
|
||||
<string name="color_walk_title">Color Walk</string>
|
||||
<string name="color_walk_desc">A Color Walk is a form of mindfulness. By focusing on a specific color, we slow down and discover the hidden beauty in our daily surroundings. Choose a color that resonates with your mood today, and let it guide your perspective.</string>
|
||||
<string name="color_walk_short_desc">Discover mindfulness through a journey of colors.</string>
|
||||
@@ -20,6 +22,7 @@
|
||||
<string name="histogram">Histogram</string>
|
||||
<string name="grid">Grid</string>
|
||||
<string name="back">Back</string>
|
||||
<string name="unknown">Unknown</string>
|
||||
<string name="take_photo">Take Photo</string>
|
||||
<string name="pause">Pause</string>
|
||||
<string name="resume">Resume</string>
|
||||
@@ -883,4 +886,19 @@
|
||||
<string name="avg">AVG</string>
|
||||
<string name="spot">SPOT</string>
|
||||
<string name="frame_editor_text_type_filter_name">Filter Name</string>
|
||||
|
||||
<!-- Film Detail -->
|
||||
<string name="film_specs">Specs</string>
|
||||
<string name="film_example_photos">Example Photos</string>
|
||||
<string name="film_type">Type</string>
|
||||
<string name="film_manufacturer">Manufacturer</string>
|
||||
<string name="film_formats">Formats</string>
|
||||
<string name="film_origin">Origin</string>
|
||||
<string name="film_iso">ISO</string>
|
||||
<string name="film_grain">Grain</string>
|
||||
<string name="film_contrast">Contrast</string>
|
||||
<string name="set_as_reference">Set as Reference</string>
|
||||
<string name="reference_photo_set_success">Set as reference photo. It will display in next edit!</string>
|
||||
<string name="zoom_in">Enlarge</string>
|
||||
<string name="zoom_out">Shrink</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user