Skip to content

Instantly share code, notes, and snippets.

View robinheinze's full-sized avatar

Robin Heinze robinheinze

View GitHub Profile
/Users/robinheinze/.npm/_npx/e31027f3785124a8/node_modules/gluegun/build/index.js:13
throw up;
^
npm WARN exec The following package was not found and will be installed: react-native-rename
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
mv: no such file or directory: /Users/robinheinze/Code/ir/MyApp/ios/MyApp
mv: no such file or directory: /Users/robinheinze/Code/ir/MyApp/ios/MyApp-tvOS
mv: no such file or directory: /Users/robinheinze/Code/ir/MyApp/ios/MyApp-tvOSTests
mv: no such file or directory: /Users/robinheinze/Code/ir/MyApp/ios/MyApp.xcodeproj
mv: no such file or directory: /Users/robinheinze/Code/ir/MyApp/ios/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp-tvOS.xcscheme
@robinheinze
robinheinze / question.ts
Created April 8, 2021 16:56
Show allAnswers view
...
export const QuestionModel = types
...
.views((self) => ({
get allAnswers() {
return shuffle(self.incorrectAnswers.concat([self.correctAnswer]))
}
)}
...
import { Instance, SnapshotOut, types } from "mobx-state-tree"
import { QuestionStore, QuestionStoreModel } from "../question-store/question-store"
/**
* A RootStore model.
*/
// prettier-ignore
export const RootStoreModel = types.model("RootStore").props({
questionStore: types.optional(QuestionStoreModel, {} as QuestionStore)
})
@robinheinze
robinheinze / question.ts
Created July 25, 2019 20:17
Radio props
get radioProps() {
const allAnswers = self.incorrectAnswers.concat([self.correctAnswer])
const radioProps = allAnswers.map(answer => ({ label: answer, value: answer }))
return shuffle(radioProps)
},
@robinheinze
robinheinze / question-screen.tsx
Last active April 8, 2021 17:26
Question Screen with radio buttons
const CHECK_ANSWER: ViewStyle = {
paddingVertical: spacing.smaller,
backgroundColor: color.palette.angry,
marginTop: spacing.smaller,
}
export const QuestionScreen = observer(function QuestionScreen() {
...
const onPressAnswer = (question: Question, guess: string) => {
question.setGuess(guess)
@robinheinze
robinheinze / question.ts
Last active April 7, 2021 21:09
Question with guess helpers
export const QuestionModel = types
.model("Question")
.props({
id: types.identifier,
category: types.maybe(types.string),
type: types.enumeration(["multiple", "boolean"]),
difficulty: types.enumeration(["easy", "medium", "hard"]),
question: types.maybe(types.string),
correctAnswer: types.maybe(types.string),
incorrectAnswers: types.optional(types.array(types.string), []),
@robinheinze
robinheinze / question-screen.tsx
Last active April 8, 2021 17:33
Question Screen with List
import React, { useEffect, useState } from "react"
import { observer } from "mobx-react-lite"
import { FlatList, TextStyle, View, ViewStyle } from "react-native"
import { Screen, Text } from "../../components"
import { color, spacing } from "../../theme"
import { useStores } from "../../models"
import { Question } from "../../models/question/question"
import { decodeHTMLEntities } from "../../utils/html-decode"
const ROOT: ViewStyle = {
@robinheinze
robinheinze / question-screen.tsx
Last active April 8, 2021 16:45
IgniteTrivia Question Screen injected store
import { useStores } from "../../models"
...
export const QuestionScreen = observer(function QuestionScreen() {
// Pull in one of our MST stores
const { questionStore } = useStores()
...
@robinheinze
robinheinze / question-screen.tsx
Last active April 8, 2021 17:25
IgniteTrivia Question Screen initial
import React from "react"
import { observer } from "mobx-react-lite"
import { View, ViewStyle } from "react-native"
import { Screen, Text } from "../../components"
// import { useNavigation } from "@react-navigation/native"
// import { useStores } from "../../models"
import { color, spacing } from "../../theme"
const ROOT: ViewStyle = {
flex: 1,
@robinheinze
robinheinze / main-navigator.ts
Last active April 9, 2021 18:07
IgniteTrivia primary navigator
import { createStackNavigator } from "@react-navigation/stack"
import { QuestionScreen } from "../screens"
/**
* This type allows TypeScript to know what routes are defined in this navigator
* as well as what properties (if any) they might take when navigating to them.
*
* If no params are allowed, pass through `undefined`. Generally speaking, we
* recommend using your MobX-State-Tree store(s) to keep application state
* rather than passing state through navigation params.