mirror of
https://gitlab.com/ceda_ei/sonzai.git
synced 2025-10-23 20:20:06 +02:00
Compare commits
2 Commits
39b264ea53
...
react-nati
Author | SHA1 | Date | |
---|---|---|---|
e4dd4768b7 | |||
6a6795c7fb |
@@ -1,34 +0,0 @@
|
|||||||
stages:
|
|
||||||
- build
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
build:
|
|
||||||
image: reactnativecommunity/react-native-android
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- yarn install
|
|
||||||
- cd android && chmod +x gradlew
|
|
||||||
- ./gradlew assembleRelease
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- android/app/build/outputs/
|
|
||||||
|
|
||||||
|
|
||||||
deploy_tg:
|
|
||||||
image: curlimages/curl
|
|
||||||
stage: deploy
|
|
||||||
script:
|
|
||||||
- >-
|
|
||||||
curl
|
|
||||||
-F chat_id=$TG_CHAT_ID
|
|
||||||
-F document=@android/app/build/outputs/apk/release/app-release.apk
|
|
||||||
-F caption=" <b>Branch</b>: <code>$CI_COMMIT_BRANCH</code>
|
|
||||||
|
|
||||||
<b>Commit</b>: <code>$CI_COMMIT_SHORT_SHA</code>
|
|
||||||
|
|
||||||
<b>Tag(if any)</b>: <code>$CI_COMMIT_TAG</code>
|
|
||||||
|
|
||||||
|
|
||||||
<code>$CI_COMMIT_MESSAGE</code>"
|
|
||||||
-F parse_mode=html
|
|
||||||
https://api.telegram.org/bot${TG_BOT_TOKEN}/sendDocument
|
|
@@ -9,26 +9,6 @@ import {
|
|||||||
|
|
||||||
export default function InputDialog({ visible, onOK, onDismiss, title, label, placeholder }) {
|
export default function InputDialog({ visible, onOK, onDismiss, title, label, placeholder }) {
|
||||||
const [ text, setText ] = useState("");
|
const [ text, setText ] = useState("");
|
||||||
const [ error, setError ] = useState(false);
|
|
||||||
|
|
||||||
function onChangeText(text) {
|
|
||||||
setText(text);
|
|
||||||
setError(text === "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCancel() {
|
|
||||||
onDismiss();
|
|
||||||
setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
function onDone() {
|
|
||||||
if (text === "") {
|
|
||||||
setError(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onOK(text);
|
|
||||||
setText("");
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<Portal>
|
<Portal>
|
||||||
<Dialog
|
<Dialog
|
||||||
@@ -40,14 +20,13 @@ export default function InputDialog({ visible, onOK, onDismiss, title, label, pl
|
|||||||
label={label}
|
label={label}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={text}
|
value={text}
|
||||||
onChangeText={onChangeText}
|
onChangeText={text => setText(text)}
|
||||||
mode="outlined"
|
mode="outlined"
|
||||||
error={error}
|
|
||||||
/>
|
/>
|
||||||
</Dialog.Content>
|
</Dialog.Content>
|
||||||
<Dialog.Actions>
|
<Dialog.Actions>
|
||||||
<Button onPress={onCancel}>Cancel</Button>
|
<Button onPress={() => {onDismiss(); setText("");}}>Cancel</Button>
|
||||||
<Button onPress={onDone}>Done</Button>
|
<Button onPress={() => {onOK(text); setText("");}}>OK</Button>
|
||||||
</Dialog.Actions>
|
</Dialog.Actions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</Portal>
|
</Portal>
|
||||||
|
@@ -5,7 +5,6 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
FAB,
|
FAB,
|
||||||
Portal,
|
Portal,
|
||||||
Snackbar,
|
|
||||||
Text,
|
Text,
|
||||||
withTheme
|
withTheme
|
||||||
} from "react-native-paper";
|
} from "react-native-paper";
|
||||||
@@ -17,21 +16,12 @@ import {
|
|||||||
|
|
||||||
import InputDialog from "./InputDialog";
|
import InputDialog from "./InputDialog";
|
||||||
|
|
||||||
function Subjects({ theme, subjects, timetable, addSubject, removeSubject }) {
|
function Subjects({ theme, subjects, addSubject, removeSubject }) {
|
||||||
const [ showDialog, setShowDialog ] = useState(false);
|
const [ showDialog, setShowDialog ] = useState(false);
|
||||||
const [ snackbar, setSnackbar ] = useState(false);
|
|
||||||
function onInput(text) {
|
function onInput(text) {
|
||||||
addSubject(text);
|
addSubject(text);
|
||||||
setShowDialog(false);
|
setShowDialog(false);
|
||||||
}
|
}
|
||||||
function deleteSubject(id) {
|
|
||||||
if (timetable.reduce((acc, val) => acc.concat(val), []).filter(i => i.sub_id === id).length){
|
|
||||||
setSnackbar(true);
|
|
||||||
setTimeout(() => setSnackbar(false), 2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
removeSubject(id);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<Portal.Host><ScrollView style={{ backgroundColor: theme.colors.background }}>
|
<Portal.Host><ScrollView style={{ backgroundColor: theme.colors.background }}>
|
||||||
{subjects.length === 0 ?
|
{subjects.length === 0 ?
|
||||||
@@ -53,7 +43,7 @@ function Subjects({ theme, subjects, timetable, addSubject, removeSubject }) {
|
|||||||
<Card.Title title={subject.name} />
|
<Card.Title title={subject.name} />
|
||||||
<Card.Actions style={{justifyContent: "flex-end"}}>
|
<Card.Actions style={{justifyContent: "flex-end"}}>
|
||||||
<IconButton
|
<IconButton
|
||||||
onPress={() => deleteSubject(subject.id)}
|
onPress={() => removeSubject(subject.id)}
|
||||||
icon="delete"
|
icon="delete"
|
||||||
color={theme.colors.primary}
|
color={theme.colors.primary}
|
||||||
/>
|
/>
|
||||||
@@ -73,7 +63,6 @@ function Subjects({ theme, subjects, timetable, addSubject, removeSubject }) {
|
|||||||
large
|
large
|
||||||
icon="plus"
|
icon="plus"
|
||||||
onPress={() => setShowDialog(true)}
|
onPress={() => setShowDialog(true)}
|
||||||
visible={!snackbar}
|
|
||||||
style={{
|
style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
margin: 16,
|
margin: 16,
|
||||||
@@ -81,16 +70,6 @@ function Subjects({ theme, subjects, timetable, addSubject, removeSubject }) {
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Snackbar
|
|
||||||
visible={snackbar}
|
|
||||||
onDismiss={() => setSnackbar(false)}
|
|
||||||
action={{
|
|
||||||
label: "Dismiss",
|
|
||||||
onPress: () => setSnackbar(false),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Subject is in use in TimeTable.
|
|
||||||
</Snackbar>
|
|
||||||
</Portal>
|
</Portal>
|
||||||
</ScrollView></Portal.Host>
|
</ScrollView></Portal.Host>
|
||||||
);
|
);
|
||||||
@@ -98,7 +77,6 @@ function Subjects({ theme, subjects, timetable, addSubject, removeSubject }) {
|
|||||||
|
|
||||||
Subjects.propTypes = {
|
Subjects.propTypes = {
|
||||||
subjects: PropTypes.array,
|
subjects: PropTypes.array,
|
||||||
timetable: PropTypes.array,
|
|
||||||
addSubject: PropTypes.func,
|
addSubject: PropTypes.func,
|
||||||
removeSubject: PropTypes.func,
|
removeSubject: PropTypes.func,
|
||||||
theme: PropTypes.object,
|
theme: PropTypes.object,
|
||||||
|
@@ -2,7 +2,6 @@ import React from "react";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import {
|
import {
|
||||||
Portal,
|
Portal,
|
||||||
Text,
|
|
||||||
} from "react-native-paper";
|
} from "react-native-paper";
|
||||||
import { createStackNavigator } from "@react-navigation/stack";
|
import { createStackNavigator } from "@react-navigation/stack";
|
||||||
|
|
||||||
@@ -13,17 +12,6 @@ const Stack = createStackNavigator();
|
|||||||
|
|
||||||
export default function Timetable({ addTimetableEntry, removeTimetableEntry, timetable, subjects }) {
|
export default function Timetable({ addTimetableEntry, removeTimetableEntry, timetable, subjects }) {
|
||||||
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
||||||
if (subjects.length === 0) {
|
|
||||||
return (
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
textAlign: "center",
|
|
||||||
marginTop: 12,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
No Subjects added. Add Subjects first.
|
|
||||||
</Text>);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<Portal.Host><Stack.Navigator headerMode="none">
|
<Portal.Host><Stack.Navigator headerMode="none">
|
||||||
<Stack.Screen name="Timetable">
|
<Stack.Screen name="Timetable">
|
||||||
|
@@ -47,22 +47,19 @@ function AddEntry({addTimetableEntry, days, day, subjects, navigation }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
let message = "";
|
if (subject.id === null) {
|
||||||
if (subject.id === null)
|
setSnackbar({ visible: true, message: "Missing subject." });
|
||||||
message = "Missing Subject";
|
return;
|
||||||
else if (start === null)
|
} else if (start === null) {
|
||||||
message = "Missing start time.";
|
setSnackbar({ visible: true, message: "Missing start time." });
|
||||||
else if (end === null)
|
return;
|
||||||
message = "Missing end time.";
|
} else if (end === null) {
|
||||||
else if (count === 0)
|
setSnackbar({ visible: true, message: "Missing end time." });
|
||||||
message = "Missing count.";
|
return;
|
||||||
|
} else if (count === 0) {
|
||||||
if (message !== "") {
|
setSnackbar({ visible: true, message: "Missing count." });
|
||||||
setSnackbar({visible: true, message: message});
|
|
||||||
setTimeout(() => setSnackbar({ visible: false, message: null }), 2000);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
addTimetableEntry(day, {
|
addTimetableEntry(day, {
|
||||||
sub_id: subject.id,
|
sub_id: subject.id,
|
||||||
count,
|
count,
|
||||||
|
@@ -5,7 +5,6 @@ import { addSubject, removeSubject } from "../actions";
|
|||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
return {
|
return {
|
||||||
subjects: state.subjects,
|
subjects: state.subjects,
|
||||||
timetable: state.timetable,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user