Skip to content

Commit

Permalink
Merge pull request #71 from LeoAndo/release-v1.0.1
Browse files Browse the repository at this point in the history
Release v1.0.1のリリース
  • Loading branch information
LeoAndo authored Feb 15, 2023
2 parents 18b5703 + 316d8c9 commit ebdff9c
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 176 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Android CI

on:
push:
branches: [ "develop" ]
branches: [ "main", "develop", /^release\/.*$/ ]
pull_request:
branches: [ "develop" ]
branches: [ "main", "develop", /^release\/.*$/ ]

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .idea/androidTestResultsUserPreferences.xml

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

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "com.leoleo.androidgithubsearch"
minSdk 29
targetSdk 33
versionCode 100
versionName "1.0.0"
versionCode 101
versionName "1.0.1"

testInstrumentationRunner "com.leoleo.androidgithubsearch.CustomTestRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ package com.leoleo.androidgithubsearch.ui
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import com.leoleo.androidgithubsearch.ui.compact.CompactMainScreen
import com.leoleo.androidgithubsearch.ui.component.AppSurface
import com.leoleo.androidgithubsearch.ui.expanded.ExpandedMainScreen
import com.leoleo.androidgithubsearch.ui.medium.MediumMainScreen

@Composable
fun MainScreen(windowWidthSizeClass: WindowWidthSizeClass) {
when (windowWidthSizeClass) {
WindowWidthSizeClass.Compact -> CompactMainScreen()
WindowWidthSizeClass.Medium -> MediumMainScreen()
WindowWidthSizeClass.Expanded -> ExpandedMainScreen()
AppSurface {
when (windowWidthSizeClass) {
WindowWidthSizeClass.Compact -> CompactMainScreen()
WindowWidthSizeClass.Medium -> MediumMainScreen()
WindowWidthSizeClass.Expanded -> ExpandedMainScreen()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.leoleo.androidgithubsearch.ui

import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.NavType
Expand All @@ -24,7 +23,7 @@ fun MyNavHost(
NavHost(
navController = navController,
startDestination = startDestination,
modifier = Modifier.fillMaxSize()
modifier = modifier
) {
// nest navigation
navigation(
Expand All @@ -35,7 +34,6 @@ fun MyNavHost(
route = GithubRepoSearchDestinations.TopRoute.routeName,
content = {
SearchScreen(
modifier = modifier,
navigateToDetailScreen = { ownerName, name ->
navController.navigate(
GithubRepoSearchDestinations.DetailRoute.withArgs(
Expand Down Expand Up @@ -63,7 +61,6 @@ fun MyNavHost(
val ownerName = it.arguments?.getString(ARG_KEY_OWNER_NAME) ?: return@composable
val name = it.arguments?.getString(ARG_KEY_NAME) ?: return@composable
DetailScreen(
modifier = modifier,
ownerName = ownerName,
name = name,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
package com.leoleo.androidgithubsearch.ui.compact

import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.leoleo.androidgithubsearch.R
import com.leoleo.androidgithubsearch.ui.MyNavHost
import com.leoleo.androidgithubsearch.ui.TopDestinations
import com.leoleo.androidgithubsearch.ui.component.AppSurface

@Composable
fun CompactMainScreen() {
AppSurface(
modifier = Modifier.testTag(stringResource(id = R.string.test_tag_compact_main_screen)),
) {
MyNavHost(
startDestination = TopDestinations.SearchRoute.routeName,
modifier = Modifier
.fillMaxSize()
.padding(12.dp)
)
}
MyNavHost(
startDestination = TopDestinations.SearchRoute.routeName,
modifier = Modifier.testTag(stringResource(id = R.string.test_tag_compact_main_screen))
)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.leoleo.androidgithubsearch.ui.detail

import androidx.compose.foundation.layout.*
import androidx.compose.material3.Text
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import coil.transform.CircleCropTransformation
Expand All @@ -19,7 +20,7 @@ import com.leoleo.androidgithubsearch.ui.preview.PreviewDevices

@Composable
fun DetailScreen(
modifier: Modifier,
modifier: Modifier = Modifier,
ownerName: String,
name: String,
viewModel: DetailViewModel = hiltViewModel()
Expand All @@ -28,76 +29,89 @@ fun DetailScreen(
viewModel.getRepositoryDetail(ownerName, name)
})
DetailScreenStateless(
modifier = modifier.fillMaxSize(),
uiState = viewModel.uiState,
modifier = modifier,
onReload = { viewModel.getRepositoryDetail(ownerName, name) },
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun DetailScreenStateless(
modifier: Modifier = Modifier,
uiState: UiState,
modifier: Modifier,
onReload: () -> Unit,
) {
when (uiState) {
UiState.Initial -> {}
UiState.Loading -> AppLoading(modifier = Modifier.fillMaxSize())
is UiState.Error -> {
val throwable = uiState.throwable
val defaultErrorMessage = throwable.localizedMessage
?: stringResource(id = R.string.default_error_message)
val message = if (throwable is ApiErrorType) {
when (throwable) {
ApiErrorType.Network -> stringResource(id = R.string.network_error_message)
is ApiErrorType.NotFound, is ApiErrorType.Forbidden, is ApiErrorType.UnAuthorized,
is ApiErrorType.UnprocessableEntity, is ApiErrorType.Unknown, ApiErrorType.Redirect, ApiErrorType.Server -> {
defaultErrorMessage
Scaffold(topBar = { TopAppBar(title = { Text(text = stringResource(id = R.string.app_name)) }) }) {
val padding = PaddingValues(
top = it.calculateTopPadding() + 12.dp,
bottom = it.calculateBottomPadding() + 12.dp,
start = it.calculateStartPadding(LayoutDirection.Ltr) + 12.dp,
end = it.calculateEndPadding(LayoutDirection.Ltr) + 12.dp,
)
when (uiState) {
UiState.Initial -> {}
UiState.Loading -> AppLoading(modifier = Modifier.fillMaxSize())
is UiState.Error -> {
val throwable = uiState.throwable
val defaultErrorMessage = throwable.localizedMessage
?: stringResource(id = R.string.default_error_message)
val message = if (throwable is ApiErrorType) {
when (throwable) {
ApiErrorType.Network -> stringResource(id = R.string.network_error_message)
is ApiErrorType.NotFound, is ApiErrorType.Forbidden, is ApiErrorType.UnAuthorized,
is ApiErrorType.UnprocessableEntity, is ApiErrorType.Unknown, ApiErrorType.Redirect, ApiErrorType.Server -> {
defaultErrorMessage
}
}
} else {
defaultErrorMessage
}
} else {
defaultErrorMessage
AppError(message = message, onReload = onReload, modifier = Modifier.fillMaxSize())
AppAlertDialog(
titleText = stringResource(id = R.string.app_name),
messageText = message,
confirmText = stringResource(id = android.R.string.ok),
)
}
AppError(message = message, onReload = onReload, modifier = Modifier.fillMaxSize())
AppAlertDialog(
titleText = stringResource(id = R.string.app_name),
messageText = message,
confirmText = stringResource(id = android.R.string.ok),
)
}
is UiState.Data -> {
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(20.dp)) {
val data = uiState.repositoryDetail
Row(verticalAlignment = Alignment.CenterVertically) {
AppNetworkImage(
imageUrl = data.ownerAvatarUrl,
contentDescription = stringResource(R.string.content_description_owner_avatar_icon),
modifier = Modifier.size(60.dp),
transformations = listOf(CircleCropTransformation())
)
Spacer(modifier = Modifier.size(12.dp))
Text(text = data.name, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
Text(
text = stringResource(
id = R.string.stargazers_count,
data.stargazersCount
is UiState.Data -> {
Column(
modifier = modifier
.padding(padding),
verticalArrangement = Arrangement.spacedBy(20.dp)
) {
val data = uiState.repositoryDetail
Row(verticalAlignment = Alignment.CenterVertically) {
AppNetworkImage(
imageUrl = data.ownerAvatarUrl,
contentDescription = stringResource(R.string.content_description_owner_avatar_icon),
modifier = Modifier.size(60.dp),
transformations = listOf(CircleCropTransformation())
)
Spacer(modifier = Modifier.size(12.dp))
Text(text = data.name, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
Text(
text = stringResource(
id = R.string.stargazers_count,
data.stargazersCount
)
)
)
Text(text = stringResource(id = R.string.forks_count, data.forksCount))
Text(
text = stringResource(
id = R.string.open_issues_count,
data.openIssuesCount
Text(text = stringResource(id = R.string.forks_count, data.forksCount))
Text(
text = stringResource(
id = R.string.open_issues_count,
data.openIssuesCount
)
)
)
Text(
text = stringResource(
id = R.string.watchers_count,
data.watchersCount
Text(
text = stringResource(
id = R.string.watchers_count,
data.watchersCount
)
)
)
data.language?.let { Text(text = stringResource(id = R.string.language, it)) }
data.language?.let { Text(text = stringResource(id = R.string.language, it)) }
}
}
}
}
Expand All @@ -117,10 +131,9 @@ private fun Prev_DetailScreen() {
)
AppSurface {
DetailScreenStateless(
uiState = UiState.Data(data),
modifier = Modifier
.fillMaxSize()
.padding(12.dp),
.fillMaxSize(),
uiState = UiState.Data(data),
onReload = {},
)
}
Expand Down
Loading

0 comments on commit ebdff9c

Please sign in to comment.