-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b629e2
commit 83dbe27
Showing
14 changed files
with
217 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from "react" | ||
import { storiesOf } from "@storybook/react-native" | ||
import { StoryScreen, Story, UseCase } from "../../../storybook/views" | ||
import { ErrorSection } from "./error-section" | ||
|
||
declare var module | ||
|
||
storiesOf("ErrorSection", module) | ||
.addDecorator(fn => <StoryScreen>{fn()}</StoryScreen>) | ||
.add("Style Presets", () => ( | ||
<Story> | ||
<UseCase text="Primary" usage="The primary."> | ||
<ErrorSection text="ErrorSection" /> | ||
</UseCase> | ||
</Story> | ||
)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ViewStyle } from "react-native" | ||
|
||
export const errorSectionStyles = { | ||
WRAPPER: { | ||
justifyContent: 'center' | ||
} as ViewStyle | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { FunctionComponent as Component, useEffect } from "react" | ||
import { View } from "react-native" | ||
import { Text } from "../" | ||
// import { observer } from "mobx-react-lite" | ||
import { useStores } from "../../models" | ||
import { errorSectionStyles as styles } from "./error-section.styles" | ||
import { observer } from "mobx-react-lite" | ||
|
||
export interface ErrorSectionProps {} | ||
|
||
/** | ||
* This is a React functional component, ready to | ||
* | ||
* Component description here for TypeScript tips. | ||
*/ | ||
export const ErrorSection: Component<ErrorSectionProps> = observer(props => { | ||
const { dialogStore } = useStores() | ||
|
||
useEffect(() => { | ||
if (dialogStore.dialog) { | ||
setTimeout(() => { | ||
dialogStore.setDialog(undefined) | ||
}, 2000) | ||
} | ||
}, [dialogStore.dialog]) | ||
|
||
return ( | ||
<View style={styles.WRAPPER}> | ||
{dialogStore.dialog && ( | ||
<Text>{dialogStore.dialog}</Text> | ||
)} | ||
</View> | ||
) | ||
}) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { DialogStoreModel, DialogStore } from "./dialog-store" | ||
|
||
test("can be created", () => { | ||
const instance: DialogStore = DialogStoreModel.create({}) | ||
|
||
expect(instance).toBeTruthy() | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Instance, SnapshotOut, types, flow } from "mobx-state-tree" | ||
import { withEnvironment } from "../extensions/with-environment" | ||
|
||
/** | ||
* Model description here for TypeScript hints. | ||
*/ | ||
export const DialogStoreModel = types | ||
.model("DialogStore") | ||
.props({ | ||
dialog: types.maybe(types.string), | ||
}) | ||
.extend(withEnvironment) | ||
.views(self => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars | ||
.actions(self => ({ | ||
setDialog: flow(function * (dialog) { | ||
self.dialog = dialog | ||
}), | ||
})) | ||
.actions(self => ({ | ||
initializeStore: flow(function * () { | ||
self.environment.setDialog = dialog => self.setDialog(dialog) | ||
}), | ||
})) | ||
|
||
/** | ||
* Un-comment the following to omit model attributes from your snapshots (and from async storage). | ||
* Useful for sensitive data like passwords, or transitive state like whether a modal is open. | ||
* Note that you'll need to import `omit` from ramda, which is already included in the project! | ||
* .postProcessSnapshot(omit(["password", "socialSecurityNumber", "creditCardNumber"])) | ||
*/ | ||
|
||
type DialogStoreType = Instance<typeof DialogStoreModel> | ||
export interface DialogStore extends DialogStoreType {} | ||
type DialogStoreSnapshotType = SnapshotOut<typeof DialogStoreModel> | ||
export interface DialogStoreSnapshot extends DialogStoreSnapshotType {} |
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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