Skip to content

Instantly share code, notes, and snippets.

View gabrielbmoro's full-sized avatar
👋
Hii

Gabriel Bronzatti Moro gabrielbmoro

👋
Hii
View GitHub Profile
@gabrielbmoro
gabrielbmoro / ScreenRoutes.kt
Last active January 22, 2022 22:42
Exemple - Route sending Quiz object - Navigation Compose
fun quizRoute(quiz: Quiz): String{
val json = Uri.encode(Gson().toJson(quiz))
return "$QUIZ_ROUTE/$json"
}
@gabrielbmoro
gabrielbmoro / NavQuizType.kt
Last active January 22, 2022 22:40
NavQuizType - Argument - Navigation Compose
class NavQuizType: NavType<Quiz>(false) {
override fun get(bundle: Bundle, key: String): Quiz {
return bundle.getParcelable(key)!!
}
override fun parseValue(value: String): Quiz {
return Gson().fromJson(value, Quiz::class.java)
}
override fun put(bundle: Bundle, key: String, value: Quiz) {
@gabrielbmoro
gabrielbmoro / clickEvent.kt
Created January 21, 2022 13:53
Calling Navigation Controller - Compose Navigation
clickEvent = { quiz ->
val route = ScreenRoutes.quizRoute(quiz)
navController.navigate(route)
}
@gabrielbmoro
gabrielbmoro / MainNavGraph.kt
Created January 21, 2022 14:03
Navigation graph - Navigation Compose
composable(
"${ScreenRoutes.QUIZ_ROUTE}/{${ScreenRoutes.QUIZ_ARGUMENT_KEY}}",
arguments = listOf(
navArgument(ScreenRoutes.QUIZ_ARGUMENT_KEY) {
type = NavQuizType()
}
)
) {
val quiz = it.arguments?.getParcelable<Quiz>(ScreenRoutes.QUIZ_ARGUMENT_KEY)
?: throw IllegalStateException("It is not possible access the quiz object")
@gabrielbmoro
gabrielbmoro / build.gradle
Last active May 29, 2022 20:01
Getting version name, and version code from env variables
private static String getVersionName() {
String versionName = "$System.env.ANDROID_VERSION_NAME"
if (versionName == null || versionName.isEmpty()) {
int versionCode = getVersionCode()
return "1.0.$versionCode"
} else {
return versionName
}
}
@gabrielbmoro
gabrielbmoro / build.gradle
Created May 29, 2022 20:25
Get Keystore properties from local environment or Bitrise
private static Properties loadProperties(Project rootProject) {
def keystoreProperties = new Properties()
// load your keystore.properties file into e keystoreProperties object.
try {
def keystorePropertiesFile = rootProject.file("keystore.properties")
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
} catch(FileNotFoundException exception){
println(exception.message)
println("-------")
@gabrielbmoro
gabrielbmoro / build.gradle
Created May 29, 2022 20:27
Exposing Gradle properties
android {
compileSdk 31
defaultConfig {
applicationId "com.matematicasimples"
minSdk 23
targetSdk 30
versionCode getVersionCode()
versionName getVersionName()
@gabrielbmoro
gabrielbmoro / Composable.kt
Created July 12, 2022 22:13
Typing a Text
ComposableFunction() {
DisposableEffect(Unit) {
typingTimer = TypingTimer().apply {
setup(
baseMessage = welcomingMessage,
finishCallback = { showFooter = true },
currentMessageUpdateCallback = {
// here if you are using viewbinding it could be textView.text = currentMessage
currentMessage = it
}
@gabrielbmoro
gabrielbmoro / app.ts
Created September 6, 2022 20:51
An API Project - Gists Part 1
import express, { Request, Response, NextFunction } from "express";
require('express-async-errors');
import { historyRoutes } from "./routes/history.routes";
const app = express();
app.use(express.json());
app.use("/history", historyRoutes);
@gabrielbmoro
gabrielbmoro / historic.routes.ts
Created September 6, 2022 20:53
An API Project - Gists Part 2
import { Router } from "express";
import { CreateNewHistoricEntryController } from "../../controllers/CreateNewHistoricEntryController";
const historyRoutes = Router();
const createNewHistoricEntryController = new CreateNewHistoricEntryController();
historyRoutes.post("/historic", createNewHistoricEntryController.handle);
export { historyRoutes };