Skip to content

Commit 06d4987

Browse files
authored
Merge pull request #144 from NID-kt/feature/issue-82
2 parents 511fe06 + ef8e9c1 commit 06d4987

File tree

12 files changed

+142
-21
lines changed

12 files changed

+142
-21
lines changed

.idea/deploymentTargetSelector.xml

+9-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deviceManager.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/other.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/example/runningavater/MyAppNavHost.kt

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.example.runningavater
22

33
import android.app.Application
44
import android.content.Context
5+
import android.content.SharedPreferences
56
import androidx.compose.foundation.layout.padding
67
import androidx.compose.material.icons.Icons
78
import androidx.compose.material.icons.filled.Home
@@ -18,6 +19,7 @@ import androidx.compose.runtime.getValue
1819
import androidx.compose.ui.Modifier
1920
import androidx.compose.ui.graphics.Color
2021
import androidx.compose.ui.graphics.vector.ImageVector
22+
import androidx.compose.ui.platform.LocalContext
2123
import androidx.datastore.preferences.preferencesDataStore
2224
import androidx.navigation.NavDestination
2325
import androidx.navigation.NavDestination.Companion.hierarchy
@@ -37,14 +39,26 @@ import com.example.runningavater.settings.SettingsScreen
3739
import com.example.runningavater.settings.SpanSettingsScreen
3840
import com.example.runningavater.ui.theme.NuclearMango
3941

42+
fun getStartDestination(context: Context): String {
43+
val prefs: SharedPreferences = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE)
44+
val isFirstLaunch = prefs.getBoolean("is_first_launch", true)
45+
46+
if (isFirstLaunch) {
47+
return "initialFlow/1"
48+
} else {
49+
return "authentication"
50+
}
51+
}
52+
4053
@Composable
4154
fun MyAppNavHost(
4255
navController: NavHostController = rememberNavController(),
43-
startDestination: String = "initialFlow/1", // メイン画面をスタート画面に設定
56+
// startDestination: String = "initialFlow/1", // メイン画面をスタート画面に設定
4457
) {
4558
val navBackStackEntry by navController.currentBackStackEntryAsState()
4659
val currentDestination = navBackStackEntry?.destination
47-
val startDestination = if (true) "initialFlow/2" else "authentication"
60+
val context = LocalContext.current
61+
val startDestination = getStartDestination(context)
4862
Scaffold(
4963
bottomBar = {
5064
if (currentDestination?.route?.startsWith("initialFlow") != true) {

app/src/main/java/com/example/runningavater/initialFlow/InitialFlow10.kt

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.example.runningavater.initialFlow
22

3+
import android.content.Context
4+
import android.content.SharedPreferences
35
import androidx.compose.foundation.Image
46
import androidx.compose.foundation.layout.Box
57
import androidx.compose.foundation.layout.Column
@@ -13,6 +15,7 @@ import androidx.compose.ui.Alignment
1315
import androidx.compose.ui.Modifier
1416
import androidx.compose.ui.graphics.Color
1517
import androidx.compose.ui.layout.ContentScale
18+
import androidx.compose.ui.platform.LocalContext
1619
import androidx.compose.ui.res.painterResource
1720
import androidx.compose.ui.text.style.TextAlign
1821
import androidx.compose.ui.tooling.preview.Preview
@@ -71,7 +74,12 @@ fun InitialFlow10Screen(navController: NavHostController) {
7174
.align(Alignment.BottomEnd)
7275
.padding(0.dp, 0.dp, 0.dp, 20.dp),
7376
) {
77+
val context = LocalContext.current // Context を取得
78+
val prefs: SharedPreferences = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE)
7479
NextButton(
80+
onClick = {
81+
prefs.edit().putBoolean("is_first_launch", false).apply()
82+
},
7583
navController = navController,
7684
nextDestination = "authentication",
7785
text = "始める",

app/src/main/java/com/example/runningavater/initialFlow/InitialFlow2.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fun InitialFlow2Screen(navController: NavHostController) {
6666
) {
6767
NextButton(
6868
navController = navController,
69-
nextDestination = "initialFlow/5",
69+
nextDestination = "initialFlow/3",
7070
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
7171
)
7272
}

app/src/main/java/com/example/runningavater/initialFlow/InitialFlow5.kt

+23-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import androidx.compose.foundation.layout.fillMaxSize
1111
import androidx.compose.foundation.layout.fillMaxWidth
1212
import androidx.compose.foundation.layout.padding
1313
import androidx.compose.foundation.layout.size
14+
import androidx.compose.foundation.text.KeyboardActions
15+
import androidx.compose.foundation.text.KeyboardOptions
1416
import androidx.compose.material3.ExperimentalMaterial3Api
1517
import androidx.compose.material3.Text
1618
import androidx.compose.material3.TextField
@@ -22,7 +24,9 @@ import androidx.compose.ui.Alignment
2224
import androidx.compose.ui.Modifier
2325
import androidx.compose.ui.graphics.Color
2426
import androidx.compose.ui.platform.LocalContext
27+
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
2528
import androidx.compose.ui.res.painterResource
29+
import androidx.compose.ui.text.input.ImeAction
2630
import androidx.compose.ui.text.style.TextAlign
2731
import androidx.compose.ui.tooling.preview.Preview
2832
import androidx.compose.ui.unit.dp
@@ -49,7 +53,11 @@ import kotlinx.coroutines.launch
4953
fun InitialFlow5Screen(navController: NavHostController) {
5054
val viewModel: YourViewModel = viewModel()
5155
val context = LocalContext.current
52-
val text = remember { mutableStateOf("") }
56+
val keyboardController = LocalSoftwareKeyboardController.current
57+
val text =
58+
remember {
59+
mutableStateOf("")
60+
}
5361

5462
InitialFlowBackground {
5563
Box(modifier = Modifier.fillMaxSize()) {
@@ -85,13 +93,25 @@ fun InitialFlow5Screen(navController: NavHostController) {
8593
onValueChange = { newValue -> text.value = newValue },
8694
placeholder = { Text(text = "名前をここに入力してね") },
8795
colors =
88-
TextFieldDefaults.textFieldColors(
89-
containerColor = GranulatedSugar,
96+
TextFieldDefaults.colors(
97+
focusedContainerColor = GranulatedSugar,
98+
unfocusedLabelColor = GranulatedSugar,
9099
),
91100
modifier =
92101
Modifier
93102
.fillMaxWidth()
94103
.padding(horizontal = 10.dp),
104+
singleLine = true,
105+
keyboardOptions =
106+
KeyboardOptions.Default.copy(
107+
imeAction = ImeAction.Done,
108+
),
109+
keyboardActions =
110+
KeyboardActions(
111+
onDone = {
112+
keyboardController?.hide()
113+
},
114+
),
95115
)
96116
Text(
97117
text = "※名前は後から変更できるよ",

app/src/main/java/com/example/runningavater/initialFlow/InitialFlow6.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fun InitialFlow6Screen(
7979
)
8080
NextButton(
8181
navController = navController,
82-
nextDestination = "initialFlow/8",
82+
nextDestination = "initialFlow/7",
8383
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
8484
)
8585
BackButton(

app/src/main/java/com/example/runningavater/initialFlow/InitialFlow7.kt

+21-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import androidx.compose.foundation.layout.offset
1515
import androidx.compose.foundation.layout.padding
1616
import androidx.compose.foundation.layout.size
1717
import androidx.compose.foundation.shape.CircleShape
18+
import androidx.compose.foundation.text.KeyboardActions
19+
import androidx.compose.foundation.text.KeyboardOptions
1820
import androidx.compose.material3.ExperimentalMaterial3Api
1921
import androidx.compose.material3.Text
2022
import androidx.compose.material3.TextField
@@ -29,7 +31,9 @@ import androidx.compose.ui.Modifier
2931
import androidx.compose.ui.draw.clip
3032
import androidx.compose.ui.graphics.Color
3133
import androidx.compose.ui.platform.LocalContext
34+
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
3235
import androidx.compose.ui.res.painterResource
36+
import androidx.compose.ui.text.input.ImeAction
3337
import androidx.compose.ui.tooling.preview.Preview
3438
import androidx.compose.ui.unit.dp
3539
import androidx.compose.ui.unit.sp
@@ -60,6 +64,7 @@ fun InitialFlow7Screen(navController: NavHostController) {
6064
var imageUri: Uri? by remember {
6165
mutableStateOf(null)
6266
}
67+
val keyboardController = LocalSoftwareKeyboardController.current
6368
val launcher =
6469
rememberLauncherForActivityResult(contract = ActivityResultContracts.GetContent()) { uri ->
6570
if (uri == null) return@rememberLauncherForActivityResult
@@ -116,14 +121,25 @@ fun InitialFlow7Screen(navController: NavHostController) {
116121
onValueChange = { newValue -> text.value = newValue },
117122
placeholder = { Text(text = "名前をここに入力してね") },
118123
colors =
119-
TextFieldDefaults.textFieldColors(
120-
containerColor = GranulatedSugar,
124+
TextFieldDefaults.colors(
125+
focusedContainerColor = GranulatedSugar,
126+
unfocusedLabelColor = GranulatedSugar,
121127
),
122128
modifier =
123129
Modifier
124-
.padding(0.dp, 40.dp, 0.dp, 0.dp)
125-
.clip(CircleShape)
126-
.size(350.dp, 55.dp),
130+
.fillMaxWidth()
131+
.padding(horizontal = 10.dp, vertical = 40.dp),
132+
singleLine = true,
133+
keyboardOptions =
134+
KeyboardOptions.Default.copy(
135+
imeAction = ImeAction.Done,
136+
),
137+
keyboardActions =
138+
KeyboardActions(
139+
onDone = {
140+
keyboardController?.hide()
141+
},
142+
),
127143
)
128144
Text(
129145
text = "※名前とアイコンは",

app/src/main/java/com/example/runningavater/initialFlow/InitialFlow8.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.Column
1010
import androidx.compose.foundation.layout.fillMaxSize
1111
import androidx.compose.foundation.layout.fillMaxWidth
1212
import androidx.compose.foundation.layout.padding
13+
import androidx.compose.foundation.text.KeyboardActions
1314
import androidx.compose.foundation.text.KeyboardOptions
1415
import androidx.compose.material3.DropdownMenuItem
1516
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -27,6 +28,8 @@ import androidx.compose.ui.Alignment
2728
import androidx.compose.ui.Modifier
2829
import androidx.compose.ui.graphics.Color
2930
import androidx.compose.ui.platform.LocalContext
31+
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
32+
import androidx.compose.ui.text.input.ImeAction
3033
import androidx.compose.ui.text.input.KeyboardType
3134
import androidx.compose.ui.text.style.TextAlign
3235
import androidx.compose.ui.tooling.preview.Preview
@@ -57,6 +60,7 @@ fun InitialFlow8Screen(navController: NavHostController) {
5760
val viewModel: TargetSettings = viewModel()
5861
val context = LocalContext.current
5962
val text = remember { mutableStateOf("") }
63+
val keyboardController = LocalSoftwareKeyboardController.current
6064

6165
InitialFlowBackground {
6266
Box(modifier = Modifier.fillMaxSize()) {
@@ -101,7 +105,15 @@ fun InitialFlow8Screen(navController: NavHostController) {
101105
keyboardOptions =
102106
KeyboardOptions(
103107
keyboardType = KeyboardType.Number,
108+
imeAction = ImeAction.Done,
104109
),
110+
keyboardActions =
111+
KeyboardActions(
112+
onDone = {
113+
keyboardController?.hide()
114+
},
115+
),
116+
singleLine = true,
105117
)
106118
Text(
107119
text = "目標期間",
@@ -170,7 +182,7 @@ fun InitialFlow8Screen(navController: NavHostController) {
170182
) {
171183
NextButton(
172184
navController = navController,
173-
nextDestination = "initialFlow/10",
185+
nextDestination = "initialFlow/9",
174186
modifier = Modifier.padding(20.dp, 0.dp, 20.dp, 10.dp),
175187
onClick = {
176188
viewModel.viewModelScope.launch {

app/src/main/java/com/example/runningavater/initialFlow/components/NextButton.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ fun NextButton(
2020
onClick: (() -> Unit)? = null,
2121
) {
2222
Button(
23-
onClick = { navController.navigate(nextDestination) },
23+
onClick = {
24+
onClick?.invoke()
25+
navController.navigate(nextDestination)
26+
},
2427
modifier =
2528
modifier
2629
.fillMaxWidth(),

0 commit comments

Comments
 (0)