This file contains hidden or 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 ImagePicker() { | |
var imageUri: Uri? by remember { mutableStateOf(null) } | |
val context = LocalContext.current | |
val dataStore = remember { StoreData() } | |
val scope = rememberCoroutineScope() | |
val launcher = | |
rememberLauncherForActivityResult(contract = ActivityResultContracts.OpenDocument()) { | |
it?.let { uri -> | |
context.contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION ) |
This file contains hidden or 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 StoreData { | |
private val Context.storeData: DataStore<Preferences> by preferencesDataStore(name = "data") | |
suspend fun storeImage(context: Context, value: String) { | |
context.storeData.edit { preferences -> | |
preferences[stringPreferencesKey("image")] = value | |
} | |
} | |
suspend fun getImage(context: Context): Flow<String?> { | |
return context.storeData.data.map { | |
preferences -> |
This file contains hidden or 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 ImagePicker() { | |
var imageUri: Uri? by remember { | |
mutableStateOf(null) | |
} | |
val launcher = | |
rememberLauncherForActivityResult(contract = ActivityResultContracts.OpenDocument()) { | |
it?.let { uri -> | |
imageUri = uri | |
} |
This file contains hidden or 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 MapScreen() { | |
var point: Point? by remember { | |
mutableStateOf(null) | |
} | |
var relaunch by remember { | |
mutableStateOf(false) | |
} | |
val context = LocalContext.current | |
val permissionRequest = rememberLauncherForActivityResult( |
This file contains hidden or 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 MapBoxMap( | |
modifier: Modifier = Modifier, | |
onPointChange: (Point) -> Unit, | |
point: Point?, | |
) { | |
val context = LocalContext.current | |
val marker = remember(context) { | |
context.getDrawable(R.drawable.marker)!!.toBitmap() | |
} |
This file contains hidden or 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 MapScreen() { | |
var point: Point? by remember { | |
mutableStateOf(null) | |
} | |
var relaunch by remember { | |
mutableStateOf(false) | |
} | |
val context = LocalContext.current | |
This file contains hidden or 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 MapScreen() { | |
Column( | |
modifier = Modifier.fillMaxSize(), | |
) { | |
MapBoxMap( | |
point = Point.fromLngLat(-0.6333, 35.6971), | |
modifier = Modifier | |
.fillMaxSize() | |
) |
This file contains hidden or 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 MapBoxMap( | |
modifier: Modifier = Modifier, | |
point: Point?, | |
) { | |
val context = LocalContext.current | |
val marker = remember(context) { | |
context.getDrawable(R.drawable.marker)!!.toBitmap() | |
} | |
var pointAnnotationManager: PointAnnotationManager? by remember { |
This file contains hidden or 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
pluginManagement { | |
repositories { | |
google() | |
mavenCentral() | |
gradlePluginPortal() | |
} | |
} | |
dependencyResolutionManagement { | |
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) | |
repositories { |
This file contains hidden or 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 MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
GetCurrentLocationUI() | |
} | |
} | |
} |
NewerOlder