Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Replace share text with an image on iOS #242

Merged
merged 17 commits into from
Oct 3, 2019
Merged
Prev Previous commit
Next Next commit
👌🏻 Renamed currentFrequency as frequency
  • Loading branch information
James Pearson committed Oct 3, 2019
commit 77ed78705636843895ab391fdd3f8d06574290eb
6 changes: 3 additions & 3 deletions App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (Constants.manifest.extra.sentryPublicDsn) {
}
}

export function App () {
export function App() {
const [ready, setReady] = useState(false);
useEffect(() => {
Promise.all([
Expand Down Expand Up @@ -79,6 +79,6 @@ export function App () {
</LocationContextProvider>
</ErrorContextProvider>
) : (
<LoadingBackground />
);
<LoadingBackground />
);
}
4 changes: 2 additions & 2 deletions App/Screens/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import * as theme from '../../util/theme';

interface HomeProps extends NavigationInjectedProps { }

export function Home (props: HomeProps) {
export function Home(props: HomeProps) {
const { api } = useContext(ApiContext);
const { currentFrequency: frequency, setFrequency } = useContext(FrequencyContext);
const { frequency, setFrequency } = useContext(FrequencyContext);

trackScreen('HOME');

Expand Down
6 changes: 3 additions & 3 deletions App/Screens/ShareScreen/ShareImage/ShareImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import { CigaretteBlock, CurrentLocation } from '../../../components';
import { ApiContext, CurrentLocationContext, FrequencyContext } from '../../../stores';
import * as theme from '../../../util/theme';

export function ShareImage () {
export function ShareImage() {
const { api } = useContext(ApiContext)!;
const { currentLocation } = useContext(CurrentLocationContext);
const { currentFrequency } = useContext(FrequencyContext);
const { frequency } = useContext(FrequencyContext);

const cigarettesPerDay = api!.shootISmoke.cigarettes;

return (
<View style={styles.container}>
<CigaretteBlock cigarettesPerDay={cigarettesPerDay} frequency={currentFrequency} displayFrequency style={{ paddingHorizontal: 0 }} />
<CigaretteBlock cigarettesPerDay={cigarettesPerDay} frequency={frequency} displayFrequency style={{ paddingHorizontal: 0 }} />
<View>
<CurrentLocation api={api!} currentLocation={currentLocation!} numberOfLines={2} />
</View>
Expand Down
15 changes: 11 additions & 4 deletions App/stores/frequency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,26 @@
import React, { createContext, useState } from 'react';
import { Frequency } from '../Screens/Home/SelectFrequency';

export const FrequencyContext = createContext();
import { noop } from '../util/noop';

export function FrequencyContextProvider ({
interface Context {
frequency: Frequency
setFrequency: (newFrequency: Frequency) => void;
}

export const FrequencyContext = createContext<Context>({ frequency: "daily", setFrequency: noop });

export function FrequencyContextProvider({
children
}: {
children: JSX.Element;
}) {
const [currentFrequency, setFrequency] = useState<Frequency>('daily');
const [frequency, setFrequency] = useState<Frequency>('daily');

return (
<FrequencyContext.Provider
value={{
currentFrequency,
frequency,
setFrequency
}}
>
Expand Down