Skip to content

Commit

Permalink
feature-added node icons
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloyap22 committed Oct 9, 2024
1 parent 5b84908 commit b77a358
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 9 deletions.
Binary file added assets/icons/entrance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/special.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/stairs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions components/EditNodeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppDispatch, RootState } from "@/store/datastore";
import { useDispatch, useSelector } from "react-redux";
import { updateNodeProperties } from "@/store/NavMapSlice";
import TagOptions from "./TagOptions";
import { Picker } from '@react-native-picker/picker';

type editNodeMenuProps = {
isVisible: boolean,
Expand All @@ -13,6 +14,7 @@ type editNodeMenuProps = {
const EditNodeMenu = (props: editNodeMenuProps) => {
const [nodeName, setNodeName] = useState('');
const [nodeDescription, setNodeDescription] = useState('');
const [nodeType, setNodeType] = useState('');
const testTags = ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6', 'tag7', 'tag8', 'tag9', 'tag10'];
const [selectedTags, setSelectedTags] = useState<string[]>([]);

Expand All @@ -28,17 +30,19 @@ const EditNodeMenu = (props: editNodeMenuProps) => {
const updateNode = () => {
if (selectedNodeIDs.length > 0) {
selectedNodeIDs.forEach((nodeID) => {
dispatch(updateNodeProperties({key: nodeID, name: nodeName, desc: nodeDescription, tags: selectedTags}));
dispatch(updateNodeProperties({key: nodeID, name: nodeName, type: nodeType, desc: nodeDescription, tags: selectedTags}));
console.log("Updated Node: " + nodeID);
console.log("Name: " + nodeName);
console.log("Type: " + nodeType);
console.log("Description: " + nodeDescription);
console.log("Tags: " + selectedTags);
});
}
else if (selectedNodeID !== "") {
dispatch(updateNodeProperties({key: selectedNodeID, name: nodeName, desc: nodeDescription, tags: selectedTags}));
dispatch(updateNodeProperties({key: selectedNodeID, name: nodeName, type: nodeType, desc: nodeDescription, tags: selectedTags}));
console.log("Updated Node: " + selectedNodeID);
console.log("Name: " + nodeName);
console.log("Type: " + nodeType);
console.log("Description: " + nodeDescription);
console.log("Tags: " + selectedTags);
}
Expand Down Expand Up @@ -101,6 +105,7 @@ const EditNodeMenu = (props: editNodeMenuProps) => {
if (node) {
setNodeName(node.name);
setNodeDescription(node.description);
setNodeType(node.type);
setSelectedTags(node.tags);
}
}
Expand All @@ -109,6 +114,7 @@ const EditNodeMenu = (props: editNodeMenuProps) => {
if (node) {
setNodeName(node.name);
setNodeDescription(node.description);
setNodeType(node.type);
setSelectedTags(node.tags);
}
}
Expand Down Expand Up @@ -141,6 +147,16 @@ const EditNodeMenu = (props: editNodeMenuProps) => {
multiline={true}
numberOfLines={2}
/>
<Text>Node Type:</Text>
<Picker
selectedValue={nodeType}
onValueChange={(itemValue, itemIndex) => setNodeType(itemValue)}
>
<Picker.Item label="Entrance" value="Entrance" />
<Picker.Item label="Stairs" value="Stairs" />
<Picker.Item label="Special" value="Special" />
<Picker.Item label="Path" value="Path" />
</Picker>
<Text>Tags:</Text>
<View style={{flexDirection: 'row', flexWrap: 'wrap', columnGap:
10, rowGap: 10, marginBottom: 10, marginTop: 10, justifyContent: 'center'
Expand Down
1 change: 1 addition & 0 deletions components/MapEditorCanvas/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const Canvas = (props: CanvasProps) => {
name: "node-" + newId,
id: newId,
tags: [],
type: "Path",
coords: coords,
description: ""
}
Expand Down
4 changes: 2 additions & 2 deletions components/MapEditorCanvas/NavigationEdge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const NavigationEdge = (props: NavigationEdgeProps) => {
const styles = StyleSheet.create({
line: {
position: 'absolute',
height: 5,
backgroundColor: 'red',
height: 3,
backgroundColor: 'lime',
left: "50%",
},
});
Expand Down
1 change: 1 addition & 0 deletions components/MapEditorCanvas/NavigationEdgeDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const NavigationEdgeDisplay = () => {
const emptyNode:NavNodeType = {
name:"empty",
id:"empty",
type:"empty",
tags:[],
description:"empty",
coords: emptyCoords
Expand Down
7 changes: 4 additions & 3 deletions components/MapEditorCanvas/NavigationNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import React, { useEffect } from "react";
import { Coordinate } from "../../constants/Coordinate"
import { Dimension } from "@/constants/Dimension";
import { is } from "immutable";
import { useLinkProps } from "@react-navigation/native";

const defaultImage:ImageProps = require('../../assets/images/sampleNode.png')
import { NodeTypeMapper } from "@/constants/NodeTypeMapper";

type NavigationNodeProps = {
name: string,
id: string,
coords: Coordinate,
type: string,
dimension: Dimension,
canvasDimension: Dimension,
scale: number
Expand Down Expand Up @@ -54,6 +53,8 @@ const NavigationNode = (props: NavigationNodeProps) => {
}
}

const defaultImage = NodeTypeMapper[props.type];

const nodePanResponder = PanResponder.create({
onStartShouldSetPanResponder: () => isMoveMode,
onPanResponderMove: (evt) => {
Expand Down
1 change: 1 addition & 0 deletions components/MapEditorCanvas/NavigationNodeDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const NavigationNodeDisplay = (props: NavigationNodeDisplayProps) => {
<NavigationNode key={node.id}
name={node.name}
id={node.id}
type={node.type}
coords={node.coords}
dimension={props.dimension}
canvasDimension = {props.canvasDimensions}
Expand Down
1 change: 1 addition & 0 deletions constants/NavigationNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Coordinate} from './Coordinate'
export interface NavNodeType {
name: string;
id: string;
type: string;
coords: Coordinate;
tags: string[];
description: string;
Expand Down
7 changes: 7 additions & 0 deletions constants/NodeTypeMapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

export const NodeTypeMapper: { [key: string]: any } = {
Path: require('@/assets/icons/path.png'),
Stairs: require('@/assets/icons/stairs.png'),
Entrance: require('@/assets/icons/entrance.png'),
Special : require('@/assets/icons/special.png'),
}
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"dependencies": {
"@expo/vector-icons": "^14.0.2",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-picker/picker": "^2.8.1",
"@react-navigation/native": "^6.1.18",
"@react-navigation/stack": "^6.4.1",
"@reduxjs/toolkit": "^2.2.6",
Expand Down
6 changes: 4 additions & 2 deletions store/NavMapSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const navMapSlice = createSlice({
const newNode: NavNodeType = {
name: action.payload.id,
id: action.payload.id,
type: action.payload.id,
tags: [],
coords: action.payload.coords,
description: ""
Expand All @@ -53,6 +54,7 @@ const navMapSlice = createSlice({
name: "node-" + id,
id: id,
tags: [],
type: "Path",
coords: action.payload.coords,
description: ""
}
Expand Down Expand Up @@ -98,10 +100,10 @@ const navMapSlice = createSlice({
state.nodes = state.nodes.set(action.payload.key, updatedNode);
}
},
updateNodeProperties: (state, action: PayloadAction<{ key: string, name: string, desc: string, tags: string[]}>) => {
updateNodeProperties: (state, action: PayloadAction<{ key: string, name: string, type: string, desc: string, tags: string[]}>) => {
const existingNode = state.nodes.get(action.payload.key);
if (existingNode) {
const updatedNode = { ...existingNode, name: action.payload.name, description: action.payload.desc, tags: action.payload.tags };
const updatedNode = { ...existingNode, name: action.payload.name,type: action.payload.type, description: action.payload.desc, tags: action.payload.tags };
state.nodes = state.nodes.set(action.payload.key, updatedNode);
}
},
Expand Down

0 comments on commit b77a358

Please sign in to comment.