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 DetailsScreen( | |
modifier: Modifier = Modifier, | |
user: User?, | |
onDismiss: () -> Unit, | |
onSharing: () -> Unit, | |
onAddNewUserClicked: () -> Unit | |
) { | |
if (user == null) | |
UserNotFoundDialog( |
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
object SharingUtil { | |
... | |
// add the following two functions | |
@RequiresApi(Build.VERSION_CODES.S) | |
@Composable | |
fun CheckIfAppApprovedForDomain() { | |
val context = LocalContext.current | |
val domain = context.getString(R.string.host) |
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
object SharingUtil { | |
private fun Context.createUserSharingUrl(id: Int): String { | |
val scheme = getString(R.string.scheme) | |
val host = getString(R.string.host) | |
val path = getString(R.string.path_to_existed_user) | |
return "$scheme://$host$path?userId=$id" | |
} | |
fun shareUserUrl(context: Context, user: User) { |
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
@OptIn(ExperimentalLifecycleComposeApi::class) | |
@Composable | |
private fun App() { | |
... | |
NavHost(navController = navController, startDestination = Destinations.Home.route) { | |
// main screen | |
... | |
// details screen |
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
<manifest ...> | |
<application | |
...> | |
<activity | |
....> | |
.... | |
<intent-filter > | |
<category android:name="android.intent.category.DEFAULT" /> | |
<category android:name="android.intent.category.BROWSABLE"/> | |
<action android:name="android.intent.action.VIEW" /> |
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
sealed class Destinations(val route: String) { | |
object Home : Destinations("home") | |
object Details : Destinations("details/{userId}") { | |
fun setAndGetArgumentRoute(id: Int) = route.replace("{userId}", id.toString()) | |
} | |
// add this | |
object AddNewUser : Destinations("add_new_user") | |
} |
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
sealed class Destinations(val route: String) { | |
object Home : Destinations("home") | |
object Details : Destinations("details/{userId}") { | |
fun setAndGetArgumentRoute(id: Int) = route.replace("{userId}", id.toString()) | |
} | |
} |
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
@OptIn(ExperimentalLifecycleComposeApi::class) | |
@Composable | |
private fun App() { | |
val db = remember { UserDatabase.getUserDatabase(this) } | |
val viewModel = | |
viewModel<MainViewModel>(factory = MainViewModel.Companion.MainViewModelFactory(db)) | |
val navController = rememberNavController() | |
val users by viewModel.users.collectAsStateWithLifecycle() | |
NavHost(navController = navController, startDestination = Destinations.Home.route) { |
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
<manifest ...> | |
<application | |
...> | |
<activity | |
....> | |
.... | |
<intent-filter > | |
<category android:name="android.intent.category.DEFAULT" /> | |
<category android:name="android.intent.category.BROWSABLE"/> | |
<action android:name="android.intent.action.VIEW" /> |
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
class RemoteWidget : GlanceAppWidget(errorUiLayout = R.layout.widget_error_layout) { | |
override val stateDefinition: GlanceStateDefinition<*> | |
get() = CustomGlanceStateDefinition | |
@Composable | |
override fun Content() { | |
val pref = currentState<Preferences>() |
NewerOlder