Skip to content

初期フローの合体をした #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 6, 2025
Merged
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
15 changes: 9 additions & 6 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/deviceManager.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions app/src/main/java/com/example/runningavater/MyAppNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.example.runningavater

import android.app.Application
import android.content.Context
import android.content.SharedPreferences
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
Expand All @@ -18,6 +19,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.datastore.preferences.preferencesDataStore
import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
Expand All @@ -37,14 +39,26 @@ import com.example.runningavater.settings.SettingsScreen
import com.example.runningavater.settings.SpanSettingsScreen
import com.example.runningavater.ui.theme.NuclearMango

fun getStartDestination(context: Context): String {
val prefs: SharedPreferences = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE)
val isFirstLaunch = prefs.getBoolean("is_first_launch", true)

if (isFirstLaunch) {
return "initialFlow/1"
} else {
return "authentication"
}
}

@Composable
fun MyAppNavHost(
navController: NavHostController = rememberNavController(),
startDestination: String = "initialFlow/1", // メイン画面をスタート画面に設定
// startDestination: String = "initialFlow/1", // メイン画面をスタート画面に設定
) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val startDestination = if (true) "initialFlow/2" else "authentication"
val context = LocalContext.current
val startDestination = getStartDestination(context)
Scaffold(
bottomBar = {
if (currentDestination?.route?.startsWith("initialFlow") != true) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.runningavater.initialFlow

import android.content.Context
import android.content.SharedPreferences
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -13,6 +15,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -71,7 +74,12 @@ fun InitialFlow10Screen(navController: NavHostController) {
.align(Alignment.BottomEnd)
.padding(0.dp, 0.dp, 0.dp, 20.dp),
) {
val context = LocalContext.current // Context を取得
val prefs: SharedPreferences = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE)
NextButton(
onClick = {
prefs.edit().putBoolean("is_first_launch", false).apply()
},
navController = navController,
nextDestination = "authentication",
text = "始める",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun InitialFlow2Screen(navController: NavHostController) {
) {
NextButton(
navController = navController,
nextDestination = "initialFlow/5",
nextDestination = "initialFlow/3",
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
Expand All @@ -22,7 +24,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -49,7 +53,11 @@ import kotlinx.coroutines.launch
fun InitialFlow5Screen(navController: NavHostController) {
val viewModel: YourViewModel = viewModel()
val context = LocalContext.current
val text = remember { mutableStateOf("") }
val keyboardController = LocalSoftwareKeyboardController.current
val text =
remember {
mutableStateOf("")
}

InitialFlowBackground {
Box(modifier = Modifier.fillMaxSize()) {
Expand Down Expand Up @@ -85,13 +93,25 @@ fun InitialFlow5Screen(navController: NavHostController) {
onValueChange = { newValue -> text.value = newValue },
placeholder = { Text(text = "名前をここに入力してね") },
colors =
TextFieldDefaults.textFieldColors(
containerColor = GranulatedSugar,
TextFieldDefaults.colors(
focusedContainerColor = GranulatedSugar,
unfocusedLabelColor = GranulatedSugar,
),
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = 10.dp),
singleLine = true,
keyboardOptions =
KeyboardOptions.Default.copy(
imeAction = ImeAction.Done,
),
keyboardActions =
KeyboardActions(
onDone = {
keyboardController?.hide()
},
),
Comment on lines +105 to +114
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nits]

singleLine = true だけでやりたいことはできてそうなのでここは不要かも

)
Text(
text = "※名前は後から変更できるよ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun InitialFlow6Screen(
)
NextButton(
navController = navController,
nextDestination = "initialFlow/8",
nextDestination = "initialFlow/7",
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
)
BackButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
Expand All @@ -29,7 +31,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand Down Expand Up @@ -60,6 +64,7 @@ fun InitialFlow7Screen(navController: NavHostController) {
var imageUri: Uri? by remember {
mutableStateOf(null)
}
val keyboardController = LocalSoftwareKeyboardController.current
val launcher =
rememberLauncherForActivityResult(contract = ActivityResultContracts.GetContent()) { uri ->
if (uri == null) return@rememberLauncherForActivityResult
Expand Down Expand Up @@ -116,14 +121,25 @@ fun InitialFlow7Screen(navController: NavHostController) {
onValueChange = { newValue -> text.value = newValue },
placeholder = { Text(text = "名前をここに入力してね") },
colors =
TextFieldDefaults.textFieldColors(
containerColor = GranulatedSugar,
TextFieldDefaults.colors(
focusedContainerColor = GranulatedSugar,
unfocusedLabelColor = GranulatedSugar,
),
modifier =
Modifier
.padding(0.dp, 40.dp, 0.dp, 0.dp)
.clip(CircleShape)
.size(350.dp, 55.dp),
.fillMaxWidth()
.padding(horizontal = 10.dp, vertical = 40.dp),
singleLine = true,
keyboardOptions =
KeyboardOptions.Default.copy(
imeAction = ImeAction.Done,
),
keyboardActions =
KeyboardActions(
onDone = {
keyboardController?.hide()
},
),
Comment on lines +133 to +142
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nits]
ここも singleLine = true だけで良さそう

)
Text(
text = "※名前とアイコンは",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -27,6 +28,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -57,6 +60,7 @@ fun InitialFlow8Screen(navController: NavHostController) {
val viewModel: TargetSettings = viewModel()
val context = LocalContext.current
val text = remember { mutableStateOf("") }
val keyboardController = LocalSoftwareKeyboardController.current

InitialFlowBackground {
Box(modifier = Modifier.fillMaxSize()) {
Expand Down Expand Up @@ -101,7 +105,15 @@ fun InitialFlow8Screen(navController: NavHostController) {
keyboardOptions =
KeyboardOptions(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done,
),
keyboardActions =
KeyboardActions(
onDone = {
keyboardController?.hide()
},
),
Comment on lines +108 to +115
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nits]

ここも singleLine = true だけで良さそう

singleLine = true,
)
Text(
text = "目標期間",
Expand Down Expand Up @@ -170,7 +182,7 @@ fun InitialFlow8Screen(navController: NavHostController) {
) {
NextButton(
navController = navController,
nextDestination = "initialFlow/10",
nextDestination = "initialFlow/9",
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
onClick = {
viewModel.viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ fun BackButton(
Button(
onClick = { navController.popBackStack() },
modifier =
modifier
.fillMaxWidth(),
modifier
.fillMaxWidth(),
colors =
ButtonDefaults.buttonColors(
containerColor = GranulatedSugar,
contentColor = NuclearMango,
),
ButtonDefaults.buttonColors(
containerColor = GranulatedSugar,
contentColor = NuclearMango,
),
) {
Text(
text = "戻る",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ fun NextButton(
onClick: (() -> Unit)? = null,
) {
Button(
onClick = { navController.navigate(nextDestination) },
onClick = {
onClick?.invoke()
navController.navigate(nextDestination)
},
modifier =
modifier
.fillMaxWidth(),
Expand Down