-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
Added Notifications with repeating Schedules Solves #55 #57
Open
SalikSayyed
wants to merge
24
commits into
heylinda:main
Choose a base branch
from
SalikSayyed:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+553
−6
Open
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c390c1f
Added Notification Schedular
SalikSayyed cfc832e
Added Notification Schedular
SalikSayyed 37deef3
Check correction
SalikSayyed 26767ed
Notification Cleaner
SalikSayyed 7939844
Time Show formated
SalikSayyed 124fb34
Swiped Buttons
SalikSayyed 5a5d5ec
Set Notification Panel Toggle added
SalikSayyed e271c6d
Update screens/Settings/index.tsx
SalikSayyed 2852ffd
Update screens/Settings/index.tsx
SalikSayyed ab7e359
Update screens/Settings/index.tsx
SalikSayyed b6603ac
Theme Color, Non-repetative Code, Dialog Box Added
SalikSayyed 8d75552
Theme Color, Non-repetative Code, Dialog Box Added
SalikSayyed 0a725a9
Modified Permission for IOS and Android
SalikSayyed 0856c2c
Added Notifier on HomeScreen
SalikSayyed 7a85a1f
Update screens/Settings/notificationSetter.tsx
SalikSayyed 90a3e7b
Update screens/Settings/notificationSetter.tsx
SalikSayyed 850cc4a
Removed Toast using SnackBar, removed logs and camelCase Correction
SalikSayyed 893e663
merge conflict resolved
SalikSayyed 12ac4b9
changes
SalikSayyed f373575
clear data clearning set notification
SalikSayyed 3716f9a
notificationSetter updated UI for IOS
SalikSayyed f97c075
Auto Close UI
SalikSayyed f5fc7a4
space between days
SalikSayyed 8413da3
setShow correction
SalikSayyed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ web-build/ | |
.eslintcache | ||
|
||
# other files | ||
NOTES.md | ||
NOTES.md | ||
yarn-error.log |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react' | ||
import { Snackbar } from 'react-native-paper' | ||
import { Text, useThemeColor } from '../components/Themed' | ||
|
||
interface Props { | ||
message: string | ||
show: boolean | ||
changeShow: React.Dispatch<React.SetStateAction<boolean>> | ||
} | ||
|
||
export default function ToastBar({ message, show, changeShow }: Props) { | ||
const onDismissSnackBar = () => changeShow(false) | ||
return ( | ||
<Snackbar | ||
visible={show} | ||
duration={2000} | ||
onDismiss={onDismissSnackBar} | ||
wrapperStyle={{ backgroundColor: useThemeColor({}, 'black') }} | ||
> | ||
<Text style={{ color: useThemeColor({}, 'white') }}>{message}</Text> | ||
</Snackbar> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react' | ||
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native' | ||
import { useThemeColor } from '../components/Themed' | ||
|
||
interface Props { | ||
weekdays: number[] | ||
setWeekdays: React.Dispatch<React.SetStateAction<number[]>> | ||
} | ||
export default function DayPicker({ weekdays, setWeekdays }: Props) { | ||
function daysIO(v: number) { | ||
if (weekdays.includes(v)) { | ||
const weekdayRemoved = weekdays.filter((element) => element !== v) | ||
setWeekdays(weekdayRemoved) | ||
} else { | ||
setWeekdays([...weekdays, v]) | ||
} | ||
} | ||
|
||
const activeColor = useThemeColor({}, 'primary') | ||
const inactiveColor = useThemeColor({}, 'gray800') | ||
const whiteColor = useThemeColor({}, 'white') | ||
const days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'] | ||
return ( | ||
<View style={[styles.boxContainer]}> | ||
{days.map((value, index) => ( | ||
<TouchableOpacity key={value} onPress={() => daysIO(index + 1)}> | ||
<View | ||
style={[ | ||
styles.box, | ||
{ backgroundColor: weekdays.includes(index + 1) ? activeColor : inactiveColor }, | ||
]} | ||
> | ||
<Text style={{ color: whiteColor }}>{value}</Text> | ||
</View> | ||
</TouchableOpacity> | ||
))} | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
box: { | ||
width: 40, | ||
height: 40, | ||
borderRadius: 20, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
marginVertical: 30, | ||
}, | ||
boxContainer: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-evenly', | ||
alignItems: 'center', | ||
marginTop: 20, | ||
}, | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import * as Notifications from 'expo-notifications' | ||
import { Platform } from 'react-native' | ||
|
||
const askPermissions = async () => { | ||
Notifications.getPermissionsAsync().then((status) => { | ||
if (!status.granted) { | ||
Notifications.requestPermissionsAsync() | ||
} | ||
}) | ||
} | ||
|
||
const deleteNotifications = async () => { | ||
Notifications.cancelAllScheduledNotificationsAsync() | ||
} | ||
|
||
const iosScheduler = (weekday: number[], time: Date) => { | ||
if (weekday !== [-1]) { | ||
Notifications.cancelAllScheduledNotificationsAsync() | ||
weekday.forEach((v) => { | ||
if (v !== -1) { | ||
Notifications.scheduleNotificationAsync({ | ||
content: { | ||
title: 'Practice your meditation today 🙇♂️', | ||
}, | ||
trigger: { | ||
hour: time.getHours(), | ||
minute: time.getMinutes(), | ||
weekday: v, | ||
}, | ||
}) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
const androidSchedular = (weekday: number[], time: Date) => { | ||
Notifications.cancelAllScheduledNotificationsAsync() | ||
if (weekday !== [-1]) { | ||
weekday.forEach((v) => { | ||
if (v !== -1) { | ||
Notifications.scheduleNotificationAsync({ | ||
content: { | ||
title: 'Practice your meditation today 🙇♂️', | ||
}, | ||
trigger: { | ||
hour: time.getHours(), | ||
minute: time.getMinutes(), | ||
weekday: v, | ||
repeats: true, | ||
}, | ||
}) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
const platformScheduler = (weekday: number[], time: Date) => { | ||
if (Platform.OS === 'android') { | ||
androidSchedular(weekday, time) | ||
} | ||
if (Platform.OS === 'ios') { | ||
iosScheduler(weekday, time) | ||
} | ||
} | ||
|
||
export default { | ||
askPermission: askPermissions, | ||
testSchedular: platformScheduler, | ||
deleteNotification: deleteNotifications, | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import * as React from 'react' | ||
import { Platform, StyleSheet, View, TouchableOpacity, Text } from 'react-native' | ||
import { useThemeColor } from '../../components/Themed' | ||
|
||
import DateTimePicker from '@react-native-community/datetimepicker' | ||
import Notify from '../../notifications/notificationHandler' | ||
import WeekdayPicker from '../../components/WeekdayPicker' | ||
|
||
interface Props { | ||
setToastMessage: React.Dispatch<React.SetStateAction<string>> | ||
setToastShow: React.Dispatch<React.SetStateAction<boolean>> | ||
} | ||
|
||
const NotificationSetter = ({ setToastMessage, setToastShow }: Props) => { | ||
const [time, setTime] = React.useState(new Date()) | ||
const [pickedTime, setPickedTime] = React.useState(false) | ||
const [weekdays, setWeekdays] = React.useState([-1]) | ||
const [show, setShow] = React.useState(false) | ||
const changeTimeHandler = (event: Event, value?: Date) => { | ||
setShow(Platform.OS === 'ios') | ||
if (value) { | ||
setPickedTime(true) | ||
} else { | ||
setPickedTime(false) | ||
} | ||
setTime(value || new Date()) | ||
} | ||
|
||
const timeString = (timeSet: Date) => { | ||
const timeHours = timeSet.getHours() | ||
const timeMinutes = timeSet.getMinutes() | ||
const hours = | ||
timeHours === 0 ? '00' : timeHours <= 9 ? '0' + timeHours.toString() : timeHours.toString() | ||
const minutes = | ||
timeMinutes === 0 | ||
? '00' | ||
: timeMinutes <= 9 | ||
? '0' + timeMinutes.toString() | ||
: timeMinutes.toString() | ||
return hours + ' : ' + minutes | ||
} | ||
|
||
const textColor = useThemeColor({}, 'text') | ||
const textWhite = useThemeColor({}, 'white') | ||
|
||
return ( | ||
<> | ||
SalikSayyed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<WeekdayPicker weekdays={weekdays} setWeekdays={setWeekdays} /> | ||
<View style={styles.buttonContainer}> | ||
<TouchableOpacity onPress={() => setShow(!show)}> | ||
<View style={[styles.pickTime, { backgroundColor: useThemeColor({}, 'primary') }]}> | ||
<Text style={{ color: textWhite }}>PICK TIME</Text> | ||
</View> | ||
</TouchableOpacity> | ||
{pickedTime && ( | ||
<Text style={[styles.selectedTime, { color: textColor }]}>At {timeString(time)} </Text> | ||
)} | ||
<TouchableOpacity | ||
onPress={() => { | ||
if (weekdays.length !== 1 && pickedTime) { | ||
Notify.testSchedular(weekdays, time) | ||
setToastMessage('Reminders Set') | ||
setToastShow(true) | ||
} else { | ||
setToastMessage('Please Pick Day and Time') | ||
setToastShow(true) | ||
} | ||
}} | ||
> | ||
<View style={[styles.pickTime, { backgroundColor: useThemeColor({}, 'primary') }]}> | ||
<Text style={{ color: textWhite }}>NOTIFY</Text> | ||
</View> | ||
</TouchableOpacity> | ||
</View> | ||
{show && ( | ||
<DateTimePicker | ||
value={time} | ||
mode="time" | ||
is24Hour={true} | ||
display="clock" | ||
onChange={changeTimeHandler} | ||
/> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
pickTime: { | ||
width: 90, | ||
height: 25, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
borderRadius: 10, | ||
}, | ||
selectedTime: { | ||
fontSize: 20, | ||
}, | ||
buttonContainer: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
marginHorizontal: 1, | ||
}, | ||
}) | ||
|
||
export default NotificationSetter |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: call this
setShow