View Validator.kt
This file contains 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
sealed interface Validator { | |
fun validate(value: String): Int? | |
} | |
object RequiredValidator : Validator { | |
override fun validate(value: String): Int? = | |
if (value.isNotBlank()) null else ValidationError.Required | |
} | |
object EmailValidator : Validator { |
View Example.kt
This file contains 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
data class CounterUiState(val counter: Int = 0) : State | |
sealed class CounterAction : Action { | |
object Increment : CounterAction() | |
object Decrement : CounterAction() | |
data class SetValue(val value: Int) : CounterAction() | |
} | |
class CounterViewModel : ViewModel() { | |
View DatePicker.kt
This file contains 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
@Composable | |
fun DatePicker( | |
label: String, | |
value: String, | |
onValueChange: (String) -> Unit = {}, | |
keyboardActions: KeyboardActions = KeyboardActions.Default, | |
keyboardOptions: KeyboardOptions = KeyboardOptions.Default, | |
pattern: String = "yyyy-MM-dd", | |
) { | |
val formatter = DateTimeFormatter.ofPattern(pattern) |
View settings.json
This file contains 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
{ | |
"[rust]": { | |
"editor.formatOnSave": true | |
}, | |
"[typescript]": { | |
"editor.formatOnSave": true | |
}, | |
"[typescriptreact]": { | |
"editor.formatOnSave": true | |
}, |
View GuessANumber.kt
This file contains 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 kotlin.random.Random | |
fun main() { | |
val secretNumber = Random.nextInt(1, 100) | |
var numTries = 0 | |
var numTriesLeft: Int | |
var gameWon = false | |
println("Welcome to Guess a number!") |
View LoginScreen.kt
This file contains 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
@ExperimentalComposeUiApi | |
@Composable | |
fun LoginScreen( | |
viewModel: LoginViewModel, | |
navigateToOverview: () -> Unit = {}, | |
onBack: () -> Unit = {}, | |
) { | |
val uiState by viewModel.uiState.collectAsState() | |
val (username, setUsername) = viewModel.username |
View graphql.ts
This file contains 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
// See: https://github.com/vercel/next.js/blob/canary/examples/api-routes-apollo-server/pages/api/graphql.js | |
import {AsyncExecutor} from '@graphql-tools/delegate'; | |
import {introspectSchema, wrapSchema} from '@graphql-tools/wrap'; | |
import {ApolloServer} from 'apollo-server-micro'; | |
import {print} from 'graphql'; | |
import fetch from 'isomorphic-unfetch'; | |
import {NextApiRequest, NextApiResponse} from 'next'; | |
import getConfig from 'next/config'; |
View graphql.ts
This file contains 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 {ApolloServer} from 'apollo-server-micro'; | |
import {NextApiRequest, NextApiResponse} from 'next'; | |
import {resolvers} from '@/graphql/resolvers'; | |
import typeDefs from '@/graphql/schema.graphql'; | |
const handler = async (req: NextApiRequest, res: NextApiResponse) => { | |
return new ApolloServer( | |
resolvers, |
View ci.yml
This file contains 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
name: CI | |
on: [push] | |
jobs: | |
schema: | |
name: Schema | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Inspect Schema |
NewerOlder