1
0
mirror of https://gitlab.com/ceda_ei/sonzai.git synced 2025-10-23 20:20:06 +02:00

Compare commits

..

8 Commits

Author SHA1 Message Date
39b264ea53 Add .gitlab-ci.yml 2020-04-04 22:57:19 +05:30
a6c21ade50 Revert "Enable Hermes"
This reverts commit e151e51eb0.
2020-04-04 19:33:40 +05:30
b89b67bf68 Disallow removing used subjects
Pass timetable as prop in containers.
2020-03-31 14:37:13 +05:30
f9f4f40822 Refactor InputDialog. Disallow empty input. 2020-03-30 13:53:24 +05:30
7425b566d5 Do not show Timetable till subjects are not added. 2020-03-29 13:45:27 +05:30
265485acb1 Auto close snackbar. 2020-03-29 13:39:17 +05:30
e151e51eb0 Enable Hermes 2020-03-28 23:04:56 +05:30
6eadc6739f Replace BottomNavigation with react-native-tab-view.
Squashed commit of the following:

commit e4dd4768b7
Author: Ceda EI <ceda_ei@webionite.com>
Date:   Sat Mar 28 16:45:18 2020 +0530

    Style tab navigation.

commit 6a6795c7fb
Author: Ceda EI <ceda_ei@webionite.com>
Date:   Thu Mar 26 04:05:50 2020 +0530

    Add basic working model using react-native-tab-view.
2020-03-28 18:18:49 +05:30
6 changed files with 109 additions and 16 deletions

34
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,34 @@
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

View File

@@ -9,6 +9,26 @@ import {
export default function InputDialog({ visible, onOK, onDismiss, title, label, placeholder }) {
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 (
<Portal>
<Dialog
@@ -20,13 +40,14 @@ export default function InputDialog({ visible, onOK, onDismiss, title, label, pl
label={label}
placeholder={placeholder}
value={text}
onChangeText={text => setText(text)}
onChangeText={onChangeText}
mode="outlined"
error={error}
/>
</Dialog.Content>
<Dialog.Actions>
<Button onPress={() => {onDismiss(); setText("");}}>Cancel</Button>
<Button onPress={() => {onOK(text); setText("");}}>OK</Button>
<Button onPress={onCancel}>Cancel</Button>
<Button onPress={onDone}>Done</Button>
</Dialog.Actions>
</Dialog>
</Portal>

View File

@@ -5,6 +5,7 @@ import {
Card,
FAB,
Portal,
Snackbar,
Text,
withTheme
} from "react-native-paper";
@@ -16,12 +17,21 @@ import {
import InputDialog from "./InputDialog";
function Subjects({ theme, subjects, addSubject, removeSubject }) {
function Subjects({ theme, subjects, timetable, addSubject, removeSubject }) {
const [ showDialog, setShowDialog ] = useState(false);
const [ snackbar, setSnackbar ] = useState(false);
function onInput(text) {
addSubject(text);
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 (
<Portal.Host><ScrollView style={{ backgroundColor: theme.colors.background }}>
{subjects.length === 0 ?
@@ -43,7 +53,7 @@ function Subjects({ theme, subjects, addSubject, removeSubject }) {
<Card.Title title={subject.name} />
<Card.Actions style={{justifyContent: "flex-end"}}>
<IconButton
onPress={() => removeSubject(subject.id)}
onPress={() => deleteSubject(subject.id)}
icon="delete"
color={theme.colors.primary}
/>
@@ -63,6 +73,7 @@ function Subjects({ theme, subjects, addSubject, removeSubject }) {
large
icon="plus"
onPress={() => setShowDialog(true)}
visible={!snackbar}
style={{
position: "absolute",
margin: 16,
@@ -70,6 +81,16 @@ function Subjects({ theme, subjects, addSubject, removeSubject }) {
bottom: 0,
}}
/>
<Snackbar
visible={snackbar}
onDismiss={() => setSnackbar(false)}
action={{
label: "Dismiss",
onPress: () => setSnackbar(false),
}}
>
Subject is in use in TimeTable.
</Snackbar>
</Portal>
</ScrollView></Portal.Host>
);
@@ -77,6 +98,7 @@ function Subjects({ theme, subjects, addSubject, removeSubject }) {
Subjects.propTypes = {
subjects: PropTypes.array,
timetable: PropTypes.array,
addSubject: PropTypes.func,
removeSubject: PropTypes.func,
theme: PropTypes.object,

View File

@@ -2,6 +2,7 @@ import React from "react";
import PropTypes from "prop-types";
import {
Portal,
Text,
} from "react-native-paper";
import { createStackNavigator } from "@react-navigation/stack";
@@ -12,6 +13,17 @@ const Stack = createStackNavigator();
export default function Timetable({ addTimetableEntry, removeTimetableEntry, timetable, subjects }) {
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 (
<Portal.Host><Stack.Navigator headerMode="none">
<Stack.Screen name="Timetable">

View File

@@ -47,19 +47,22 @@ function AddEntry({addTimetableEntry, days, day, subjects, navigation }) {
}
function submit() {
if (subject.id === null) {
setSnackbar({ visible: true, message: "Missing subject." });
return;
} else if (start === null) {
setSnackbar({ visible: true, message: "Missing start time." });
return;
} else if (end === null) {
setSnackbar({ visible: true, message: "Missing end time." });
return;
} else if (count === 0) {
setSnackbar({ visible: true, message: "Missing count." });
let message = "";
if (subject.id === null)
message = "Missing Subject";
else if (start === null)
message = "Missing start time.";
else if (end === null)
message = "Missing end time.";
else if (count === 0)
message = "Missing count.";
if (message !== "") {
setSnackbar({visible: true, message: message});
setTimeout(() => setSnackbar({ visible: false, message: null }), 2000);
return;
}
addTimetableEntry(day, {
sub_id: subject.id,
count,

View File

@@ -5,6 +5,7 @@ import { addSubject, removeSubject } from "../actions";
const mapStateToProps = state => {
return {
subjects: state.subjects,
timetable: state.timetable,
};
};