Skip to content

Commit

Permalink
Merge pull request fga-eps-mds#48 from fga-eps-mds/hotfix/#218-tela_r…
Browse files Browse the repository at this point in the history
…otinas

Atualizando EAS UPDATE expo e HotFix #218-tela rotinas
  • Loading branch information
GuiDutra21 authored Dec 4, 2023
2 parents 8f6c020 + bd1c19b commit bb15819
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 171 deletions.
16 changes: 8 additions & 8 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"expo": {
"name": "GEROcuidado",
"slug": "GEROcuidado",
"scheme": "gerocuidado",
"slug": "gerocuidado",
"scheme": "gero.cuidado",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
Expand All @@ -22,8 +22,7 @@
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.gerocuidado.GEROcuidado"
}
},
"web": {
"favicon": "./assets/favicon.png",
Expand All @@ -39,15 +38,16 @@
"router": {
"origin": false
},
"eas": {
"projectId": "1c3cf6d4-5926-44df-b2ce-95faae2d57aa"
"eas": {
"projectId": "7028a81c-adee-41de-91a7-b7e80535a448"
}
},
"runtimeVersion": {
"policy": "appVersion"
},
"updates": {
"url": "https://u.expo.dev/1c3cf6d4-5926-44df-b2ce-95faae2d57aa"
}
"url": "https://u.expo.dev/7028a81c-adee-41de-91a7-b7e80535a448"
},
"owner": "gerocuidado"
}
}
192 changes: 40 additions & 152 deletions src/app/components/CardRotina.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface IProps {
}

export default function CardRotina({ item, index, date }: IProps) {
date.setHours(date.getHours() - 3);
const dateString = date.toISOString().split("T")[0];

const [nameIcon, setnameIcon] = useState("view-grid-outline");
Expand Down Expand Up @@ -70,129 +69,6 @@ export default function CardRotina({ item, index, date }: IProps) {
};

const editar = () => {
const fuso = new Date(item.dataHora).getTimezoneOffset() / 60;

let dataString = new Date(item.dataHora).toISOString();
let dataHoraArray = dataString.split("T");
let horaArray = dataHoraArray[1].split(":");
let dataArray = dataHoraArray[0].split("-");
if (horaArray[0] == "00") {
horaArray[0] = "21";
if (dataArray[2] == "01") {
if (dataArray[1] == "01") {
// caso em que é primeiro de janeiro
dataArray[0] = (parseInt(dataArray[0], 10) - 1).toString();
dataArray[1] = "12";
dataArray[2] = "31";
} else {
// verifica se o mês é março
if (parseInt(dataArray[1], 10) == 3) {
/// verifica se o ano é bissexto
if (parseInt(dataArray[0], 10) % 4 == 0) dataArray[2] = "29";
else dataArray[2] = "28";
} else {
// verifica os meses de janeiro a agosto
if (parseInt(dataArray[1], 10) <= 8) {
if (parseInt(dataArray[1], 10) % 2 == 0) dataArray[2] = "31";
else {
dataArray[2] = "30";
}
} else {
// verifica os meses de setembro a dezembro
if (parseInt(dataArray[1], 10) % 2 == 0) dataArray[2] = "30";
else {
dataArray[2] = "31";
}
}
}
dataArray[1] = (parseInt(dataArray[1], 10) - 1).toString();
dataArray[1] = dataArray[1].padStart(2, "0");
}
} else {
dataArray[2] = (parseInt(dataArray[2], 10) - 1).toString();
dataArray[2] = dataArray[2].padStart(2, "0");
}
} else if (horaArray[0] == "01") {
horaArray[0] = "22";
if (dataArray[2] == "01") {
if (dataArray[1] == "01") {
// caso em que é primeiro de janeiro
dataArray[0] = (parseInt(dataArray[0], 10) - 1).toString();
dataArray[1] = "12";
dataArray[2] = "31";
} else {
// verifica se o mês é março
if (parseInt(dataArray[1], 10) == 3) {
/// verifica se o ano é bissexto
if (parseInt(dataArray[0], 10) % 4 == 0) dataArray[2] = "29";
else dataArray[2] = "28";
} else {
// verifica os meses de janeiro a agosto
if (parseInt(dataArray[1], 10) <= 8) {
if (parseInt(dataArray[1], 10) % 2 == 0) dataArray[2] = "31";
else {
dataArray[2] = "30";
}
} else {
// verifica os meses de setembro a dezembro
if (parseInt(dataArray[1], 10) % 2 == 0) dataArray[2] = "30";
else {
dataArray[2] = "31";
}
}
}
dataArray[1] = (parseInt(dataArray[1], 10) - 1).toString();
dataArray[1] = dataArray[1].padStart(2, "0");
}
} else {
dataArray[2] = (parseInt(dataArray[2], 10) - 1).toString();
dataArray[2] = dataArray[2].padStart(2, "0");
}
} else if (horaArray[0] == "02") {
horaArray[0] = "23";
if (dataArray[2] == "01") {
if (dataArray[1] == "01") {
// caso em que é primeiro de janeiro
dataArray[0] = (parseInt(dataArray[0], 10) - 1).toString();
dataArray[1] = "12";
dataArray[2] = "31";
} else {
// verifica se o mês é março
if (parseInt(dataArray[1], 10) == 3) {
/// verifica se o ano é bissexto
if (parseInt(dataArray[0], 10) % 4 == 0) dataArray[2] = "29";
else dataArray[2] = "28";
} else {
// verifica os meses de janeiro a agosto
if (parseInt(dataArray[1], 10) <= 8) {
if (parseInt(dataArray[1], 10) % 2 == 0) dataArray[2] = "31";
else {
dataArray[2] = "30";
}
} else {
// verifica os meses de setembro a dezembro
if (parseInt(dataArray[1], 10) % 2 == 0) dataArray[2] = "30";
else {
dataArray[2] = "31";
}
}
}
dataArray[1] = (parseInt(dataArray[1], 10) - 1).toString();
dataArray[1] = dataArray[1].padStart(2, "0");
}
} else {
dataArray[2] = (parseInt(dataArray[2], 10) - 1).toString();
dataArray[2] = dataArray[2].padStart(2, "0");
}
} else horaArray[0] = (parseInt(horaArray[0], 10) - fuso).toString();
horaArray[0] = horaArray[0].padStart(2, "0");
let dataString2 = dataArray.join("-");
let horaString = horaArray.join(":");
dataHoraArray[1] = horaString;
dataHoraArray[0] = dataString2;
let dataHoraString = dataHoraArray.join("T");
item.dataHora = dataHoraString;

const params = { ...item, id: item.id };

router.push({
Expand All @@ -201,45 +77,57 @@ export default function CardRotina({ item, index, date }: IProps) {
});
};

function ajustaHoraTexto() {
let dataHora = new Date(item.dataHora).toISOString();
if (dataHora[23] == "Z") {
let dataHoraSemUltimo = dataHora.slice(0, -1);
console.log(dataHoraSemUltimo);
item.dataHora = dataHoraSemUltimo;
}
}

useEffect(() => handleIcon());
useEffect(() => getToken());

useEffect(() => ajustaHoraTexto(), []);

return (
<>
<Text style = {styles.hora}>{new Date(item.dataHora).getHours().toString().padStart(2, "0")}:{new Date(item.dataHora).getMinutes().toString().padStart(2, "0")}</Text>

<Pressable
onPress={editar}
style={[
styles.container,
{ backgroundColor: index % 2 == 0 ? "#B4FFE8" : "#FFC6C6" },
]}
>
<View style={styles.icon}>
<Icon size={30} name={nameIcon}></Icon>
</View>
<View style={styles.texts}>
<Text style={styles.title}>{item.titulo}</Text>
<Text style={styles.description}>{item.descricao}</Text>
</View>
<Text style={styles.hora}>
{new Date(item.dataHora).getHours().toString().padStart(2, "0")}:
{new Date(item.dataHora).getMinutes().toString().padStart(2, "0")}
</Text>
<Pressable
onPress={() => debounceConcluido(!check)}
style={styles.checkBox}
testID="checkbox"
onPress={editar}
style={[
styles.container,
{ backgroundColor: index % 2 == 0 ? "#B4FFE8" : "#FFC6C6" },
]}
>
<View style={styles.icon}>
<Icon size={30} name={nameIcon}></Icon>
</View>
<View style={styles.texts}>
<Text style={styles.title}>{item.titulo}</Text>
<Text style={styles.description}>{item.descricao}</Text>
</View>
<Pressable
onPress={() => debounceConcluido(!check)}
style={styles.checkBox}
testID="checkbox"
>
{check && <Icon name="check" size={30}></Icon>}
{check && <Icon name="check" size={30}></Icon>}
</Pressable>
</Pressable>
</Pressable>
</>
);
}

const styles = StyleSheet.create({
hora:{
fontSize:18,
fontWeight:"300",
marginLeft:20,
marginTop:10,
hora: {
fontSize: 18,
fontWeight: "300",
marginLeft: 20,
marginTop: 10,
},

container: {
Expand Down Expand Up @@ -284,4 +172,4 @@ const styles = StyleSheet.create({
justifyContent: "center",
alignItems: "center",
},
});
});
29 changes: 18 additions & 11 deletions src/app/private/tabs/rotinas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import {
} from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { router } from "expo-router";
import { IOrder, IRotina, IRotinaFilter } from "../../interfaces/rotina.interface";
import {
IOrder,
IRotina,
IRotinaFilter,
} from "../../interfaces/rotina.interface";
import CardRotina from "../../components/CardRotina";
import { getAllRotina } from "../../services/rotina.service";
import Toast from "react-native-toast-message";
Expand All @@ -35,8 +39,8 @@ export default function Rotinas() {
const [selectedDate, setSelectedDate] = useState(moment());
const order: IOrder = {
column: "dataHora",
dir: "ASC"
}
dir: "ASC",
};

const datesWhitelist = [
{
Expand Down Expand Up @@ -101,7 +105,7 @@ export default function Rotinas() {
dataHora: dataHora.toISOString(),
};

getAllRotina(rotinaFilter,order)
getAllRotina(rotinaFilter, order)
.then((response) => {
const newRotinas = response.data as IRotina[];
const filteredRotinas = newRotinas.filter((rotina) => {
Expand Down Expand Up @@ -207,9 +211,12 @@ export default function Rotinas() {
)}
{rotinas.length === 0 && (
<View>
<Text style={styles.semRotinas}>{`Você ainda não tem nenhuma rotina cadastrada no dia ${moment(selectedDate).format('DD/MM')}`}</Text>
<Text
style={styles.semRotinas}
>{`Você ainda não tem nenhuma rotina cadastrada no dia ${moment(
selectedDate,
).format("DD/MM")}`}</Text>
</View>

)}
</View>
)}
Expand Down Expand Up @@ -275,10 +282,10 @@ const styles = StyleSheet.create({
width: Dimensions.get("window").width,
height: Dimensions.get("window").height - 315,
},
semRotinas:{
fontSize:35,
opacity:0.3,
textAlign:"center",
marginTop:"35%",
semRotinas: {
fontSize: 35,
opacity: 0.3,
textAlign: "center",
marginTop: "35%",
},
});

0 comments on commit bb15819

Please sign in to comment.