Compare commits
No commits in common. "master" and "v1.0-alpha" have entirely different histories.
master
...
v1.0-alpha
30
App.tsx
30
App.tsx
|
|
@ -15,16 +15,7 @@ import TitleBar from './components/TitleBar';
|
|||
import db from './lib/client';
|
||||
|
||||
const findTheme = async () => {
|
||||
const res = await db.from("settings").select().eq({id: 'theme'})
|
||||
let theme = 'auto'
|
||||
if (!res.error){
|
||||
if (res.data.length > 0){
|
||||
theme = res.data[0].value
|
||||
}else{
|
||||
const res = await db.from('settings').insert({id: 'theme', value: 'auto'})
|
||||
console.log(res)
|
||||
}
|
||||
}
|
||||
const theme = await AsyncStorage.getItem('theme');
|
||||
if(theme === 'dark') {
|
||||
return dark;
|
||||
} else if(theme === 'light') {
|
||||
|
|
@ -44,13 +35,7 @@ const findTheme = async () => {
|
|||
}
|
||||
|
||||
const findThemeMode = async () => {
|
||||
const res = await db.from("settings").select().eq({id:'theme'})
|
||||
let theme = 'auto'
|
||||
if (!res.error){
|
||||
if (res.data.length > 0){
|
||||
theme = res.data[0].value
|
||||
}
|
||||
}
|
||||
const theme = await AsyncStorage.getItem('theme');
|
||||
if (theme){
|
||||
return theme;
|
||||
} else {
|
||||
|
|
@ -70,6 +55,7 @@ export default function App() {
|
|||
const [others, setOthers] = useState([]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const theme = await findTheme();
|
||||
|
|
@ -111,22 +97,22 @@ export default function App() {
|
|||
case 'dark':
|
||||
setThemeMode('dark');
|
||||
setTheme(dark);
|
||||
await db.from("settings").update({value: 'dark'}).eq({id: 'theme'})
|
||||
await AsyncStorage.setItem('theme', 'dark');
|
||||
break;
|
||||
case 'light':
|
||||
setThemeMode('light');
|
||||
setTheme(light);
|
||||
await db.from('settings').update({value: 'light'}).eq({id: 'theme'})
|
||||
await AsyncStorage.setItem('theme', 'light');
|
||||
break;
|
||||
case 'solorizedDark':
|
||||
setThemeMode('solorizedDark');
|
||||
setTheme(solorizedDark);
|
||||
await db.from('settings').update({value: 'solorizedDark'}).eq({id: 'theme'})
|
||||
await AsyncStorage.setItem('theme', 'solorizedDark');
|
||||
break;
|
||||
case 'oled':
|
||||
setThemeMode('oled');
|
||||
setTheme(oled);
|
||||
await db.from('settings').update({value: 'oled'}).eq({id: 'theme'})
|
||||
await AsyncStorage.setItem('theme', 'oled');
|
||||
break;
|
||||
default:
|
||||
setThemeMode('auto');
|
||||
|
|
@ -136,7 +122,7 @@ export default function App() {
|
|||
} else {
|
||||
setTheme(light);
|
||||
}
|
||||
await db.from('settings').update({id: 'theme', value: 'auto'}).eq({id: 'theme'})
|
||||
await AsyncStorage.setItem('theme', "auto");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# Tali
|
||||
|
||||
React Native app to keep track of movies, tv shows and other interesting stuff you want to watch or do. Gone are the days of using an unorganized note app to keep track of what you want to or already have watched.
|
||||
|
||||

|
||||
|
|
|
|||
2
app.json
2
app.json
|
|
@ -9,7 +9,7 @@
|
|||
"splash": {
|
||||
"image": "./assets/splash.png",
|
||||
"resizeMode": "contain",
|
||||
"backgroundColor": "#000000"
|
||||
"backgroundColor": "#ffffff"
|
||||
},
|
||||
"assetBundlePatterns": [
|
||||
"**/*"
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 17 KiB |
BIN
assets/icon.png
BIN
assets/icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 46 KiB |
|
|
@ -1,5 +1,5 @@
|
|||
import nasa from './nasa';
|
||||
import { MovieSchema, ShowSchema, TestTableShema, OtherSchema, CategorySchema, SettingSchema} from './schemas';
|
||||
import { MovieSchema, ShowSchema, TestTableShema, OtherSchema, CategorySchema} from './schemas';
|
||||
|
||||
|
||||
const tableSchemas = {
|
||||
|
|
@ -7,7 +7,7 @@ const tableSchemas = {
|
|||
shows: ShowSchema,
|
||||
others: OtherSchema,
|
||||
categories: CategorySchema,
|
||||
settings: SettingSchema ,
|
||||
test: TestTableShema,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
12
lib/nasa.ts
12
lib/nasa.ts
|
|
@ -55,15 +55,6 @@ export default class nasa{
|
|||
let table:any = await AsyncStorage.getItem(this.#tableName);
|
||||
if(table){
|
||||
table = JSON.parse(table);
|
||||
console.log(newData)
|
||||
if ('id' in newData){
|
||||
table.forEach((s:any)=>{
|
||||
if(s.id === newData.id){
|
||||
this.error = 'Id already exists';
|
||||
return this
|
||||
}
|
||||
});
|
||||
}else{
|
||||
let maxId = 0;
|
||||
table.forEach((s:any)=>{
|
||||
if(s.id > maxId){
|
||||
|
|
@ -71,7 +62,6 @@ export default class nasa{
|
|||
}
|
||||
});
|
||||
newData.id = maxId + 1;
|
||||
}
|
||||
const {data, error} = await this.#tableSchemas[this.#tableName].safeParse(newData);
|
||||
if(error){
|
||||
this.error = error.message;
|
||||
|
|
@ -82,9 +72,7 @@ export default class nasa{
|
|||
this.data = data
|
||||
return this;
|
||||
}else{
|
||||
if (!('id' in newData)){
|
||||
newData.id = 1;
|
||||
}
|
||||
const {data, error} = await this.#tableSchemas[this.#tableName].safeParse(newData);
|
||||
if(error){
|
||||
this.error = error.message;
|
||||
|
|
|
|||
|
|
@ -89,9 +89,3 @@ export const TestTableShema = z.object({
|
|||
test: z.string(),
|
||||
}).strict();
|
||||
export type TestTable = z.infer<typeof TestTableShema>;
|
||||
|
||||
export const SettingSchema = z.object({
|
||||
id: z.string(),
|
||||
value: z.string().or(z.boolean().or(z.number()))
|
||||
})
|
||||
export type SettingsTable = z.infer<typeof SettingSchema>
|
||||
|
|
@ -244,12 +244,6 @@ const style = (theme:any) => {
|
|||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
delete: {
|
||||
color: 'red',
|
||||
textAlign: 'center',
|
||||
marginTop: 10,
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -463,8 +457,8 @@ function EditMovieModal({editMovie, setEdditMovie, update, theme, remove}:any){
|
|||
value={editMovie.notes}
|
||||
/>
|
||||
</View>
|
||||
<View style={{...st.row, width: '90%', marginLeft: 20, justifyContent: "center"}}>
|
||||
<Text style={st.delete} onLongPress={()=>remove(editMovie.id)}>long press to delete</Text>
|
||||
<View style={{...st.row, width: '90%', marginLeft: 20, justifyContent: "flex-start"}}>
|
||||
<Button title="delete" onPress={()=>remove(editMovie.id)} theme={theme} style={{backgroundColor: theme.danger, paddingHorizontal: 25, margin: 0}}/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -266,11 +266,6 @@ const style = (theme:any) => {
|
|||
paddingHorizontal: 10,
|
||||
padding: 5,
|
||||
},
|
||||
delete: {
|
||||
color: 'red',
|
||||
textAlign: 'center',
|
||||
marginTop: 10,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -525,8 +520,8 @@ function EditshowModal({editOther, setEditOther, update, theme, remove, selCat}:
|
|||
value={editOther.notes}
|
||||
/>
|
||||
</View>
|
||||
<View style={{...st.row, width: '90%', marginLeft: 20, justifyContent: "center"}}>
|
||||
<Text style={st.delete} onLongPress={()=>remove(editor.id)}>long press to delete</Text>
|
||||
<View style={{...st.row, width: '90%', marginLeft: 20, justifyContent: "flex-start"}}>
|
||||
<Button title="delete" onPress={()=>remove(editOther.id)} theme={theme} style={{backgroundColor: theme.danger, paddingHorizontal: 25, margin: 0,}}/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
|
|
|||
|
|
@ -58,11 +58,10 @@ export default function OtherCat({theme, otherCategories, setOtherCategories, se
|
|||
}
|
||||
|
||||
const handleDelete = async () => {
|
||||
let res = await db.from('categories').delete().eq({id: newCat.id});
|
||||
const res = await db.from('categories').delete().eq({id: newCat.id});
|
||||
if (res.data) {
|
||||
setOtherCategories([...otherCategories.filter((c:any) => c.id !== newCat.id)])
|
||||
}
|
||||
res = await db.from('others').delete().eq({category: newCat.id})
|
||||
setModalVisible(false);
|
||||
setNewCat({title: '', showEpisodes: false});
|
||||
setEditPop(false);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ export default function Settings({theme, changeTheme, themeMode, clearAll, resyn
|
|||
const handleExport = async () => {
|
||||
const dataToExport = await db.fileExport()
|
||||
const data = JSON.stringify(dataToExport);
|
||||
// export dataToExport in json format to a file using react-native-fs
|
||||
if (Platform.OS === 'android') {
|
||||
const permissions = await StorageAccessFramework.requestDirectoryPermissionsAsync();
|
||||
if (permissions.granted) {
|
||||
// Gets SAF URI from response
|
||||
const uri = permissions.directoryUri;
|
||||
// Writes file to SAF URI
|
||||
await StorageAccessFramework.createFileAsync(uri, 'tali', 'application/json').then(async (fileUri) => {
|
||||
await StorageAccessFramework.writeAsStringAsync(fileUri, data, { encoding: FileSystem.EncodingType.UTF8 }).catch((err) => console.log(err))
|
||||
})
|
||||
|
|
@ -101,8 +104,8 @@ export default function Settings({theme, changeTheme, themeMode, clearAll, resyn
|
|||
/>
|
||||
</View>
|
||||
<View style={{...st.row, zIndex:0}}>
|
||||
<Button theme={theme} title="Export" onPress={handleExport} style={{padding:30, flex:1}}/>
|
||||
<Button theme={theme} title="Import" onPress={handleImport} style={{padding:30, flex:1}}/>
|
||||
<Button theme={theme} title="Export Data" onPress={handleExport} style={{padding:30, flex:1}}/>
|
||||
<Button theme={theme} title="Import Data" onPress={handleImport} style={{padding:30, flex:1}}/>
|
||||
</View>
|
||||
<View style={{...st.row, zIndex:0}}>
|
||||
<Button theme={theme} title="Delete All Data" onPress={() => setDeleteAllModal(true)} style={{width:'100%'}}/>
|
||||
|
|
|
|||
|
|
@ -265,11 +265,6 @@ const style = (theme:any) => {
|
|||
paddingHorizontal: 10,
|
||||
padding: 5,
|
||||
},
|
||||
delete: {
|
||||
color: 'red',
|
||||
textAlign: 'center',
|
||||
marginTop: 10,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -522,8 +517,8 @@ function EditshowModal({editShow, setEditShow, update, theme, remove}:any){
|
|||
value={editShow.notes}
|
||||
/>
|
||||
</View>
|
||||
<View style={{...st.row, width: '90%', marginLeft: 20, justifyContent: "center"}}>
|
||||
<Text style={st.delete} onLongPress={()=>remove(editShow.id)}>long press to delete</Text>
|
||||
<View style={{...st.row, width: '90%', marginLeft: 20, justifyContent: "flex-start"}}>
|
||||
<Button title="delete" onPress={()=>remove(editShow.id)} theme={theme} style={{backgroundColor: theme.danger, paddingHorizontal: 25, margin: 0,}}/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
|
|
|||
Loading…
Reference in New Issue