-
Notifications
You must be signed in to change notification settings - Fork 0
ホーム画面実装 #102
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
ホーム画面実装 #102
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9819919
ホーム画面のくまちゃん調整
kdix-23-071 fe93a9c
トップバーの表示
kdix-23-071 5e5d181
ナビゲーションバーの調整
kdix-23-071 5ae3c95
歩数のテキストと背景調整
kdix-23-071 2ce53ee
フォーマット整えました
kdix-23-071 25d4bf2
手動でフォーマット整えました
kdix-23-071 548d508
インデント整えました
kdix-23-071 0e755ae
ホーム画面にお花を表示しました
kdix-23-071 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 116 additions & 1 deletion
117
app/src/main/java/com/example/runningavater/home/HomeScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,123 @@ | ||
package com.example.runningavater.home | ||
|
||
import android.graphics.BitmapFactory | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.offset | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.asImageBitmap | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.example.runningavater.ui.theme.NuclearMango | ||
import java.text.SimpleDateFormat | ||
import java.util.Date | ||
import java.util.Locale | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun HomeScreen() { | ||
Bear3D(assetFileLocation = "fatBear.glb") | ||
// 現在の日付と曜日を保持するState | ||
val currentDate = remember { mutableStateOf(getCurrentDate()) } | ||
|
||
// 日時を更新するためのLaunchedEffect | ||
LaunchedEffect(Unit) { | ||
while (true) { | ||
currentDate.value = getCurrentDate() | ||
kotlinx.coroutines.delay(60000L) // 1分ごとに更新 | ||
} | ||
} | ||
Scaffold( | ||
topBar = { | ||
// ヘッダーの表示 | ||
TopAppBar( | ||
colors = | ||
TopAppBarDefaults.topAppBarColors( | ||
containerColor = NuclearMango, | ||
titleContentColor = MaterialTheme.colorScheme.background, | ||
), | ||
title = { | ||
// 日付と曜日を表示 | ||
Text(text = currentDate.value) | ||
}, | ||
) | ||
}, | ||
) { | ||
Box(Modifier.padding(it)) { | ||
Bear3D(assetFileLocation = "fatBear.glb") | ||
Row( | ||
modifier = | ||
Modifier | ||
.align(Alignment.TopCenter) | ||
.offset(y = 15.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
SetImage( | ||
fileName = "flowers_big.PNG", | ||
modifier = Modifier.size(120.dp), | ||
) | ||
|
||
// 歩数の数字の部分 | ||
Text( | ||
text = "35", | ||
fontSize = 96.sp, | ||
color = NuclearMango, | ||
) | ||
// 調整のためのスペース挿入 | ||
Spacer(Modifier.width(11.dp)) | ||
// ”歩”の文字 | ||
Text( | ||
text = "歩", | ||
fontSize = 32.sp, | ||
color = NuclearMango, | ||
) | ||
SetImage( | ||
fileName = "flowers_right.PNG", | ||
modifier = Modifier.size(120.dp), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// 現在の日付と曜日を取得する関数 | ||
// トップバーで使ってます | ||
fun getCurrentDate(): String { | ||
// 日付と曜日をフォーマットする(例:09/11 (Wed)) | ||
val dateFormat = SimpleDateFormat("MM/dd (E)", Locale.getDefault()) | ||
return dateFormat.format(Date()) | ||
} | ||
|
||
@Composable | ||
fun SetImage( | ||
fileName: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
// assets フォルダから画像をロード | ||
val context = LocalContext.current | ||
val assetManager = context.assets | ||
val bitmap = BitmapFactory.decodeStream(assetManager.open(fileName)) | ||
|
||
// 画像を表示 | ||
Image( | ||
bitmap = bitmap.asImageBitmap(), | ||
contentDescription = null, | ||
modifier = modifier, | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[must]
SungYellowのカラーコードはFEDB81のはず...?
変更の意図等あれば教えてください。