Skip to content

Instantly share code, notes, and snippets.

View dllewellyn's full-sized avatar

Dan dllewellyn

View GitHub Profile
import androidx.compose.ui.graphics.Color
val purple200 = Color(0xFFBB86FC)
val purple500 = Color(0xFF6200EE)
val purple700 = Color(0xFF3700B3)
val teal200 = Color(0xFF03DAC5)
private val DarkColorPalette = darkColors(
primary = purple200,
primaryVariant = purple700,
secondary = teal200
)
private val LightColorPalette = lightColors(
primary = purple500,
primaryVariant = purple700,
secondary = teal200
HStack(alignment: .center, spacing: nil) {
VStack(alignment: .leading, spacing: nil) {
Text(title)
.font(.title)
Text(subtitle)
.font(.subheadline)
}
Spacer()
Image(imageUrl)
.resizable()
@dllewellyn
dllewellyn / ListViewItem.swift
Created January 9, 2021 09:47
ListViewItem.swift
struct ListViewItem: View {
var title : String
var subtitle : String
var imageUrl : String
var body: some View {
VStack(alignment: .leading, spacing: nil) {
Text(title)
@override
Stream<Transition<SearchEvent, SearchState>> transformEvents(
Stream<SearchEvent> events,
TransitionFunction<SearchEvent, SearchState> transitionFn,
) {
return events
.debounceTime(const Duration(milliseconds: 350))
.switchMap(transitionFn);
}
import 'package:bloc/bloc.dart';
class FluttersaurusBlocObserver extends BlocObserver {
@override
void onEvent(Bloc bloc, Object event) {
print('${bloc.runtimeType} $event');
super.onEvent(bloc, event);
}
@override
@dllewellyn
dllewellyn / bloc.dart
Created August 14, 2020 07:52
Bloc_sample
enum CounterEvent { increment }
class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0);
@override
Stream<int> mapEventToState(CounterEvent event) async* {
switch (event) {
case CounterEvent.increment:
yield state + 1;
private val oneTapClient: SignInClient by lazy {
Identity.getSignInClient(this)
}
private val loginResult =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) {
val credential = oneTapClient.getSignInCredentialFromIntent(it.data)
val idToken = credential.googleIdToken
val username = credential.id
val password = credential.password
private val loginResult =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) {
val credential = oneTapClient.getSignInCredentialFromIntent(it.data)
val idToken = credential.googleIdToken
val username = credential.id
val password = credential.password
when {
idToken != null -> {
// Got an ID token from Google. Use it to authenticate
// with your backend.
private fun signin() {
lifecycleScope.launch(errorHandler { signup() }) {
val result = oneTapClient.suspendBeginSignInRequest(buildSignInRequest())
loginResult.launch(
IntentSenderRequest.Builder(result.pendingIntent)
.build()
)
}
}