This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.ui.graphics.Color | |
val purple200 = Color(0xFFBB86FC) | |
val purple500 = Color(0xFF6200EE) | |
val purple700 = Color(0xFF3700B3) | |
val teal200 = Color(0xFF03DAC5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val DarkColorPalette = darkColors( | |
primary = purple200, | |
primaryVariant = purple700, | |
secondary = teal200 | |
) | |
private val LightColorPalette = lightColors( | |
primary = purple500, | |
primaryVariant = purple700, | |
secondary = teal200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HStack(alignment: .center, spacing: nil) { | |
VStack(alignment: .leading, spacing: nil) { | |
Text(title) | |
.font(.title) | |
Text(subtitle) | |
.font(.subheadline) | |
} | |
Spacer() | |
Image(imageUrl) | |
.resizable() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ListViewItem: View { | |
var title : String | |
var subtitle : String | |
var imageUrl : String | |
var body: some View { | |
VStack(alignment: .leading, spacing: nil) { | |
Text(title) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Stream<Transition<SearchEvent, SearchState>> transformEvents( | |
Stream<SearchEvent> events, | |
TransitionFunction<SearchEvent, SearchState> transitionFn, | |
) { | |
return events | |
.debounceTime(const Duration(milliseconds: 350)) | |
.switchMap(transitionFn); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun signin() { | |
lifecycleScope.launch(errorHandler { signup() }) { | |
val result = oneTapClient.suspendBeginSignInRequest(buildSignInRequest()) | |
loginResult.launch( | |
IntentSenderRequest.Builder(result.pendingIntent) | |
.build() | |
) | |
} | |
} |