Skip to content

Instantly share code, notes, and snippets.

View agarasul's full-sized avatar

agarasul

View GitHub Profile
@agarasul
agarasul / MapDrawer.kt
Created December 13, 2023 14:01
Map Drawer Part 2
@Composable
fun MapDrawer(onDrawingEnd : (List<Point>) -> Unit) {
var state by remember { mutableStateOf(MapPolygonState()) }
val brush = remember { SolidColor(Color.Black) }
val path = remember { Path() }
Canvas(
modifier = Modifier
.fillMaxSize()
.pointerInput(Unit) {
awaitEachGesture {
@agarasul
agarasul / MapDrawerFull.kt
Last active December 13, 2023 13:23
MapDrawerFull
enum class DrawerMotionEvent { idle, down, up, move }
data class MapDrawState(
val currentPosition: Offset = Offset.Unspecified,
val event: MotionEvent = MotionEvent.idle
)
@Composable
fun MapDrawer() {
var state by remember { mutableStateOf(MapDrawState()) }
@agarasul
agarasul / MapDrawer.kt
Last active December 13, 2023 13:23
Map drawer
enum class DrawerMotionEvent { idle, down, up, move }
data class MapDrawState(
val currentPosition: Offset = Offset.Unspecified,
val event: MotionEvent = MotionEvent.idle
)
@Composable
fun MapDrawer() {
var state by remember { mutableStateOf(MapDrawState()) }
@agarasul
agarasul / bottom_sheet.kt
Created March 3, 2021 15:27
BottomSheet Composable
@ExperimentalMaterialApi
@Composable
fun HomeScreen() {
val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = BottomSheetState(BottomSheetValue.Collapsed)
)
val coroutineScope = rememberCoroutineScope()
BottomSheetScaffold(
scaffoldState = bottomSheetScaffoldState,
sheetContent = {
object LocaleHelper {
private val SELECTED_LANGUAGE = "app_lang"
fun onAttach(context: Context): Context {
val langu = getPersistedData(context, Locale.getDefault().language)
return setLocale(context, langu)
}
fun onAttach(context: Context, defaultLanguage: String): Context {
public class Incrementor {
/**
* The current number
*/
private int number = 0;
/**
* The maximum value that number can be
*/
private int max = Integer.MAX_VALUE;
import 'package:flutter/material.dart';
import 'package:news_app/entity/news.dart';
class ListItem extends StatelessWidget {
final Article article;
ListItem(this.article);
@override
Widget build(BuildContext context) {
Expanded(
child: Padding(
padding: EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(article.title),
Text(article.description)
]),
),
void getData() async {
http.Response response = await http.get(
"https://newsapi.org/v2/top-headlines?country=us&apiKey=YOUR_API_KEY");
setState(() {
_newsList = News.fromJson(json.decode(response.body)).articles;
});
}
void getData() async {
var response = await http.get(
"https://newsapi.org/v2/top-headlines?country=us&apiKey=821a22ad51e240fb9c131c4b00009630");
setState(() {
if (response.statusCode == 200) {
items.addAll(News.fromJson(json.decode(response.body)).articles);
}
});
}