Skip to content

Instantly share code, notes, and snippets.

View sebaslogen's full-sized avatar

Sebas LG sebaslogen

View GitHub Profile
@sebaslogen
sebaslogen / main.dart
Created January 10, 2020 20:33
Flutter colored slider experiment
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@sebaslogen
sebaslogen / main.dart
Created January 12, 2020 22:00
Flutter Neumorphism
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@RunWith(AndroidJUnit4::class) // Update: back in 2022, this used to be @RunWith(RobolectricTestRunner::class)
class MyTests {
@get:Rule val composeTestRule = createComposeRule()
@Test fun `when I test, then it works`() {
// Some test code here
}
}
@Before
@Throws(Exception::class)
fun setUp() {
ShadowLog.stream = System.out // Redirect Logcat to console
}
Button(
modifier = Modifier.testTag("First Button"),
onClick = clickListener) {
Text("Push first destination")
}
android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
testImplementation 'junit:junit:4.+'
@sebaslogen
sebaslogen / ActivityLifecycleComposable.kt
Last active September 27, 2024 08:51
Update Activity reference (from Compose) on configuration changes (Activity recreation)
import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.core.app.ComponentActivity