Skip to content

Instantly share code, notes, and snippets.

View cicerohellmann's full-sized avatar
💭
Exploring Kotlin

Cicero Hellmann Jacobi cicerohellmann

💭
Exploring Kotlin
View GitHub Profile
@cicerohellmann
cicerohellmann / index.css
Created September 19, 2021 11:38
Three.js - Load .GLTF
html, body {
margin: 0;
height: 100%;
}
#c {
width: 100%;
height: 100%;
display: block;
}
@cicerohellmann
cicerohellmann / SelectableItem.kt
Created May 11, 2021 10:58
A simple selectable
@Composable
fun SelectableItem(
modifier: Modifier = Modifier,
text: String,
selected: Boolean = false,
onClick: (() -> Unit)? = null,
) {
Button(
onClick = { onClick?.invoke() },
modifier = modifier
@cicerohellmann
cicerohellmann / DumbNavigation.kt
Created May 4, 2021 14:39
A simple compose navigation implementation
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.navigation.NavHostController
import androidx.navigation.NavType
@cicerohellmann
cicerohellmann / SerializeTest.kt
Created April 30, 2021 16:09
A serialization test between our serialization libraries
@Serializable
data class User(
val name: String,
val email: String,
val age: Int = 13,
val isAlive: Boolean = false,
val role: Role = Role.Viewer,
val bodyType: BodyType = BodyType(Body.NotSkinny),
)
@Serializable
@cicerohellmann
cicerohellmann / Values.kt
Created April 29, 2021 12:22
Several value grous and a way to implement them
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
class Dimens {
companion object {
val buttonHeight = 16.dp
}
}
class Padding {
@cicerohellmann
cicerohellmann / Button.kt
Created April 29, 2021 12:19
Custom button that has two presentation modes within
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
@cicerohellmann
cicerohellmann / FontFamily.kt
Created April 29, 2021 12:14
Adding an external font to your project
//https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml
class FontFamily {
companion object {
val robotoFamily = FontFamily(
Font(R.font.roboto_bold, FontWeight.Bold),
Font(R.font.roboto_medium, FontWeight.Medium)
)
}
}
@cicerohellmann
cicerohellmann / Text.kt
Last active April 29, 2021 12:14
Composable Custom Text with two variants
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import com.your.project.resources.FontFamily
@Composable
fun Text(
@cicerohellmann
cicerohellmann / TimeToInt.swift
Last active April 29, 2021 14:56
time conversion
let amPmFormat = "h:mm a"
let twentyFourHFormat = "HH:mm"
func hourMinuteParser(date: Date) -> KotlinInt{
let formatter = DateFormatter()
if DateFormatter.dateFormat(fromTemplate: "j",options:0, locale: Locale.current)!.contains("a") {
formatter.dateFormat = amPmFormat
}else{
formatter.dateFormat = twentyFourHFormat
}
let stringTime = formatter.string(from: date)
.gradle
/local.properties
/.idea/workspace.xml
.DS_Store
/build