Skip to content

Commit

Permalink
Merge branch 'TranslationAndSettings' of https://github.com/AndreaIan…
Browse files Browse the repository at this point in the history
…noli/JAM into TranslationAndSettings
  • Loading branch information
AndreaIannoli committed Nov 11, 2023
2 parents 7605f22 + 2069738 commit 4a13833
Show file tree
Hide file tree
Showing 175 changed files with 4,774 additions and 870 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified app/.DS_Store
Binary file not shown.
35 changes: 35 additions & 0 deletions app/JAM/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo
5 changes: 5 additions & 0 deletions app/JAM/.idea/.gitignore

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

13 changes: 13 additions & 0 deletions app/JAM/.idea/JAM.iml

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

6 changes: 6 additions & 0 deletions app/JAM/.idea/jsLibraryMappings.xml

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

14 changes: 14 additions & 0 deletions app/JAM/.idea/libraries/LA_MQTT.xml

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

8 changes: 8 additions & 0 deletions app/JAM/.idea/modules.xml

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

1 change: 0 additions & 1 deletion app/JAM/.idea/vcs.xml
100644 → 100755

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

1 change: 0 additions & 1 deletion app/JAM/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "./config/FirebaseConfig";
import RootNavigation from "./navigation/Index";
import {StreetsInfosProvider} from "./components/StreetsInfosProvider";

export default function App() {
return (
<StreetsInfosProvider>
Expand Down
20 changes: 9 additions & 11 deletions app/JAM/activities/Authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {Ionicons} from "@expo/vector-icons";
import {signIn, signUp} from "../services/AuthService";
import {FIREBASE_AUTH, FIREBASE_DB} from "../config/FirebaseConfig";
import ImagePickerBox from "../components/ImagePickerBox";
import {useTranslation} from "react-i18next";

function Authentication({navigation}){
const windowHeight = useWindowDimensions().height;
Expand All @@ -40,7 +39,6 @@ function Authentication({navigation}){
error: ''
});
const auth = FIREBASE_AUTH;
const { t } = useTranslation();
const toggleShowPassword = () => {
setShowPassword(!showPassword);
};
Expand Down Expand Up @@ -127,7 +125,7 @@ function Authentication({navigation}){
editable
inputMode="email"
autoComplete="email"
placeholder={t('emailPlaceHolder')}
placeholder="Email"
cursorColor={Colors.primary}
placeholderTextColor={Colors.grey}
style={[styles.textInput, {marginTop: 20}]}
Expand All @@ -141,7 +139,7 @@ function Authentication({navigation}){
value={password}
inputMode="text"
autoComplete="password"
placeholder={t('passwordPlaceHolder')}
placeholder="Password"
cursorColor={Colors.primary}
placeholderTextColor={Colors.grey}
style={[styles.textInput, {paddingHorizontal: 0}]}
Expand All @@ -158,7 +156,7 @@ function Authentication({navigation}){
<PrimaryButton title="Login" onPress={() => {signIn(auth, loginCredentials, setLoginCredentials, navigation)}}/>
{loginCredentials.error ? <Text style={styles.error}>{loginCredentials.error}</Text> : null}
<Pressable hitSlop={3} style={{marginTop: 10}}>
<Text style={styles.forgotPassText}>{t('passwordForgotLink')}</Text>
<Text style={styles.forgotPassText}>Hai dimenticato la password?</Text>
</Pressable>
</View>
:
Expand All @@ -168,7 +166,7 @@ function Authentication({navigation}){
editable
inputMode="email"
autoComplete="email"
placeholder={t('emailPlaceHolder')}
placeholder="Email"
cursorColor={Colors.primary}
placeholderTextColor={Colors.grey}
style={[styles.textInput, {marginTop: 20}]}
Expand All @@ -178,7 +176,7 @@ function Authentication({navigation}){
editable
inputMode="text"
autoComplete="username"
placeholder={t('namePlaceHolder')}
placeholder="Nome"
cursorColor={Colors.primary}
placeholderTextColor={Colors.grey}
style={[styles.textInput, {marginTop: 20}]}
Expand All @@ -189,7 +187,7 @@ function Authentication({navigation}){
secureTextEntry={true}
inputMode="text"
autoComplete="password"
placeholder={t('passwordPlaceHolder')}
placeholder="Password"
cursorColor={Colors.primary}
placeholderTextColor={Colors.grey}
style={[styles.textInput, {marginTop: 20}]}
Expand All @@ -200,13 +198,13 @@ function Authentication({navigation}){
secureTextEntry={true}
inputMode="text"
autoComplete="password"
placeholder={t('confirmPasswordPlaceHolder')}
placeholder="Conferma password"
cursorColor={Colors.primary}
placeholderTextColor={Colors.grey}
style={[styles.textInput, {marginTop: 20}, {marginBottom: 60}]}
onChangeText={(text) => setRegistrationCredentials({ ...registrationCredentials, confirmPass: text })}
/>
<PrimaryButton title={t('registerBtn')} onPress={() => {
<PrimaryButton title="Registrati" onPress={() => {
signUp(auth, registrationCredentials, setRegistrationCredentials, image, navigation);
}}/>
{registrationCredentials.error ? <Text style={styles.error}>{registrationCredentials.error}</Text> : null}
Expand All @@ -215,7 +213,7 @@ function Authentication({navigation}){
</View>
<View style={styles.switchContainer}>
<SegmentedControl
values={[t('segmentControlLogin'), t('segmentControlRegister')]}
values={['Login', 'Registrati']}
selectedIndex={selectedIndex}
onChange={(event) => {
setSelectedIndex(event.nativeEvent.selectedSegmentIndex)
Expand Down
7 changes: 3 additions & 4 deletions app/JAM/activities/Favourites.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import {useContext, useEffect, useState} from "react";
import {getUserFavourites} from "../services/UserService";
import {StreetsInfosContext} from "../components/StreetsInfosProvider";
import {getStatusComponent} from "../services/StreetService";
import {useTranslation} from "react-i18next";

function Favourites({navigation}){
const [favs, setFavs] = useState([])
const [filteredFavs, setFilteredFavs] = useState([])
const { streetsInfos, updateFavs } = useContext(StreetsInfosContext);
const { t } = useTranslation();

function getDotColor(status) {
if(status === 'free') {
return Colors.green;
Expand Down Expand Up @@ -96,10 +95,10 @@ function Favourites({navigation}){
<View style={styles.streetsContainer}>
<FlatList
data={favs}
renderItem={({item}) => <Item title={item} status={streetsInfos.get(item) ? streetsInfos.get(item).status : null}/>}
renderItem={({item}) => <Item title={item} status={streetsInfos.get(item)? streetsInfos.get(item).status : null}/>}
ItemSeparatorComponent={StreetsItemSeparator}
KeyExtractor={({item}) => item.title}
ListEmptyComponent={() => {return(<Text style={styles.emptyText}>{t('emptyFavourites')}</Text>)}}
ListEmptyComponent={() => {return(<Text style={styles.emptyText}>Aggiungi le strade di tuo interesse ai preferiti per visualizzarle facilmente e ricevere aggiornamenti</Text>)}}
/>
</View>
</View>
Expand Down
18 changes: 3 additions & 15 deletions app/JAM/activities/Feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import Animated, {
withTiming
} from "react-native-reanimated"
import {GestureHandlerRootView, PanGestureHandler} from "react-native-gesture-handler";
import {useTranslation} from "react-i18next";

function Feed(){
const [notifications, setNotifications] = useState(new Map());
const {updateNotifications} = useContext(StreetsInfosContext);
const { t } = useTranslation();

const deviceWidth = Dimensions.get('window').width;
const threshold = -deviceWidth * 0.4;
Expand Down Expand Up @@ -63,7 +61,7 @@ function Feed(){
<Text style={styles.notificationHeading}>{title}</Text>
<Text style={styles.ago}>{timeAgo((date.toDate().getTime()) / 1000)}</Text>
</View>
<Text style={styles.notificationBody}>{getNotificationDesc(title, description, notificationType)}</Text>
<Text style={styles.notificationBody}>{description}</Text>
</View>
</Animated.View>
</PanGestureHandler>
Expand Down Expand Up @@ -118,15 +116,7 @@ function Feed(){
} else {
const days = Math.floor(timeDifference / 86400);
const hours = Math.floor((timeDifference % 86400) / 3600);
return `${days}d ago`;
}
}

function getNotificationDesc(title, description, notificationType) {
if(notificationType === "notifyAlmostFull" || notificationType === "notifyFull" || notificationType === "notifyFree") {
return t(notificationType.replace("notify", "").toLowerCase() + "StreetNotificationBody", {streetName: title});
} else {
return description;
return `${days}d ${hours}h ago`;
}
}

Expand Down Expand Up @@ -165,11 +155,9 @@ function Feed(){
color: 'white',
flexWrap: 'wrap',
flexDirection: "row",
flexShrink: 1
},
notificationInfos: {
flexGrow: 1,
maxWidth: "80%"
flexGrow: 1
},
notificationsContainer: {
width: '100%'
Expand Down
106 changes: 106 additions & 0 deletions app/JAM/activities/Home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import {Text, View, StyleSheet, Platform} from "react-native";
import TopBar from "./TopBar";
import MapView from "react-native-maps";
import {StatusBar} from "expo-status-bar";
import {useContext, useEffect, useRef, useState} from "react";
import MapViewDirections from "react-native-maps-directions";
import * as Notifications from "expo-notifications";
import Constants from "expo-constants";
import StreetModal from "../components/StreetModal";
import {StreetsInfosContext} from "../components/StreetsInfosProvider";
import {Colors} from "../res/Colors";
function Home({navigation}) {
const [polyLines, setPolyLines] = useState(new Map());
const GOOGLE_MAPS_APIKEY = 'AIzaSyCMVvS9_LtrL_sfNoXu27hfhWBaWtYrUss';
const [showStreetModal, setShowStreetModal] = useState(false);
const [selectedStreetInfo, setSelectedStreetInfo] = useState();
const [selectedStreetName, setSelectedStreetName] = useState('');
const { streetsInfos, setStreetsInfos, location, update, errorMsg } = useContext(StreetsInfosContext);

useEffect(() => {
const polyLinesToPlot = new Map();
const toNotify = [];
for(let streetName of streetsInfos.keys()) {
const origin = {latitude: streetsInfos.get(streetName).latStart, longitude: streetsInfos.get(streetName).lngStart};
const destination = {latitude: streetsInfos.get(streetName).latEnd, longitude: streetsInfos.get(streetName).lngEnd};
let color;
if(streetsInfos.get(streetName).status === "free") {
color = Colors.green;
} else if(streetsInfos.get(streetName).status === "almost full") {
color = Colors.orange;
} else {
color = Colors.red;
}
polyLinesToPlot.set(streetName, <MapViewDirections
key={streetName}
origin={origin}
destination={destination}
apikey={GOOGLE_MAPS_APIKEY}
strokeWidth={6}
strokeColor={color}
precision="high"
tappable={true}
onPress={() => {setShowStreetModal(true); setSelectedStreetName(streetName); setSelectedStreetInfo(streetsInfos.get(streetName))}}
/>);
}
setPolyLines(new Map([...polyLines, ...polyLinesToPlot]));
console.log(polyLines);
}, [update]);

const styles = StyleSheet.create({
container: {
height: "100%",
alignItems: "center"
},
map: {
width: "100%",
height: "100%",
marginTop: -30,
zIndex: 1
},
errorBar: {
justifyContent: "center",
alignItems: "center",
width: "100%",
backgroundColor: "red",
height: 150,
marginTop: -40,
paddingTop: 0
},
errorText: {
fontSize: 16,
color: "white"
}
})
return(
<View style={styles.container}>
<TopBar page="Home" navigation={navigation}/>
{errorMsg ?
<View style={styles.errorBar}>
<Text style={styles.errorText}>{errorMsg}</Text>
</View>
:
null
}
{location ?
<MapView style={styles.map} initialRegion={{
latitude: location.coords.latitude,
longitude: location.coords.longitude,
latitudeDelta: 0.008,
longitudeDelta: 0.008,
}} showsUserLocation={true} followsUserLocation={true} showsCompass={false}>{Array.from(polyLines.values())}</MapView>
:
<MapView style={styles.map} initialRegion={{
latitude: 44.499789104418404,
longitude: 11.350433839312743,
latitudeDelta: 0.004,
longitudeDelta: 0.004,
}} showsUserLocation={true} followsUserLocation={true} showsCompass={false}>{Array.from(polyLines.values())}</MapView>
}
{showStreetModal ? <StreetModal isVisible={showStreetModal} streetName={selectedStreetName} streetInfos={selectedStreetInfo} onClose={() => {setShowStreetModal(false)}}/> : null}
<StatusBar style="auto"/>
</View>
)
}

export default Home;
Loading

0 comments on commit 4a13833

Please sign in to comment.