Skip to content

Commit 3e058d8

Browse files
authored
Merge pull request #2 from flamyoad/feat/file-main-ui
(feat) File page
2 parents 13ffca5 + 51633e5 commit 3e058d8

24 files changed

Lines changed: 274 additions & 59 deletions

File tree

app/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ dependencies {
6464
implementation(project(ProjectModules.commonUi))
6565
implementation(project(ProjectModules.fileScanner))
6666
implementation(project(ProjectModules.fileScannerImpl))
67+
implementation(project(ProjectModules.explorer))
68+
implementation(project(ProjectModules.explorerImpl))
6769

6870
implementation(Libs.AndroidX.coreKtx)
6971
implementation(Libs.AndroidX.appCompat)
@@ -82,6 +84,7 @@ dependencies {
8284
implementation(Libs.Lifecycle.runtimeKtx)
8385

8486
implementation(Libs.Hilt.hilt)
87+
implementation(Libs.Hilt.hiltNavigationCompose)
8588
kapt(Libs.Hilt.hiltCompiler)
8689

8790
implementation(Libs.timber)

app/src/main/java/com/flamyoad/filemanager/MainActivity.kt

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,19 @@ package com.flamyoad.filemanager
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6-
import androidx.compose.foundation.layout.Arrangement
7-
import androidx.compose.foundation.layout.Column
8-
import androidx.compose.foundation.layout.Spacer
9-
import androidx.compose.foundation.layout.fillMaxSize
10-
import androidx.compose.foundation.layout.height
11-
import androidx.compose.material3.Button
12-
import androidx.compose.material3.MaterialTheme
13-
import androidx.compose.material3.Surface
14-
import androidx.compose.material3.Text
15-
import androidx.compose.runtime.Composable
16-
import androidx.compose.ui.Alignment
17-
import androidx.compose.ui.Modifier
18-
import androidx.compose.ui.platform.LocalContext
19-
import androidx.compose.ui.unit.dp
206
import com.flamyoad.common_ui.theme.FileManagerTheme
21-
import com.flamyoad.gallery_kit.GalleryKit
7+
import com.flamyoad.filemanager.ui.FileManagerApp
228
import dagger.hilt.android.AndroidEntryPoint
23-
import javax.inject.Inject
249

2510
@AndroidEntryPoint
2611
class MainActivity : ComponentActivity() {
2712

28-
@Inject lateinit var galleryKit: GalleryKit
29-
3013
override fun onCreate(savedInstanceState: Bundle?) {
3114
super.onCreate(savedInstanceState)
3215
setContent {
33-
val context = LocalContext.current
3416
FileManagerTheme {
35-
// A surface container using the 'background' color from the theme
36-
Surface(
37-
modifier = Modifier.fillMaxSize(),
38-
color = MaterialTheme.colorScheme.background
39-
) {
40-
Column(
41-
verticalArrangement = Arrangement.Center,
42-
horizontalAlignment = Alignment.CenterHorizontally
43-
) {
44-
Greeting("Android")
45-
Spacer(Modifier.height(4.dp))
46-
Button(onClick = { galleryKit.openImage(context) }) {
47-
Text("Open kit")
48-
}
49-
}
50-
}
17+
FileManagerApp()
5118
}
5219
}
5320
}
5421
}
55-
56-
@Composable
57-
fun Greeting(name: String, modifier: Modifier = Modifier) {
58-
Text(
59-
text = "Hello $name!",
60-
modifier = modifier
61-
)
62-
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.flamyoad.filemanager.ui
2+
3+
import androidx.compose.foundation.layout.padding
4+
import androidx.compose.material3.Scaffold
5+
import androidx.compose.material3.Text
6+
import androidx.compose.runtime.Composable
7+
import androidx.compose.runtime.getValue
8+
import androidx.compose.ui.Modifier
9+
import androidx.navigation.NavHostController
10+
import androidx.navigation.compose.currentBackStackEntryAsState
11+
import androidx.navigation.compose.rememberNavController
12+
13+
@Composable
14+
fun FileManagerApp(
15+
navController: NavHostController = rememberNavController()
16+
) {
17+
val backStackEntry by navController.currentBackStackEntryAsState()
18+
val currentScreen = backStackEntry?.destination?.route
19+
20+
Scaffold { innerPadding ->
21+
FileManagerNavHost(
22+
navController = navController,
23+
modifier = Modifier.padding(innerPadding),
24+
)
25+
}
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.flamyoad.filemanager.ui
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.ui.Modifier
5+
import androidx.navigation.NavHostController
6+
import androidx.navigation.compose.NavHost
7+
import androidx.navigation.compose.composable
8+
import com.flamyoad.explorer_impl.HOME_PAGE_ROUTE
9+
import com.flamyoad.explorer_impl.homePageRoute
10+
11+
@Composable
12+
fun FileManagerNavHost(
13+
modifier: Modifier = Modifier,
14+
navController: NavHostController,
15+
startDestination: String = HOME_PAGE_ROUTE
16+
) {
17+
NavHost(
18+
navController = navController,
19+
startDestination = startDestination,
20+
modifier = modifier
21+
) {
22+
homePageRoute()
23+
}
24+
}

buildSrc/src/main/kotlin/Libs.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ object Libs {
33
const val navigationVersion = "2.5.1"
44
const val lifecycleVersion = "2.6.0"
55
const val hiltVersion = "2.50"
6+
const val androidxHiltVersion = "1.2.0"
67
const val dataStoreVersion = "1.0.0"
78
const val coroutineVersion = "1.6.0"
89

@@ -40,6 +41,7 @@ object Libs {
4041
object Hilt {
4142
const val hilt = "com.google.dagger:hilt-android:$hiltVersion"
4243
const val hiltCompiler = "com.google.dagger:hilt-android-compiler:$hiltVersion"
44+
const val hiltNavigationCompose = "androidx.hilt:hilt-navigation-compose:$androidxHiltVersion"
4345
}
4446

4547
object Coroutines {

buildSrc/src/main/kotlin/ProjectModules.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ object ProjectModules {
1212

1313
const val fileScanner = ":file-scanner"
1414
const val fileScannerImpl = ":file-scanner-impl"
15+
16+
const val explorer = ":explorer"
17+
const val explorerImpl = ":explorer-impl"
1518
}

explorer-impl/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

explorer-impl/build.gradle.kts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id("com.android.library")
3+
id("android-library-base")
4+
id("kotlin-kapt")
5+
id("com.google.dagger.hilt.android")
6+
}
7+
8+
android {
9+
namespace = "com.flamyoad.explorer_impl"
10+
11+
buildFeatures {
12+
compose = true
13+
}
14+
composeOptions {
15+
kotlinCompilerExtensionVersion = AppConfigs.kotlinCompilerExtensionVersion
16+
}
17+
}
18+
19+
20+
dependencies {
21+
implementation(project(ProjectModules.explorer))
22+
implementation(project(ProjectModules.fileScanner))
23+
implementation(project(ProjectModules.common))
24+
implementation(project(ProjectModules.commonUi))
25+
26+
implementation(Libs.AndroidX.coreKtx)
27+
28+
implementation(Libs.Coroutines.core)
29+
implementation(Libs.Coroutines.android)
30+
31+
implementation(Libs.Navigation.navigationCompose)
32+
33+
implementation(Libs.Lifecycle.runtimeCompose)
34+
35+
implementation(platform(Libs.Compose.bom))
36+
implementation(Libs.Compose.ui)
37+
implementation(Libs.Compose.uiGraphics)
38+
implementation(Libs.Compose.toolingPreview)
39+
implementation(Libs.Compose.material3)
40+
implementation(Libs.Compose.activityCompose)
41+
42+
implementation(Libs.Hilt.hilt)
43+
implementation(Libs.Hilt.hiltNavigationCompose)
44+
kapt(Libs.Hilt.hiltCompiler)
45+
46+
testImplementation(Libs.Testing.junit)
47+
}

explorer-impl/consumer-rules.pro

Whitespace-only changes.

explorer-impl/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

0 commit comments

Comments
 (0)