Created
November 2, 2022 13:31
-
-
Save Wajahat-Jawaid/215abfd38066d867afce2226500818a6 to your computer and use it in GitHub Desktop.
This file contains 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
@Composable | |
fun JetFilesApp( | |
appContainer: AppContainer | |
) { | |
JetFilesTheme { | |
ProvideWindowInsets { | |
// Drawing content behind the system windows. Just a UX thing! | |
val systemUiController = rememberSystemUiController() | |
SideEffect { | |
systemUiController.setSystemBarsColor(Color.Transparent, darkIcons = true) | |
} | |
val homeViewModel: HomeViewModel = viewModel( | |
factory = HomeViewModel.provideFactory(appContainer.fileRepository) | |
) | |
val context = LocalContext.current | |
Scaffold { padding -> | |
HomeScreen( | |
modifier = Modifier | |
.fillMaxWidth() | |
.fillMaxHeight(), | |
homeViewModel = homeViewModel, | |
onSelectFile = { onSelectFile(context, it) } | |
) | |
} | |
} | |
} | |
} | |
fun onSelectFile(context: Context, path: String) { | |
val uri = FileProvider.getUriForFile(context, "${context.packageName}.provider", File(path)) | |
val intent = Intent(Intent.ACTION_VIEW) | |
intent.data = uri | |
context.startActivity(intent) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment