This repository has been archived by the owner on Sep 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ronna Firmo
committed
Apr 27, 2021
1 parent
f32f85f
commit 6426085
Showing
16 changed files
with
384 additions
and
5 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
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,41 @@ | ||
import { API } from './api/KkAPIClient'; | ||
import { LocalStorageService } from './services/KkLocalStorageService'; | ||
|
||
type KkEnvironment = { | ||
/** The current API */ | ||
api: API; | ||
/** A proxy for handling navigation */ | ||
navigation: { | ||
/** Navigates to the provided `route`, using the given `params` */ | ||
navigate: (route: string, params?: { [key: string]: any }) => void; | ||
}; | ||
/** Currently available services */ | ||
services: { | ||
/** A service for interacting with async storage */ | ||
localStorage: LocalStorageService; | ||
}; | ||
}; | ||
|
||
/** This value holds the actual environment object. */ | ||
let _currentEnvironment: KkEnvironment | undefined = undefined; | ||
|
||
/** Exposes the current `StraveEnvironment` via `current()`. */ | ||
const Environment = { | ||
/** Returns the current environment. */ | ||
current(): KkEnvironment { | ||
return { ..._currentEnvironment! }; | ||
}, | ||
|
||
/** | ||
* Sets the current environment. Call as early as possible during startup, and | ||
* ONLY call once. | ||
*/ | ||
set(environment: KkEnvironment) { | ||
if (_currentEnvironment === undefined) { | ||
_currentEnvironment = environment; | ||
} | ||
}, | ||
}; | ||
|
||
Object.freeze(Environment); | ||
export { Environment }; |
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 { Workplace } from './models/Workplace'; | ||
|
||
export type API = { | ||
getWorkspaces: () => Promise<Workplace>; | ||
}; | ||
|
||
export const kkAPIClient = (options: { baseUrl: string }): API => { | ||
const getUrl = (url: string) => `${options.baseUrl}/${url}`; | ||
return { | ||
getWorkspaces: async () => { | ||
const response = await fetch(getUrl('/workspaces')); | ||
const result = await response.json(); | ||
return result; | ||
}, | ||
}; | ||
}; |
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,4 @@ | ||
export type Workplace = { | ||
id: string; | ||
name: string; | ||
}; |
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,11 @@ | ||
import React from 'react'; | ||
import { View } from './Themed'; | ||
|
||
type Props = { | ||
height?: number; | ||
width?: number; | ||
}; | ||
|
||
export const KkSizedBox = (props: Props) => { | ||
return <View style={{ height: props.height, width: props.width }} />; | ||
}; |
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,90 @@ | ||
import { StyleSheet, TextStyle, ViewStyle } from 'react-native'; | ||
|
||
type FontOptions = { | ||
bold?: boolean; | ||
size?: number; | ||
}; | ||
|
||
type Fonts = { | ||
h1: (options?: FontOptions) => TextStyle; | ||
h2: (options?: FontOptions) => TextStyle; | ||
h3: (options?: FontOptions) => TextStyle; | ||
h4: (options?: FontOptions) => TextStyle; | ||
h5: (options?: FontOptions) => TextStyle; | ||
h6: (options?: FontOptions) => TextStyle; | ||
subtitle1: (options?: FontOptions) => TextStyle; | ||
subtitle2: (options?: FontOptions) => TextStyle; | ||
body1: (options?: FontOptions) => TextStyle; | ||
body2: (options?: FontOptions) => TextStyle; | ||
button: (options?: FontOptions) => TextStyle; | ||
caption: (options?: FontOptions) => TextStyle; | ||
overline: (options?: FontOptions) => TextStyle; | ||
}; | ||
|
||
// If you want to see it visually: | ||
// https://material.io/design/typography/the-type-system.html#type-scale | ||
export const fonts: Fonts = { | ||
h1: (options) => ({ | ||
fontWeight: options?.bold ? 'bold' : '300', | ||
fontSize: 96, | ||
letterSpacing: -1.5, | ||
}), | ||
h2: (options) => ({ | ||
fontSize: 60, | ||
fontWeight: options?.bold ? 'bold' : '300', | ||
letterSpacing: -0.5, | ||
}), | ||
h3: (options) => ({ | ||
fontSize: 48, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
}), | ||
h4: (options) => ({ | ||
fontSize: 34, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
letterSpacing: 0.25, | ||
}), | ||
h5: (options) => ({ | ||
fontSize: 24, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
}), | ||
h6: (options) => ({ | ||
fontSize: 20, | ||
fontWeight: options?.bold ? 'bold' : '500', | ||
letterSpacing: 0.15, | ||
}), | ||
subtitle1: (options) => ({ | ||
fontSize: 16, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
letterSpacing: 0.15, | ||
}), | ||
subtitle2: (options) => ({ | ||
fontSize: 14, | ||
fontWeight: options?.bold ? 'bold' : '500', | ||
letterSpacing: 0.1, | ||
}), | ||
body1: (options) => ({ | ||
fontSize: 16, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
letterSpacing: 0.5, | ||
}), | ||
body2: (options) => ({ | ||
fontSize: 14, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
letterSpacing: 0.25, | ||
}), | ||
button: (options) => ({ | ||
fontSize: 14, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
letterSpacing: 1.25, | ||
}), | ||
caption: (options) => ({ | ||
fontSize: 12, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
letterSpacing: 0.4, | ||
}), | ||
overline: (options) => ({ | ||
fontSize: 10, | ||
fontWeight: options?.bold ? 'bold' : '400', | ||
letterSpacing: 1.5, | ||
}), | ||
}; |
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 React, { useState } from 'react'; | ||
import { kkAPIClient } from '../api/KkAPIClient'; | ||
import { Environment } from '../KkEnvironment'; | ||
import { routes } from '../navigation/KkNavigation'; | ||
import { KkLandingScreen } from '../screens/KkLandingScreen'; | ||
import { localStorageKey } from '../services/KkLocalStorageService'; | ||
|
||
export type KkLandingProps = { | ||
formState: FormState; | ||
userUpdatedForm: React.Dispatch<React.SetStateAction<FormState>>; | ||
userSubmittedForm: () => void; | ||
}; | ||
|
||
type FormState = { | ||
apiKey: string; | ||
}; | ||
|
||
export const KkLandingContainer = (props: KkLandingProps) => { | ||
const [formState, setFormState] = useState<FormState>({ apiKey: '' }); | ||
|
||
const { services, navigation } = Environment.current(); | ||
|
||
return ( | ||
<KkLandingScreen | ||
formState={formState} | ||
userUpdatedForm={setFormState} | ||
userSubmittedForm={async () => { | ||
await services.localStorage.storeItem( | ||
localStorageKey.API_KEY, | ||
formState.apiKey | ||
); | ||
navigation.navigate(routes.WORKSPACE); | ||
}} | ||
/> | ||
); | ||
}; |
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,8 @@ | ||
import React from 'react'; | ||
import { KkWorspaceScreen } from '../screens/KkWorspaceScreen'; | ||
|
||
export type KkWorkspaceProps = {}; | ||
|
||
export const KkWorkspaceContainer = (props: KkWorkspaceProps) => { | ||
return <KkWorspaceScreen />; | ||
}; |
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,50 @@ | ||
import { | ||
DarkTheme, | ||
DefaultTheme, | ||
NavigationContainer, | ||
NavigationContainerRef, | ||
} from '@react-navigation/native'; | ||
import { createStackNavigator } from '@react-navigation/stack'; | ||
import React from 'react'; | ||
import { ColorSchemeName } from 'react-native'; | ||
import { KkLandingContainer } from '../containers/KkLandingContainer'; | ||
import { KkWorkspaceContainer } from '../containers/KkWorkspaceContainer'; | ||
|
||
export const routes = { | ||
LANDING: 'Landing', | ||
WORKSPACE: 'Workspace', | ||
}; | ||
|
||
export const createKkNavigation = (): { | ||
Navigator: React.ComponentType<{ colorScheme: ColorSchemeName }>; | ||
navigate: (route: string, params?: { [key: string]: any }) => void; | ||
} => { | ||
let navigatorRef: NavigationContainerRef | null = null; | ||
return { | ||
navigate: (route, params) => { | ||
navigatorRef?.navigate(route, params); | ||
}, | ||
Navigator: (props) => ( | ||
<NavigationContainer | ||
ref={(ref) => (navigatorRef = ref)} | ||
theme={props.colorScheme === 'dark' ? DarkTheme : DefaultTheme}> | ||
<KkRootNavigator /> | ||
</NavigationContainer> | ||
), | ||
}; | ||
}; | ||
|
||
// A root stack navigator is often used for displaying modals on top of all other content | ||
// Read more here: https://reactnavigation.org/docs/modal | ||
const RootStack = createStackNavigator(); | ||
const KkRootNavigator = () => { | ||
return ( | ||
<RootStack.Navigator screenOptions={{ headerShown: false }}> | ||
<RootStack.Screen name={routes.LANDING} component={KkLandingContainer} /> | ||
<RootStack.Screen | ||
name={routes.WORKSPACE} | ||
component={KkWorkspaceContainer} | ||
/> | ||
</RootStack.Navigator> | ||
); | ||
}; |
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,3 @@ | ||
# klakie docu | ||
|
||
> Anything that doesn't begin with `Kk` is part of the generated expo template |
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,45 @@ | ||
import React from 'react'; | ||
import { Button, StyleSheet, TextInput } from 'react-native'; | ||
import { KkSizedBox } from '../components/KkSizedBox'; | ||
import { fonts } from '../components/KkStyles'; | ||
import { Text, View } from '../components/Themed'; | ||
import { KkLandingProps } from '../containers/KkLandingContainer'; | ||
|
||
export const KkLandingScreen = (props: KkLandingProps) => { | ||
return ( | ||
<View style={styles.container}> | ||
<View style={styles.container}> | ||
<Text style={fonts.h6({ bold: true })}>Welcome to Klakie!</Text> | ||
</View> | ||
<View style={styles.container}> | ||
<Text style={fonts.body1()}>Enter your API Key</Text> | ||
<KkSizedBox height={24} /> | ||
<TextInput | ||
style={styles.input} | ||
value={props.formState.apiKey} | ||
onSubmitEditing={props.userSubmittedForm} | ||
onChangeText={(text) => | ||
props.userUpdatedForm((prevState) => ({ | ||
...prevState, | ||
apiKey: text, | ||
})) | ||
} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
input: { | ||
...fonts.body1(), | ||
color: 'white', | ||
border: '1px solid white', | ||
padding: 8, | ||
}, | ||
}); |
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,11 @@ | ||
import React from 'react'; | ||
import { Text, View } from '../components/Themed'; | ||
import { KkWorkspaceProps } from '../containers/KkWorkspaceContainer'; | ||
|
||
export const KkWorspaceScreen = (props: KkWorkspaceProps) => { | ||
return ( | ||
<View> | ||
<Text>Hello world</Text> | ||
</View> | ||
); | ||
}; |
Oops, something went wrong.