Skip to content

Commit 1574958

Browse files
author
Vivek Patel
committed
Added Haptic Feedbacks
1 parent 68333c5 commit 1574958

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

models/history.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
33
import React from "react";
44
import { View, ScrollView, Text, TouchableHighlight } from "react-native";
55
import { LinearGradient } from "expo-linear-gradient";
6+
import * as Haptics from "expo-haptics";
67
export default class History extends React.Component {
78
constructor(props) {
89
super(props);
@@ -89,6 +90,7 @@ export default class History extends React.Component {
8990
clearHistory = async () => {
9091
try {
9192
await AsyncStorage.clear();
93+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
9294
alert("History Cleared!");
9395
this.setState({ allKeys: [] });
9496
} catch (e) {

models/table.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111

1212
import AsyncStorage from "@react-native-async-storage/async-storage";
1313
import { Table, TableWrapper, Row, Cell } from "react-native-table-component";
14+
import * as Haptics from "expo-haptics";
1415

1516
export default class InputTable extends Component {
1617
constructor(props) {
@@ -171,12 +172,14 @@ export default class InputTable extends Component {
171172
}
172173

173174
animationCompleted() {
175+
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
174176
alert("Process Completed!");
175177
}
176178

177179
ganntChart() {
178180
if (this.state.ganntChartArray.length == 0) {
179-
alert("No Processes!");
181+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
182+
alert("Add Processes & Press Evaluate First!");
180183
return null;
181184
}
182185

@@ -664,6 +667,7 @@ export default class InputTable extends Component {
664667
deleteProcess() {
665668
const state = this.state;
666669
if (state.totalProcess == -1) {
670+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
667671
alert("Table is Empty!");
668672
return null;
669673
}
@@ -682,6 +686,7 @@ export default class InputTable extends Component {
682686

683687
toggleButton() {
684688
const toggleSwitch = () => {
689+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
685690
var isIoEnabled = this.state.isIoEnabled;
686691
var tableHead = this.state.tableHead;
687692
var tableData = this.state.tableData;

screens/home.js

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "react-native";
1212
import "react-native-gesture-handler";
1313
import { LinearGradient } from "expo-linear-gradient";
14-
14+
import * as Haptics from "expo-haptics";
1515
export default function App({ navigation }) {
1616
const Algorithms = [
1717
{ id: "0", name: "FCFS" },
@@ -36,7 +36,10 @@ export default function App({ navigation }) {
3636
<View style={styles.container}>
3737
<TouchableHighlight
3838
style={styles.algoBox}
39-
onPress={() => navigation.navigate("FCFS Algorithm", Algorithms[0])}
39+
onPress={() => [
40+
navigation.navigate("FCFS Algorithm", Algorithms[0]),
41+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
42+
]}
4043
>
4144
<View
4245
style={[styles.algoBox, { backgroundColor: "rgb(5, 116, 95)" }]}
@@ -56,7 +59,10 @@ export default function App({ navigation }) {
5659

5760
<TouchableHighlight
5861
style={styles.algoBox}
59-
onPress={() => navigation.navigate("SJF Algorithm", Algorithms[1])}
62+
onPress={() => [
63+
navigation.navigate("SJF Algorithm", Algorithms[1]),
64+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
65+
]}
6066
>
6167
<View
6268
style={[styles.algoBox, { backgroundColor: "rgb(25,84,123)" }]}
@@ -76,7 +82,10 @@ export default function App({ navigation }) {
7682

7783
<TouchableHighlight
7884
style={styles.algoBox}
79-
onPress={() => navigation.navigate("SRTF Algorithm", Algorithms[2])}
85+
onPress={() => [
86+
navigation.navigate("SRTF Algorithm", Algorithms[2]),
87+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
88+
]}
8089
>
8190
<View
8291
style={[styles.algoBox, { backgroundColor: "rgb(1, 95, 223)" }]}
@@ -96,9 +105,10 @@ export default function App({ navigation }) {
96105

97106
<TouchableHighlight
98107
style={styles.algoBox}
99-
onPress={() =>
100-
navigation.navigate("Round Robin Algorithm", Algorithms[3])
101-
}
108+
onPress={() => [
109+
navigation.navigate("Round Robin Algorithm", Algorithms[3]),
110+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
111+
]}
102112
>
103113
<View
104114
style={[styles.algoBox, { backgroundColor: "rgb(255, 170, 34)" }]}
@@ -121,7 +131,10 @@ export default function App({ navigation }) {
121131

122132
<TouchableHighlight
123133
style={styles.algoBox}
124-
onPress={() => navigation.navigate("LJF Algorithm", Algorithms[4])}
134+
onPress={() => [
135+
navigation.navigate("LJF Algorithm", Algorithms[4]),
136+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
137+
]}
125138
>
126139
<View
127140
style={[
@@ -144,7 +157,10 @@ export default function App({ navigation }) {
144157

145158
<TouchableHighlight
146159
style={styles.algoBox}
147-
onPress={() => navigation.navigate("LRTF Algorithm", Algorithms[5])}
160+
onPress={() => [
161+
navigation.navigate("LRTF Algorithm", Algorithms[5]),
162+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
163+
]}
148164
>
149165
<View
150166
style={[styles.algoBox, { backgroundColor: "rgb(255, 170, 34)" }]}
@@ -164,9 +180,11 @@ export default function App({ navigation }) {
164180

165181
<TouchableHighlight
166182
style={styles.algoBox_P}
167-
onPress={() =>
168-
navigation.navigate("PRIORITY SCHEDULING(P)", Algorithms[6])
169-
}
183+
onPress={() => [
184+
navigation.navigate("PRIORITY SCHEDULING(P)", Algorithms[6]),
185+
,
186+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
187+
]}
170188
>
171189
<View
172190
style={[
@@ -199,9 +217,10 @@ export default function App({ navigation }) {
199217
</TouchableHighlight>
200218
<TouchableHighlight
201219
style={styles.algoBox_P}
202-
onPress={() =>
203-
navigation.navigate("PRIORITY SCHEDULING(NP)", Algorithms[7])
204-
}
220+
onPress={() => [
221+
navigation.navigate("PRIORITY SCHEDULING(NP)", Algorithms[7]),
222+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
223+
]}
205224
>
206225
<View
207226
style={[
@@ -234,7 +253,10 @@ export default function App({ navigation }) {
234253
</TouchableHighlight>
235254
<TouchableHighlight
236255
style={styles.historyBox}
237-
onPress={() => navigation.navigate("Input History")}
256+
onPress={() => [
257+
navigation.navigate("Input History"),
258+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light),
259+
]}
238260
>
239261
<View
240262
style={[styles.historyBoxView, { backgroundColor: "#45B649" }]}

0 commit comments

Comments
 (0)