Skip to content
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

Added Kotlin formatter plugin to Gradle [#60] #62

Merged
merged 1 commit into from
Jul 27, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --info
run: ./gradlew build check sonar --info
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MainActivity : ComponentActivity() {
VariantTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
color = MaterialTheme.colorScheme.background,
) {
val serverList by serverViewModel.serverList.collectAsStateWithLifecycle()
val linkList by serverLinkViewModel.displayLinkList.collectAsStateWithLifecycle()
Expand All @@ -63,11 +63,12 @@ class MainActivity : ComponentActivity() {
name,
url,
username,
password
password,
)
})
},
)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ lateinit var koin: Koin
* @author Darryl L. Pierce
*/
class VariantApp : Application() {

override fun onCreate() {
super.onCreate()

VariantApp.appContext = applicationContext

koin = initKoin(
appModule = module {
single<Context> { this@VariantApp }

},
viewModelsModule = module { }).koin
koin =
initKoin(
appModule =
module {
single<Context> { this@VariantApp }
},
viewModelsModule = module { },
).koin
}

companion object {
lateinit var appContext: Context
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,42 @@ import androidx.compose.ui.unit.sp
@Composable
fun VariantTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
val colors = if (darkTheme) {
darkColorScheme(
primary = Color(0xFFBB86FC),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3)
val colors =
if (darkTheme) {
darkColorScheme(
primary = Color(0xFFBB86FC),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3),
)
} else {
lightColorScheme(
primary = Color(0xFF6200EE),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3),
)
}
val typography =
Typography(
bodyMedium =
TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
),
)
} else {
lightColorScheme(
primary = Color(0xFF6200EE),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3)
val shapes =
Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp),
)
}
val typography = Typography(
bodyMedium = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
)
)
val shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
)

MaterialTheme(
colorScheme = colors,
typography = typography,
shapes = shapes,
content = content
content = content,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ import org.comixedproject.variant.android.R
*
* @author Darryl L. Pierce
*/
enum class BottomBarItem(val label: Int, val icon: ImageVector, val screen: NavigationScreen) {
enum class BottomBarItem(
val label: Int,
val icon: ImageVector,
val screen: NavigationScreen,
) {
ServerList(R.string.serverButtonLabel, Icons.Filled.AccountBox, NavigationScreen.Servers),
ComicList(
R.string.comicsButtonLabel,
Icons.AutoMirrored.Filled.List,
NavigationScreen.ComicList
NavigationScreen.ComicList,
),
Settings(R.string.settingsButtonLabel, Icons.Filled.Settings, NavigationScreen.Settings);
Settings(R.string.settingsButtonLabel, Icons.Filled.Settings, NavigationScreen.Settings),
;

companion object {
val all = values()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ import org.comixedproject.variant.android.VariantTheme
@Composable
fun BottomBarView(
currentDestination: NavDestination?,
onScreenChange: (route: String) -> Unit
onScreenChange: (route: String) -> Unit,
) {
var selectedItem by remember { mutableIntStateOf(0) }

NavigationBar {
BottomBarItem.all.forEachIndexed { index, item ->
NavigationBarItem(selected = selectedItem == index,
NavigationBarItem(
selected = selectedItem == index,
onClick = {
selectedItem = index
onScreenChange(item.screen.route)
Expand All @@ -55,9 +56,10 @@ fun BottomBarView(
icon = {
Icon(
imageVector = item.icon,
contentDescription = stringResource(id = item.label)
contentDescription = stringResource(id = item.label),
)
})
},
)
}
}
}
Expand All @@ -68,4 +70,4 @@ fun BottomBarPreview() {
VariantTheme {
BottomBarView(null, onScreenChange = {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,44 +63,51 @@ fun HomeView(
serverViewModel: ServerViewModel,
linkList: List<ServerLink>,
serverLinkViewModel: ServerLinkViewModel,
onSaveServer: (Long?, String, String, String, String) -> Unit
onSaveServer: (Long?, String, String, String, String) -> Unit,
) {
val navController = rememberNavController()

Scaffold(
topBar = {
TopAppBar(
navigationIcon = {
Icon(imageVector = Icons.Filled.Menu, contentDescription = "Menu",
modifier = Modifier.clickable { })
Icon(
imageVector = Icons.Filled.Menu,
contentDescription = "Menu",
modifier = Modifier.clickable { },
)
},
title = {
var title = stringResource(id = R.string.appName)
Text(title)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = colorScheme.primaryContainer,
titleContentColor = colorScheme.primary
)
colors =
TopAppBarDefaults.topAppBarColors(
containerColor = colorScheme.primaryContainer,
titleContentColor = colorScheme.primary,
),
)
},
bottomBar = {
BottomBarView(currentDestination = navController.currentBackStackEntryAsState().value?.destination,
onScreenChange = { route -> navController.navigate(route) })
BottomBarView(
currentDestination = navController.currentBackStackEntryAsState().value?.destination,
onScreenChange = { route -> navController.navigate(route) },
)
},
) { padding ->
Column(
modifier = Modifier
.padding(padding)
.fillMaxSize()
modifier =
Modifier
.padding(padding)
.fillMaxSize(),
) {
NavHost(
modifier = Modifier,
navController = navController,
startDestination = NavigationScreen.Servers.route
startDestination = NavigationScreen.Servers.route,
) {
composable(
route = NavigationScreen.Servers.route
route = NavigationScreen.Servers.route,
) {
ServerManagementView(
servers = serverList,
Expand All @@ -110,34 +117,37 @@ fun HomeView(
serverLinkViewModel.directory = server.url
navController.navigate("servers?serverId=${server.serverId}")
},
onDeleteServer = { }
onDeleteServer = { },
)
}
composable(
route = NavigationScreen.BrowseServer.route,
arguments = NavigationScreen.BrowseServer.navArguments
arguments = NavigationScreen.BrowseServer.navArguments,
) { entry ->
val serverId = entry.arguments?.getLong(NAVARG_SERVER_ID)
Logger.d(TAG, "serverId=${serverId} directory=${serverLinkViewModel.directory}")
Logger.d(TAG, "serverId=$serverId directory=${serverLinkViewModel.directory}")
val currentServer =
serverList.firstOrNull { server -> server.serverId == serverId }

if (currentServer != null) {
BrowseServerView(
server = currentServer,
serverLinks = linkList.filter { link -> link.serverId == currentServer.serverId }
.filter { link -> link.directory == serverLinkViewModel.directory }
.toList(),
serverLinks =
linkList
.filter { link -> link.serverId == currentServer.serverId }
.filter { link -> link.directory == serverLinkViewModel.directory }
.toList(),
serverLinkViewModel.directory,
onLoadDirectory = { target, selectedLink ->
serverLinkViewModel.loadServerDirectory(
target,
selectedLink.href,
false
false,
)
serverLinkViewModel.directory = selectedLink.href
navController.navigate("servers?serverId=${target.serverId}")
})
},
)
}
}
composable(route = NavigationScreen.ComicList.route) {
Expand All @@ -161,12 +171,12 @@ fun HomeSPreview() {
Server(null, "Server 2", "", "", ""),
Server(null, "Server 3", "", "", ""),
Server(null, "Server 4", "", "", ""),
Server(null, "Server 5", "", "", "")
Server(null, "Server 5", "", "", ""),
),
ServerViewModel(),
emptyList(),
ServerLinkViewModel(),
onSaveServer = { _, _, _, _, _ -> }
onSaveServer = { _, _, _, _, _ -> },
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,24 @@ const val NAVARG_SERVER_ID = "serverId"
*
* @author Darryl L. Pierce
*/
enum class NavigationScreen(val route: String, val navArguments: List<NamedNavArgument>) {
enum class NavigationScreen(
val route: String,
val navArguments: List<NamedNavArgument>,
) {
ComicList("comics", emptyList()),
Servers("servers", emptyList()),
BrowseServer(
"servers?serverId={serverId}", listOf(
"servers?serverId={serverId}",
listOf(
navArgument(NAVARG_SERVER_ID) {
type = NavType.LongType
}
)),
Settings("settings", emptyList());
},
),
),
Settings("settings", emptyList()),
;

companion object {
val all = values()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun SwipeBoxView(
modifier: Modifier = Modifier,
onDelete: () -> Unit,
onEdit: () -> Unit,
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
val swipeState = rememberSwipeToDismissBoxState()

Expand Down Expand Up @@ -85,16 +85,18 @@ fun SwipeBoxView(
backgroundContent = {
Box(
contentAlignment = alignment,
modifier = Modifier
.fillMaxSize()
.background(color)
modifier =
Modifier
.fillMaxSize()
.background(color),
) {
Icon(
modifier = Modifier.minimumInteractiveComponentSize(),
imageVector = icon, contentDescription = null
imageVector = icon,
contentDescription = null,
)
}
}
},
) {
content()
}
Expand All @@ -114,4 +116,4 @@ fun SwipeBoxView(
SwipeToDismissBoxValue.Settled -> {
}
}
}
}
Loading
Loading