-
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
1 parent
fb98c25
commit 83e6b16
Showing
8 changed files
with
74 additions
and
141 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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.
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