Skip to content

Commit

Permalink
refactor: 💡 Refactor from Ignite Flame
Browse files Browse the repository at this point in the history
  • Loading branch information
nonameolsson committed Apr 25, 2021
1 parent 8999229 commit 052187c
Show file tree
Hide file tree
Showing 148 changed files with 2,815 additions and 30,480 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

108 changes: 0 additions & 108 deletions .eslintrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,3 @@ web-build/
# Configurations
app/config/env.*.js
!env.js

# Misc
.todo
19 changes: 0 additions & 19 deletions .prettierrc

This file was deleted.

9 changes: 4 additions & 5 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
// side effect of breaking other tooling like mobile-center and react-native-rename.
//
// It's easier just to leave it here.
import { AppRegistry } from 'react-native'
import App from "./app/app.tsx";
import { AppRegistry } from "react-native";

import App from './app/app.tsx'

AppRegistry.registerComponent('YourTimeline', () => App)
export default App
AppRegistry.registerComponent("KalleKula", () => App);
export default App;
13 changes: 3 additions & 10 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"expo": {
"name": "YourTimeline",
"slug": "your-timeline",
"slug": "yourtimeline",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
Expand All @@ -15,17 +15,10 @@
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "app.yourtimeline.timeline",
"buildNumber": "1.0.0"
},
"android": {
"package": "app.yourtimeline.timeline",
"versionCode": 1
"supportsTablet": true
},
"web": {
"favicon": "./assets/favicon.png"
},
"sdkVersion": "41.0.0"
}
}
}
80 changes: 46 additions & 34 deletions app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,52 @@
* if you're interested in adding screens and navigators.
*/

import React, { useEffect, useRef, useState } from 'react'
import React, { useEffect, useRef, useState } from "react";
import {
DarkTheme as PaperDarkTheme,
DefaultTheme as PaperDefaultTheme,
Provider as PaperProvider,
} from 'react-native-paper'
import { initialWindowMetrics, SafeAreaProvider } from 'react-native-safe-area-context'
import { enableScreens } from 'react-native-screens'
import { OverflowMenuProvider } from 'react-navigation-header-buttons'
} from "react-native-paper";
import {
initialWindowMetrics,
SafeAreaProvider,
} from "react-native-safe-area-context";
import { enableScreens } from "react-native-screens";
import { OverflowMenuProvider } from "react-navigation-header-buttons";
import {
DarkTheme as NavigationDarkTheme,
DefaultTheme as NavigationDefaultTheme,
NavigationContainerRef,
} from '@react-navigation/native'
} from "@react-navigation/native";

import './i18n'
import './utils/ignore-warnings'
import "./i18n";
import "./utils/ignore-warnings";

import { ToggleStorybook } from '../storybook/toggle-storybook'
import { ToggleStorybook } from "../storybook/toggle-storybook";

import { initFonts } from './theme/fonts' // expo
import * as storage from './utils/storage'
import { RootStore, RootStoreProvider, setupRootStore } from './models'
import { canExit, RootNavigator, setRootNavigation, useBackButtonHandler, useNavigationPersistence } from './navigators'
import { initFonts } from "./theme/fonts"; // expo
import * as storage from "./utils/storage";
import { RootStore, RootStoreProvider, setupRootStore } from "./models";
import {
canExit,
RootNavigator,
setRootNavigation,
useBackButtonHandler,
useNavigationPersistence,
} from "./navigators";

// This puts screens in a native ViewController or Activity. If you want fully native
// stack navigation, use `createNativeStackNavigator` in place of `createStackNavigator`:
// https://github.com/kmagiera/react-native-screens#using-native-stack-navigator
enableScreens()
enableScreens();

export const NAVIGATION_PERSISTENCE_KEY = 'NAVIGATION_STATE'
export const NAVIGATION_PERSISTENCE_KEY = "NAVIGATION_STATE";

const CombinedDarkTheme = {
...PaperDarkTheme,
...NavigationDarkTheme,
colors: { ...PaperDarkTheme.colors, ...NavigationDarkTheme.colors },
}
};

const CombinedDefaultTheme = {
...PaperDefaultTheme,
Expand All @@ -55,38 +64,41 @@ const CombinedDefaultTheme = {
...PaperDefaultTheme.colors,
...NavigationDefaultTheme.colors,
},
}
};

/**
* This is the root component of our app.
*/
function App() {
const navigationRef = useRef<NavigationContainerRef>()
const [rootStore, setRootStore] = useState<RootStore | undefined>(undefined)
const navigationRef = useRef<NavigationContainerRef>();
const [rootStore, setRootStore] = useState<RootStore | undefined>(undefined);

setRootNavigation(navigationRef)
useBackButtonHandler(navigationRef, canExit)
const { initialNavigationState, onNavigationStateChange } = useNavigationPersistence(
storage,
NAVIGATION_PERSISTENCE_KEY,
)
setRootNavigation(navigationRef);
useBackButtonHandler(navigationRef, canExit);
const {
initialNavigationState,
onNavigationStateChange,
} = useNavigationPersistence(storage, NAVIGATION_PERSISTENCE_KEY);

// Kick off initial async loading actions, like loading fonts and RootStore
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-extra-semi
;(async () => {
await initFonts() // expo
setupRootStore().then(setRootStore)
})()
}, [])
(async () => {
await initFonts(); // expo
setupRootStore().then(setRootStore);
})();
}, []);

// Before we show the app, we have to wait for our state to be ready.
// In the meantime, don't render anything. This will be the background
// color set in native by rootView's background color. You can replace
// with your own loading component if you wish.
if (!rootStore) return null
if (!rootStore) return null;

const theme = rootStore.uiStore.theme === 'light' ? CombinedDefaultTheme : CombinedDarkTheme
const theme =
rootStore.uiStore.theme === "light"
? CombinedDefaultTheme
: CombinedDarkTheme;

// otherwise, we're ready to render the app
return (
Expand All @@ -106,7 +118,7 @@ function App() {
</RootStoreProvider>
</PaperProvider>
</ToggleStorybook>
)
);
}

export default App
export default App;
18 changes: 9 additions & 9 deletions app/components/addTimelineForm/addTimelineForm.story.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as React from 'react'
import { storiesOf } from '@storybook/react-native'
import * as React from "react";
import { storiesOf } from "@storybook/react-native";

import { Story, StoryScreen, UseCase } from '../../../storybook/views'
import { Story, StoryScreen, UseCase } from "../../../storybook/views";

import { AddTimelineForm } from './addTimelineForm'
import { AddTimelineForm } from "./addTimelineForm";

declare const module
declare const module;

storiesOf('AddTimelineForm', module)
.addDecorator(fn => <StoryScreen>{fn()}</StoryScreen>)
.add('Style Presets', () => (
storiesOf("AddTimelineForm", module)
.addDecorator((fn) => <StoryScreen>{fn()}</StoryScreen>)
.add("Style Presets", () => (
<Story>
<UseCase text="Primary" usage="The primary.">
<AddTimelineForm text="AddTimelineForm" />
</UseCase>
</Story>
))
));
Loading

0 comments on commit 052187c

Please sign in to comment.