Skip to content

Commit

Permalink
fix: navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarolorentedev committed Aug 27, 2024
1 parent fb98c25 commit 83e6b16
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 141 deletions.
10 changes: 5 additions & 5 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export default {
typedRoutes: true,
},
updates: {
url: "https://u.expo.dev/6002db10-a1bc-4c3a-9332-f42d17dbd6a2"
url: 'https://u.expo.dev/6002db10-a1bc-4c3a-9332-f42d17dbd6a2',
},
runtimeVersion: {
policy: "appVersion"
policy: 'appVersion',
},
extra: {
eas: {
"projectId": "6002db10-a1bc-4c3a-9332-f42d17dbd6a2"
}
}
projectId: '6002db10-a1bc-4c3a-9332-f42d17dbd6a2',
},
},
};
61 changes: 0 additions & 61 deletions src/app/Home/index.tsx

This file was deleted.

52 changes: 0 additions & 52 deletions src/app/Settings/helpers/observersfromLinkParser.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/app/Settings/helpers/storage.ts

This file was deleted.

9 changes: 9 additions & 0 deletions src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export default function RootLayout() {
tabBarIcon: ({ color, focused }) => <TabBarIcon name={focused ? 'home' : 'home-outline'} color={color} />,
}}
/>
<Tabs.Screen
name="settings"
options={{
title: 'Settings',
tabBarIcon: ({ color, focused }) => (
<TabBarIcon name={focused ? 'options' : 'options-outline'} color={color} />
),
}}
/>
</Tabs>
</ObserverContext.Provider>
</PaperProvider>
Expand Down
68 changes: 57 additions & 11 deletions src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,61 @@
import { Text, View } from 'react-native';
import React, { useState, useEffect, useContext } from 'react';
import { ScrollView, Image } from 'react-native';
import { Card } from 'react-native-paper';
import { State } from '@/src/types/State';
import { Status } from '@/src/types/Status';
import { ObserverContext } from '@/src/app/_layout';
import { ObserverManager } from '@/src/domain/observers/ObserverManager';

export default function Index() {
export default function Home() {
const observerManager = useContext(ObserverContext) as ObserverManager;
const [observablesState, setObservablesState] = useState([]);
const imageSelector = (status: Status) => {
switch (status) {
case Status.SUCCESS:
return require('@/src/assets/images/ok_icon_big.png');
case Status.CHECKING:
return require('@/src/assets/images/running_icon_big.png');
case Status.NA:
return require('@/src/assets/images/na_icon_big.png');
case Status.FAILURE:
return require('@/src/assets/images/fail_icon_big.png');
}
};
useEffect(() => {
(async () => {
await observerManager.refershObservers();
setObservablesState((await observerManager.getStates()) as any);
const MINUTES_MS = 300000;
const interval = setInterval(async () => {
setObservablesState((await observerManager.getStates()) as any);
}, MINUTES_MS);
return () => clearInterval(interval);
})();
}, []);
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}
>
<Text>Edit app/index.tsx to edit this screen.</Text>
</View>
<>
<ScrollView>
{observablesState.map((state: State, index: number) => (
<Card
key={`observable_${index}_${state.name}`}
style={{
marginVertical: 5,
}}
>
<Card.Title
title={state.name}
subtitle={Status.toString(state.status)}
titleStyle={{
fontWeight: 'bold',
fontSize: 20,
}}
left={(props) => (
<Image style={{ width: 30, height: 30 }} {...props} source={imageSelector(state.status)} />
)}
/>
</Card>
))}
</ScrollView>
</>
);
}
File renamed without changes.
6 changes: 3 additions & 3 deletions src/app/Settings/index.tsx → src/app/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState, useEffect, useContext } from 'react';
import { Platform, ScrollView } from 'react-native';
import { Portal } from 'react-native-paper';
import { Observers as ObserversComponent } from '../../components/Observers';
import { mutations } from './helpers/mutations';
import { Observers as ObserversComponent } from '../components/Observers';
import { mutations } from './mutations';
import * as SecureStore from 'expo-secure-store';
import { ObserverContext } from '../_layout';
import { ObserverContext } from './_layout';
import { ObserverManager } from '@/src/domain/observers/ObserverManager';

export default function Settings() {
Expand Down

0 comments on commit 83e6b16

Please sign in to comment.