Skip to content

Commit

Permalink
Demo hidden notification (Szops#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyjash authored Apr 25, 2022
1 parent 1fbbe56 commit 949dcd8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
26 changes: 24 additions & 2 deletions mobile/src/components/MapMarkerCard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Switch} from 'react-native';
import {Switch, Alert} from 'react-native';
import styled from 'styled-components';
import {
navDarkColor,
Expand All @@ -9,6 +9,7 @@ import {
import {HugeText, NormalText} from './Text';
import React, {useState, useContext} from 'react';
import {MarkerContext} from '../context/MarkerContextProvider';
import PushNotification from 'react-native-push-notification';

const StyledMarkerCard = styled.View`
height: 200px;
Expand Down Expand Up @@ -38,6 +39,23 @@ const StyledRow = styled.View`
padding-bottom: 15px;
`;

//ustawianie przypomnienia
//date - data przypomniania jako instancja Date
//pointName - nazwa punktu do wyświetlenia w powiadomieniu
const setNotification = (date, pointName) => {
PushNotification.localNotificationSchedule({
channelId: 'szop-nt',
title: 'Przypomnienie o dostępności punktu',
message: 'Punkt o nazwie ' + pointName + ' będzie wkrótce dostępny!',
date: date,
allowWhileIdle: true,
soundName: 'notification_sound.wav',
sound: 'notification_sound.wav',
playSound: true,
vibrate: true,
});
};

export default function MapMarkerCard() {
const {markerHidden, marker} = useContext(MarkerContext);
const toggleSwitch = async () => {
Expand All @@ -54,8 +72,12 @@ export default function MapMarkerCard() {
<Switch
trackColor={{false: switchFalse, true: tintColor}}
thumbColor={thumbColor}
onValueChange={toggleSwitch}
onValueChange={() => {
toggleSwitch();
setNotification(new Date(Date.now() + 5 * 1000), 'Rynek 25');
}}
value={marker.isNotificationsEnabled}
//marker.street
/>
</StyledRow>
</StyledRow>
Expand Down
4 changes: 3 additions & 1 deletion mobile/src/screens/HelloSzopScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ export default function HelloSzopScreen() {
<HomeCard header={text.tileHeader[3]} text={text.tileText[3]} last />

{/* Przyciski tylko do demo, później zrobimy automatyczne pobieranie w useEffect */}
{/*
<Button title="Pobierz bazę danych" onPress={updateDataabse} />
<Button title="Usuń bazę danych" onPress={deleteDataabse} />
{/* Tylko do demo */}
Tylko do demo
<TextInput
placeholder="Godzina"
keyboardType="numeric"
Expand Down Expand Up @@ -99,6 +100,7 @@ export default function HelloSzopScreen() {
);
}}
/>
*/}
</StyledScrollView>
{/*<HugeText>{text.appName}</HugeText>
<Button
Expand Down

0 comments on commit 949dcd8

Please sign in to comment.