Files
new-phone-who-dis/phone/src/apps/example/components/ExampleApp.tsx
T
J Francisco Rader 0ec2b682e7 Messages bugfix again :D (#164)
* Handle offline messages | Fetch messages when broadcasted | Fetch message groups

* Fetch messages on notification click

* Dont fetch groups if duplicate group

* Only submit new message on click submit

* Fix infinite loading when duplicated group is creatded

* Fix infinite loading when group already existed

* Make code prettier

* Centralize fetch messages on goToConversation

* Remove duplicated event

* Improve message groups mapping to include yourself for unreadCount + Fix redirection after adding contact + General improvements

* Remove conflicts

* Fix media paths
2021-03-18 23:01:54 -03:00

47 lines
1.6 KiB
TypeScript

import React, { useState } from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
import { useApp } from '../../../os/apps/hooks/useApps';
import { useExample } from '../hooks/useExample';
import { ExampleThemeProvider } from '../providers/ExampleThemeProvider';
import { AppTitle } from '../../../ui/components/AppTitle';
import PlayIcon from '@material-ui/icons/PlayArrow';
import StopIcon from '@material-ui/icons/Stop';
import { Button, IconButton } from '@material-ui/core';
import useSound from '../../../os/sound/hooks/useSound';
export const ExampleApp = () => {
// calling the example hook, and we assign the value to a variable
const exampleString = useExample();
const example = useApp('EXAMPLE');
const [soundName, setSound] = useState('pixel.ogg');
const { play, playing, stop } = useSound('media/ringtones/' + soundName);
const toggleSound = () => {
if (soundName === 'pixel.ogg') {
setSound('marimba.ogg');
return;
}
setSound('pixel.ogg');
};
return (
<ExampleThemeProvider>
<AppWrapper>
<AppTitle app={example} />
<AppContent>
<h1>This is an example</h1>
<Button color="primary">{example.id}</Button>
{/* Here we are using the value in a h3 tag */}
<h3>{exampleString}</h3>
<IconButton onClick={() => (playing ? stop() : play())}>
{playing ? <StopIcon /> : <PlayIcon />}
</IconButton>
<Button onClick={toggleSound}>Change sound on the fly</Button>
</AppContent>
</AppWrapper>
</ExampleThemeProvider>
);
};