Merge pull request 'location-menu' (#5) from location-menu into master
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build React Native Web App (push) Successful in 10m33s
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build React Native Web App (push) Successful in 10m33s
Reviewed-on: https://www.kaiser-labs.com/public/pogdark-app/pulls/5
This commit is contained in:
commit
e102d1ccb7
@ -4,9 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
157
LICENSE
Normal file
157
LICENSE
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
# Attribution-NonCommercial-NoDerivatives 4.0 International
|
||||||
|
|
||||||
|
> *Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.*
|
||||||
|
>
|
||||||
|
> ### Using Creative Commons Public Licenses
|
||||||
|
>
|
||||||
|
> Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||||
|
>
|
||||||
|
> * __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
|
||||||
|
>
|
||||||
|
> * __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
|
||||||
|
|
||||||
|
## Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License
|
||||||
|
|
||||||
|
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||||
|
|
||||||
|
### Section 1 – Definitions.
|
||||||
|
|
||||||
|
a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||||
|
|
||||||
|
b. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||||
|
|
||||||
|
e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||||
|
|
||||||
|
f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||||
|
|
||||||
|
h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||||
|
|
||||||
|
i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||||
|
|
||||||
|
h. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
|
||||||
|
|
||||||
|
i. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||||
|
|
||||||
|
j. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||||
|
|
||||||
|
k. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||||
|
|
||||||
|
l. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||||
|
|
||||||
|
### Section 2 – Scope.
|
||||||
|
|
||||||
|
a. ___License grant.___
|
||||||
|
|
||||||
|
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||||
|
|
||||||
|
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
||||||
|
|
||||||
|
B. produce and reproduce, but not Share, Adapted Material for NonCommercial purposes only.
|
||||||
|
|
||||||
|
2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||||
|
|
||||||
|
3. __Term.__ The term of this Public License is specified in Section 6(a).
|
||||||
|
|
||||||
|
4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||||
|
|
||||||
|
5. __Downstream recipients.__
|
||||||
|
|
||||||
|
A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||||
|
|
||||||
|
B. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||||
|
|
||||||
|
6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||||
|
|
||||||
|
b. ___Other rights.___
|
||||||
|
|
||||||
|
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||||
|
|
||||||
|
2. Patent and trademark rights are not licensed under this Public License.
|
||||||
|
|
||||||
|
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
|
||||||
|
|
||||||
|
### Section 3 – License Conditions.
|
||||||
|
|
||||||
|
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||||
|
|
||||||
|
a. ___Attribution.___
|
||||||
|
|
||||||
|
1. If You Share the Licensed Material, You must:
|
||||||
|
|
||||||
|
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||||
|
|
||||||
|
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||||
|
|
||||||
|
ii. a copyright notice;
|
||||||
|
|
||||||
|
iii. a notice that refers to this Public License;
|
||||||
|
|
||||||
|
iv. a notice that refers to the disclaimer of warranties;
|
||||||
|
|
||||||
|
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||||
|
|
||||||
|
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||||
|
|
||||||
|
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||||
|
|
||||||
|
For the avoidance of doubt, You do not have permission under this Public License to Share Adapted Material.
|
||||||
|
|
||||||
|
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||||
|
|
||||||
|
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||||
|
|
||||||
|
### Section 4 – Sui Generis Database Rights.
|
||||||
|
|
||||||
|
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||||
|
|
||||||
|
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only and provided You do not Share Adapted Material;
|
||||||
|
|
||||||
|
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
|
||||||
|
|
||||||
|
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||||
|
|
||||||
|
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||||
|
|
||||||
|
### Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
||||||
|
|
||||||
|
a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
|
||||||
|
|
||||||
|
b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
|
||||||
|
|
||||||
|
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||||
|
|
||||||
|
### Section 6 – Term and Termination.
|
||||||
|
|
||||||
|
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||||
|
|
||||||
|
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||||
|
|
||||||
|
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||||
|
|
||||||
|
2. upon express reinstatement by the Licensor.
|
||||||
|
|
||||||
|
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||||
|
|
||||||
|
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||||
|
|
||||||
|
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||||
|
|
||||||
|
### Section 7 – Other Terms and Conditions.
|
||||||
|
|
||||||
|
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||||
|
|
||||||
|
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||||
|
|
||||||
|
### Section 8 – Interpretation.
|
||||||
|
|
||||||
|
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||||
|
|
||||||
|
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||||
|
|
||||||
|
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||||
|
|
||||||
|
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||||
|
|
||||||
|
> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||||
|
>
|
||||||
|
> Creative Commons may be contacted at [creativecommons.org](http://creativecommons.org).
|
@ -13,3 +13,11 @@
|
|||||||
```bash
|
```bash
|
||||||
npm run web
|
npm run web
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Currently we're not looking for contributors.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This work is licensed under [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/)
|
||||||
|
54
app/Nav.tsx
54
app/Nav.tsx
@ -1,54 +0,0 @@
|
|||||||
import {Appbar, Portal, Button, Dialog, Menu, Text, useTheme} from "react-native-paper";
|
|
||||||
import {Image, StyleSheet, View} from "react-native";
|
|
||||||
import React, {useState} from "react";
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
logoContainer: { flex: 1, alignItems: "center" },
|
|
||||||
logo: { width: 150, height: 75, resizeMode: "contain" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const Nav = ({ toggleProfile }: { toggleProfile: () => void; }) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const [aboutVisible, setAboutVisible] = useState(false);
|
|
||||||
const [menuVisible, setMenuVisible] = useState(false);
|
|
||||||
const [menuAnchor, setMenuAnchor] = useState<{ x: number; y: number } | null>(null);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={{ backgroundColor: theme.colors.background }}>
|
|
||||||
<Appbar.Header style={{ backgroundColor: theme.colors.primary }}>
|
|
||||||
<View>
|
|
||||||
<Menu visible={menuVisible} onDismiss={() => setMenuVisible(false)} anchor={menuAnchor}>
|
|
||||||
<Menu.Item onPress={() => { setMenuVisible(false); setAboutVisible(true);}} title="About Us"/>
|
|
||||||
</Menu>
|
|
||||||
<Appbar.Action icon="menu"
|
|
||||||
onPressIn={(event) => {
|
|
||||||
setMenuAnchor({ x: event.nativeEvent.pageX, y: event.nativeEvent.pageY + 40 });
|
|
||||||
setMenuVisible(true);
|
|
||||||
}}
|
|
||||||
iconColor={theme.colors.inversePrimary} />
|
|
||||||
</View>
|
|
||||||
<View style={styles.logoContainer}>
|
|
||||||
<Image source={require("../assets/images/pogdark_logo.png")} style={styles.logo} />
|
|
||||||
</View>
|
|
||||||
<Appbar.Action icon="pencil" onPress={toggleProfile} iconColor={ theme.colors.inversePrimary } />
|
|
||||||
</Appbar.Header>
|
|
||||||
<Portal>
|
|
||||||
<Dialog visible={aboutVisible} onDismiss={() => setAboutVisible(false)} style={{ backgroundColor: theme.colors.background }}>
|
|
||||||
<Dialog.Title style={{ color: theme.colors.onBackground, textAlign: 'center' }}>About Us</Dialog.Title>
|
|
||||||
<Dialog.Content>
|
|
||||||
<Text style={{ color: theme.colors.onSurface, textAlign: 'justify' }}>
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam auctor, nisl nec laoreet luctus, felis sapien facilisis augue, at tristique enim turpis nec turpis. Donec convallis justo vel mi consectetur, at pulvinar justo dictum. Mauris vulputate dapibus neque, sed sagittis libero dapibus eu. Integer nec mi at quam cursus suscipit sed et tortor.
|
|
||||||
</Text>
|
|
||||||
</Dialog.Content>
|
|
||||||
<Dialog.Actions style={{ justifyContent: "center" }}>
|
|
||||||
<Button onPress={() => setAboutVisible(false)} mode="contained" style={{ backgroundColor: theme.colors.secondary }} labelStyle={{ color: theme.colors.onPrimary }}>
|
|
||||||
Close
|
|
||||||
</Button>
|
|
||||||
</Dialog.Actions>
|
|
||||||
</Dialog>
|
|
||||||
</Portal>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Nav;
|
|
@ -1,127 +0,0 @@
|
|||||||
import React, { useEffect } from 'react';
|
|
||||||
import { Platform } from "react-native";
|
|
||||||
import { Button, TextInput, Dialog, Portal, Avatar, useTheme } from "react-native-paper";
|
|
||||||
import { Asset } from 'expo-asset';
|
|
||||||
import * as FileSystem from 'expo-file-system';
|
|
||||||
import * as ImagePicker from "expo-image-picker";
|
|
||||||
|
|
||||||
interface ProfileScreenProps {
|
|
||||||
visible: boolean;
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
setName: (name: string) => void;
|
|
||||||
image: string;
|
|
||||||
setImage: (image: string) => void;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ProfileScreen: React.FC<ProfileScreenProps> = ({ visible, name, setName, image, setImage, onClose }) => {
|
|
||||||
const { colors } = useTheme();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const loadDefaultImage = async () => {
|
|
||||||
const asset = Asset.fromModule(require("../assets/images/default_profile_image.png"));
|
|
||||||
await asset.downloadAsync();
|
|
||||||
if (Platform.OS === 'web') {
|
|
||||||
const response = await fetch(asset.uri);
|
|
||||||
const blob = await response.blob();
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onloadend = () => {
|
|
||||||
const base64String = reader.result?.toString().replace(/^data:.+;base64,/, '');
|
|
||||||
resolve(base64String);
|
|
||||||
if (typeof base64String == "string") {
|
|
||||||
setImage(base64String);
|
|
||||||
} else {
|
|
||||||
throw new Error("Failed to load asset.");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(blob);
|
|
||||||
});
|
|
||||||
} else if (asset.uri) {
|
|
||||||
const base64 = await FileSystem.readAsStringAsync(asset.uri, { encoding: FileSystem.EncodingType.Base64 });
|
|
||||||
setImage(base64);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadImage = async () => {
|
|
||||||
if (!image) {
|
|
||||||
await loadDefaultImage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
loadImage().then(r => null);
|
|
||||||
}, [image]);
|
|
||||||
|
|
||||||
const pickImage = async () => {
|
|
||||||
let result = await ImagePicker.launchImageLibraryAsync({ base64: true });
|
|
||||||
if (!result.canceled && result.assets.length > 0) {
|
|
||||||
setImage(result.assets[0].base64 || image);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Portal>
|
|
||||||
<Dialog visible={visible} onDismiss={onClose} style={{ backgroundColor: colors.background }}>
|
|
||||||
<Dialog.Title style={{ color: colors.onBackground, textAlign: 'center' }}>Edit Your Profile</Dialog.Title>
|
|
||||||
<Dialog.Content>
|
|
||||||
<Avatar.Image
|
|
||||||
size={100}
|
|
||||||
source={image ? { uri: `data:image/png;base64,${image}` } : require("../assets/images/default_profile_image.png")}
|
|
||||||
style={{ alignSelf: 'center', marginBottom: 15 }}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
onPress={pickImage}
|
|
||||||
mode="contained"
|
|
||||||
style={{ backgroundColor: colors.primary, marginBottom: 10 }}
|
|
||||||
labelStyle={{ color: colors.onPrimary }}
|
|
||||||
>
|
|
||||||
Change Profile Picture
|
|
||||||
</Button>
|
|
||||||
<TextInput
|
|
||||||
label="Your Pet's Name"
|
|
||||||
mode="outlined"
|
|
||||||
value={name}
|
|
||||||
onChangeText={setName}
|
|
||||||
style={{ marginBottom: 15, backgroundColor: colors.surface }}
|
|
||||||
placeholderTextColor={colors.onSurface}
|
|
||||||
theme={{ colors: { text: colors.onSurface } }}
|
|
||||||
/>
|
|
||||||
</Dialog.Content>
|
|
||||||
<Dialog.Actions>
|
|
||||||
<Button
|
|
||||||
onPress={onClose}
|
|
||||||
mode="contained"
|
|
||||||
style={{ backgroundColor: colors.secondary }}
|
|
||||||
labelStyle={{ color: colors.onPrimary }}>Save</Button>
|
|
||||||
</Dialog.Actions>
|
|
||||||
</Dialog>
|
|
||||||
</Portal>
|
|
||||||
/*
|
|
||||||
<Portal>
|
|
||||||
<Dialog visible={visible} onDismiss={onClose} style={{ backgroundColor: colors.background }}>
|
|
||||||
<Dialog.Title>Edit Your Profile</Dialog.Title>
|
|
||||||
<Dialog.Content>
|
|
||||||
<Avatar.Image
|
|
||||||
size={100}
|
|
||||||
source={image ? { uri: `data:image/png;base64,${image}` } : require("../assets/images/default_profile_image.png")}
|
|
||||||
style={{ alignSelf: 'center', marginBottom: 15 }}
|
|
||||||
/>
|
|
||||||
<Button onPress={pickImage} mode="contained" style={{ backgroundColor: colors.primary, marginBottom: 10 }}>Change Profile Picture</Button>
|
|
||||||
<TextInput
|
|
||||||
label="Your Pet's Name"
|
|
||||||
mode="outlined"
|
|
||||||
value={name}
|
|
||||||
onChangeText={setName}
|
|
||||||
style={{ marginBottom: 15, backgroundColor: colors.surface, color: colors.primary }}
|
|
||||||
/>
|
|
||||||
</Dialog.Content>
|
|
||||||
<Dialog.Actions>
|
|
||||||
<Button onPress={onClose} mode="contained" style={{ backgroundColor: colors.secondary }}>Save</Button>
|
|
||||||
</Dialog.Actions>
|
|
||||||
</Dialog>
|
|
||||||
</Portal>
|
|
||||||
*/
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ProfileScreen;
|
|
@ -1,260 +0,0 @@
|
|||||||
import React, { useEffect, useState, useRef } from "react";
|
|
||||||
import useWebSocket from "react-use-websocket";
|
|
||||||
import axios from "axios";
|
|
||||||
import { Animated, Easing, ImageBackground, StyleSheet, View } from "react-native";
|
|
||||||
import { Avatar, List, Button, useTheme, } from "react-native-paper";
|
|
||||||
|
|
||||||
export const API_URL = process.env.EXPO_PUBLIC_API_URL;
|
|
||||||
export const WS_URL = process.env.EXPO_PUBLIC_WS_URL;
|
|
||||||
|
|
||||||
interface Message {
|
|
||||||
Id: string;
|
|
||||||
Name: string;
|
|
||||||
Image: string;
|
|
||||||
Status: string;
|
|
||||||
Timestamp: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
container: { flex: 1, alignItems: "stretch" },
|
|
||||||
listContainer: { flex: 1, width: "100%", backgroundColor: 'transparent' },
|
|
||||||
listSubheader: {
|
|
||||||
fontSize: 18, // Larger text
|
|
||||||
textAlign: "center", // Center the text
|
|
||||||
fontWeight: "bold", // Make it more distinct
|
|
||||||
marginBottom: 10, // Add spacing below
|
|
||||||
zIndex: 0,
|
|
||||||
},
|
|
||||||
listWrapper: { flex: 1, padding: 5 },
|
|
||||||
listRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
alignItems: "flex-start", // Aligns subheaders properly
|
|
||||||
paddingHorizontal: 10, // Adds some spacing
|
|
||||||
},
|
|
||||||
listColumn: { flex: 1, paddingHorizontal: 5, zIndex: 1},
|
|
||||||
buttonContainer: {
|
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
alignSelf: "stretch",
|
|
||||||
paddingHorizontal: 10,
|
|
||||||
paddingBottom: 20,
|
|
||||||
},
|
|
||||||
actionButton: {
|
|
||||||
flex: 1,
|
|
||||||
marginHorizontal: 5,
|
|
||||||
},
|
|
||||||
card: {
|
|
||||||
marginVertical: 5,
|
|
||||||
elevation: 4, // Android shadow
|
|
||||||
shadowColor: "#000", // iOS shadow
|
|
||||||
shadowOffset: { width: 0, height: 2 },
|
|
||||||
shadowOpacity: 0.2,
|
|
||||||
shadowRadius: 4,
|
|
||||||
borderRadius: 10,
|
|
||||||
},
|
|
||||||
imageBackground: {
|
|
||||||
position: "absolute", // Allows child elements to layer on top
|
|
||||||
width: "100%", // Ensure full coverage of the column
|
|
||||||
height: "100%", // Fully stretches to column height
|
|
||||||
resizeMode: "cover", // Ensures it fits well
|
|
||||||
opacity: 0.2, // Fades the image
|
|
||||||
zIndex: -1,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
interface StatusProps {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
image: string;
|
|
||||||
currentStatus: string;
|
|
||||||
setStatus: (currentStatus: string) => void;
|
|
||||||
isProfileActive: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const StatusPage: React.FC<StatusProps> = ({ id, name, image, currentStatus, setStatus, isProfileActive }) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const [messages, setMessages] = useState<Message[]>([]);
|
|
||||||
const { lastMessage } = useWebSocket(WS_URL + "/ws", {
|
|
||||||
shouldReconnect: () => true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Animated values for background color pulsing
|
|
||||||
const pulseAnimOnTheWay = useRef(new Animated.Value(0)).current;
|
|
||||||
const pulseAnimArrived = useRef(new Animated.Value(0)).current;
|
|
||||||
|
|
||||||
// Function to trigger the color pulsing animation
|
|
||||||
const startPulsing = (animationRef: Animated.Value) => {
|
|
||||||
Animated.loop(
|
|
||||||
Animated.sequence([
|
|
||||||
Animated.timing(animationRef, {
|
|
||||||
toValue: 1,
|
|
||||||
duration: 800,
|
|
||||||
easing: Easing.inOut(Easing.ease),
|
|
||||||
useNativeDriver: false,
|
|
||||||
}),
|
|
||||||
Animated.timing(animationRef, {
|
|
||||||
toValue: 0,
|
|
||||||
duration: 800,
|
|
||||||
easing: Easing.inOut(Easing.ease),
|
|
||||||
useNativeDriver: false,
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
).start();
|
|
||||||
};
|
|
||||||
|
|
||||||
const stopPulsing = (animationRef: Animated.Value) => {
|
|
||||||
animationRef.setValue(0);
|
|
||||||
animationRef.stopAnimation();
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log("Updated status: ", currentStatus);
|
|
||||||
|
|
||||||
if (currentStatus === "On the Way") {
|
|
||||||
startPulsing(pulseAnimOnTheWay);
|
|
||||||
} else {
|
|
||||||
stopPulsing(pulseAnimOnTheWay);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentStatus === "Arrived") {
|
|
||||||
startPulsing(pulseAnimArrived);
|
|
||||||
} else {
|
|
||||||
stopPulsing(pulseAnimArrived);
|
|
||||||
}
|
|
||||||
}, [currentStatus]);
|
|
||||||
|
|
||||||
// Interpolated colors for pulsing effect
|
|
||||||
const getPulseColor = (animValue: Animated.Value) => animValue.interpolate({
|
|
||||||
inputRange: [0, 1],
|
|
||||||
outputRange: [theme.colors.secondary, theme.colors.primary],
|
|
||||||
});
|
|
||||||
|
|
||||||
const pulseColorOnTheWay = getPulseColor(pulseAnimOnTheWay);
|
|
||||||
const pulseColorArrived = getPulseColor(pulseAnimArrived);
|
|
||||||
|
|
||||||
// Function to handle status change
|
|
||||||
const handleStatusPress = async (status: string) => {
|
|
||||||
try {
|
|
||||||
if (currentStatus === status) {
|
|
||||||
// If pressed again, send "expired" status and clear currentStatus
|
|
||||||
console.log(`Expiring status: ${status}`);
|
|
||||||
const message: Message = { Id: id, Name: name, Image: image, Status: "expired", Timestamp: new Date().toISOString() };
|
|
||||||
await axios.post(API_URL + "/set", message);
|
|
||||||
setStatus(""); // Reset status
|
|
||||||
} else {
|
|
||||||
// Otherwise, send the new status
|
|
||||||
console.log(`Setting status: ${status}`);
|
|
||||||
const message: Message = { Id: id, Name: name, Image: image, Status: status, Timestamp: new Date().toISOString() };
|
|
||||||
await axios.post(API_URL + "/set", message);
|
|
||||||
setStatus(status);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Error sending status '${status}':`, error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Determine the button label based on whether it's animating
|
|
||||||
const getButtonLabel = (status: string) => {
|
|
||||||
if (status === "On the Way") return currentStatus === "On the Way" ? "Traveling" : "On the way";
|
|
||||||
if (status === "Arrived") return currentStatus === "Arrived" ? "At the dog park" : "Arrived";
|
|
||||||
return status;
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (lastMessage?.data) {
|
|
||||||
try {
|
|
||||||
const newMessage: Message = JSON.parse(lastMessage.data);
|
|
||||||
setMessages((prev) => {
|
|
||||||
if (newMessage.Status === "removed") {
|
|
||||||
if (newMessage.Id === id) {
|
|
||||||
setTimeout(() => {
|
|
||||||
setStatus(""); // Correctly clears the status
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
return prev.filter((msg) => msg.Id !== newMessage.Id);
|
|
||||||
}
|
|
||||||
return prev.filter((msg) => msg.Id !== newMessage.Id).concat(newMessage);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error parsing WebSocket message:", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [lastMessage, setStatus, id]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={[styles.container, { backgroundColor: theme.colors.background }, isProfileActive && { display: 'none' }]}>
|
|
||||||
<View style={styles.listContainer}>
|
|
||||||
<View style={styles.listRow}>
|
|
||||||
<View style={styles.listColumn}>
|
|
||||||
<List.Section>
|
|
||||||
<List.Subheader style={[styles.listSubheader, { color: theme.colors.onSurface }]}>On the Way</List.Subheader>
|
|
||||||
{messages.filter(msg => msg.Status === "On the Way")
|
|
||||||
.sort((a, b) => new Date(a.Timestamp).getTime() - new Date(b.Timestamp).getTime())
|
|
||||||
.map(item => (
|
|
||||||
<View key={item.Id} style={[styles.card, { backgroundColor: theme.colors.primaryContainer }]}>
|
|
||||||
<List.Item
|
|
||||||
key={item.Id}
|
|
||||||
title={item.Name}
|
|
||||||
titleStyle={{ color: theme.colors.onSurface }}
|
|
||||||
description={new Date(item.Timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: true })}
|
|
||||||
descriptionStyle={{ color: theme.colors.onSurface }}
|
|
||||||
left={(props) => <Avatar.Image {...props} size={40} source={{ uri: `data:image/png;base64,${item.Image}` }} />}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</List.Section>
|
|
||||||
</View>
|
|
||||||
<View style={styles.listColumn}>
|
|
||||||
<List.Section>
|
|
||||||
<List.Subheader style={[styles.listSubheader, { color: theme.colors.onSurface }]}>Arrived</List.Subheader>
|
|
||||||
{messages.filter(msg => msg.Status === "Arrived")
|
|
||||||
.sort((a, b) => new Date(a.Timestamp).getTime() - new Date(b.Timestamp).getTime())
|
|
||||||
.map(item => (
|
|
||||||
<View key={item.Id} style={[styles.card, { backgroundColor: theme.colors.primaryContainer }]}>
|
|
||||||
<List.Item
|
|
||||||
key={item.Id}
|
|
||||||
title={item.Name}
|
|
||||||
titleStyle={{ color: theme.colors.onSurface }}
|
|
||||||
description={new Date(item.Timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: true })}
|
|
||||||
descriptionStyle={{ color: theme.colors.onSurface }}
|
|
||||||
left={(props) => <Avatar.Image {...props} size={40} source={{ uri: `data:image/png;base64,${item.Image}` }} />}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</List.Section>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
<ImageBackground source={require('../assets/images/bg.webp')} style={styles.imageBackground} />
|
|
||||||
<View style={styles.buttonContainer}>
|
|
||||||
<Animated.View style={{ flex: 1 }}>
|
|
||||||
<Button
|
|
||||||
mode="contained"
|
|
||||||
onPress={() => handleStatusPress("On the Way")}
|
|
||||||
style={[
|
|
||||||
styles.actionButton,
|
|
||||||
{ backgroundColor: currentStatus === "On the Way" ? pulseColorOnTheWay : theme.colors.primary }
|
|
||||||
]}
|
|
||||||
labelStyle={{ color: theme.colors.onPrimary }}>
|
|
||||||
{getButtonLabel("On the Way")}
|
|
||||||
</Button>
|
|
||||||
</Animated.View>
|
|
||||||
<Animated.View style={{ flex: 1 }}>
|
|
||||||
<Button
|
|
||||||
mode="contained"
|
|
||||||
onPress={() => handleStatusPress("Arrived")}
|
|
||||||
style={[
|
|
||||||
styles.actionButton,
|
|
||||||
{ backgroundColor: currentStatus === "Arrived" ? pulseColorArrived : theme.colors.primary }
|
|
||||||
]}
|
|
||||||
labelStyle={{ color: theme.colors.onPrimary }}>
|
|
||||||
{getButtonLabel("Arrived")}
|
|
||||||
</Button>
|
|
||||||
</Animated.View>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default StatusPage;
|
|
@ -1,26 +1,40 @@
|
|||||||
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
|
|
||||||
import { useFonts } from 'expo-font';
|
import { useFonts } from 'expo-font';
|
||||||
import { Stack } from 'expo-router';
|
import { Stack } from 'expo-router';
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
import { StatusBar } from 'expo-status-bar';
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import 'react-native-reanimated';
|
import 'react-native-reanimated';
|
||||||
import { useColorScheme } from 'react-native';
|
import { useColorScheme } from 'react-native';
|
||||||
import { Provider } from "react-native-paper";
|
import { PaperProvider, Provider } from "react-native-paper";
|
||||||
|
import { UserProvider, useUser } from "@/context/UserContext";
|
||||||
|
import themes from '@/assets/themes'
|
||||||
|
import log from "@/util/log"
|
||||||
|
|
||||||
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
||||||
SplashScreen.preventAutoHideAsync();
|
void SplashScreen.preventAutoHideAsync();
|
||||||
|
|
||||||
export default function RootLayout() {
|
export default function RootLayout() {
|
||||||
const colorScheme = useColorScheme();
|
return (
|
||||||
console.log(colorScheme);
|
<UserProvider>
|
||||||
const [loaded] = useFonts({
|
<InnerRootLayout />
|
||||||
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
|
</UserProvider>
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function InnerRootLayout() {
|
||||||
|
const { currentTheme } = useUser(); // Access the currentTheme from UserContext
|
||||||
|
log.debug(currentTheme);
|
||||||
|
const colorScheme = useColorScheme();
|
||||||
|
log.debug(colorScheme);
|
||||||
|
const [loaded] = useFonts({
|
||||||
|
SpaceReg: require('../assets/fonts/SpaceMono-Regular.ttf'),
|
||||||
|
SpaceBold: require('../assets/fonts/SpaceMono-Bold.ttf'),
|
||||||
|
Light: require('../assets/fonts/font-light.otf'),
|
||||||
|
Medium: require('../assets/fonts/font-medium.otf'),
|
||||||
|
Heavy: require('../assets/fonts/font-heavy.otf'),
|
||||||
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
SplashScreen.hideAsync();
|
void SplashScreen.hideAsync();
|
||||||
}
|
}
|
||||||
}, [loaded]);
|
}, [loaded]);
|
||||||
|
|
||||||
@ -28,14 +42,21 @@ export default function RootLayout() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure currentTheme is treated as a valid key, or fallback to 'blue'
|
||||||
|
//const themeKey: 'blue' | 'green' | 'red' | 'yellow' | 'orange' = (currentTheme as 'blue' | 'green' | 'red' | 'yellow' | 'orange') || 'blue';
|
||||||
|
|
||||||
|
// Use the themeKey to index into the themes object
|
||||||
|
|
||||||
|
//const appTheme = themes[themeKey][colorScheme === 'dark' ? 'dark' : 'light'];
|
||||||
|
const appTheme = themes[currentTheme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light']
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider>
|
<Provider>
|
||||||
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
<PaperProvider theme={appTheme}>
|
||||||
<StatusBar style={colorScheme === 'dark' ? 'light' : 'dark'} />
|
|
||||||
<Stack>
|
<Stack>
|
||||||
<Stack.Screen name="index" options={{ headerShown: false }} />
|
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</ThemeProvider>
|
</PaperProvider>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
62
app/_layout.web.tsx
Normal file
62
app/_layout.web.tsx
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import { useFonts } from 'expo-font';
|
||||||
|
import { Stack } from 'expo-router';
|
||||||
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import 'react-native-reanimated';
|
||||||
|
import { useColorScheme } from 'react-native';
|
||||||
|
import { PaperProvider, Provider } from "react-native-paper";
|
||||||
|
import { UserProvider, useUser } from "@/context/UserContext";
|
||||||
|
import themes from '@/assets/themes'
|
||||||
|
import log from "@/util/log"
|
||||||
|
|
||||||
|
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
||||||
|
void SplashScreen.preventAutoHideAsync();
|
||||||
|
|
||||||
|
export default function RootLayout() {
|
||||||
|
return (
|
||||||
|
<UserProvider>
|
||||||
|
<InnerRootLayout />
|
||||||
|
</UserProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function InnerRootLayout() {
|
||||||
|
const { currentTheme } = useUser(); // Access the currentTheme from UserContext
|
||||||
|
log.debug(currentTheme);
|
||||||
|
const colorScheme = useColorScheme();
|
||||||
|
log.debug(colorScheme);
|
||||||
|
const [loaded] = useFonts({
|
||||||
|
SpaceReg: require('../assets/fonts/SpaceMono-Regular.ttf'),
|
||||||
|
SpaceBold: require('../assets/fonts/SpaceMono-Bold.ttf'),
|
||||||
|
Light: require('../assets/fonts/font-light.otf'),
|
||||||
|
Medium: require('../assets/fonts/font-medium.otf'),
|
||||||
|
Heavy: require('../assets/fonts/font-heavy.otf'),
|
||||||
|
});
|
||||||
|
useEffect(() => {
|
||||||
|
if (loaded) {
|
||||||
|
void SplashScreen.hideAsync();
|
||||||
|
}
|
||||||
|
}, [loaded]);
|
||||||
|
|
||||||
|
if (!loaded) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure currentTheme is treated as a valid key, or fallback to 'blue'
|
||||||
|
//const themeKey: 'blue' | 'green' | 'red' | 'yellow' | 'orange' = (currentTheme as 'blue' | 'green' | 'red' | 'yellow' | 'orange') || 'blue';
|
||||||
|
|
||||||
|
// Use the themeKey to index into the themes object
|
||||||
|
|
||||||
|
//const appTheme = themes[themeKey][colorScheme === 'dark' ? 'dark' : 'light'];
|
||||||
|
const appTheme = themes[currentTheme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light']
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Provider>
|
||||||
|
<PaperProvider theme={appTheme}>
|
||||||
|
<Stack>
|
||||||
|
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||||
|
</Stack>
|
||||||
|
</PaperProvider>
|
||||||
|
</Provider>
|
||||||
|
);
|
||||||
|
}
|
108
app/index.tsx
108
app/index.tsx
@ -1,93 +1,73 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React from 'react';
|
||||||
import {View, StyleSheet } from "react-native";
|
import {View, Text } from "react-native";
|
||||||
import { useTheme } from "react-native-paper";
|
import { useTheme } from "react-native-paper";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import Profile from "@/components/Profile";
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
import Status from "@/components/Status";
|
||||||
import ProfileScreen from "@/app/ProfileScreen";
|
import TopNav from "@/components/TopNav";
|
||||||
import StatusPage from "@/app/StatusPage";
|
import BottomNav from "@/components/BottomNav"
|
||||||
import Nav from "@/app/Nav";
|
import { useUser } from "@/context/UserContext";
|
||||||
|
import styles from "@/assets/styles";
|
||||||
|
import log from "@/util/log"
|
||||||
|
|
||||||
const Index = () => {
|
const Index = () => {
|
||||||
const { colors } = useTheme();
|
const theme = useTheme();
|
||||||
const [isProfileActive, setProfileActive] = useState(false);
|
|
||||||
const [userId, setUserId] = useState(uuidv4());
|
|
||||||
const [userName, setUserName] = useState("");
|
|
||||||
const [userImage, setUserImage] = useState("");
|
|
||||||
const [userStatus, setUserStatus] = useState("");
|
|
||||||
|
|
||||||
useEffect(() => {
|
const {
|
||||||
const loadUserData = async () => {
|
isProfileActive,
|
||||||
try {
|
setProfileActive,
|
||||||
const storedUserId = await AsyncStorage.getItem("userId");
|
userId,
|
||||||
const storedUserName = await AsyncStorage.getItem("userName");
|
userName,
|
||||||
const storedUserImage = await AsyncStorage.getItem("userImage");
|
setUserName,
|
||||||
if(storedUserId) {
|
userImage,
|
||||||
setUserId(storedUserId || uuidv4());
|
setUserImage,
|
||||||
setUserName(storedUserName || "");
|
userStatus,
|
||||||
setUserImage(storedUserImage || "");
|
setUserStatus,
|
||||||
setProfileActive(false);
|
setUserDataChanged,
|
||||||
}else{
|
setTheme,
|
||||||
setUserId(uuidv4());
|
currentTheme,
|
||||||
setUserName("");
|
isLoading,
|
||||||
setUserImage("");
|
} = useUser();
|
||||||
setProfileActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
if (isLoading) {
|
||||||
console.error("Error loading user data:", error);
|
log.debug("Still loading");
|
||||||
}
|
return (
|
||||||
};
|
<View style={[styles.indexContainer, { backgroundColor: theme.colors.background, justifyContent: 'center', alignItems: 'center' }]}>
|
||||||
loadUserData();
|
<Text>Loading...</Text>
|
||||||
}, []);
|
</View>
|
||||||
|
);
|
||||||
useEffect(() => {
|
}
|
||||||
const saveUserData = async () => {
|
|
||||||
try {
|
|
||||||
await AsyncStorage.setItem("userId", userId);
|
|
||||||
await AsyncStorage.setItem("userName", userName);
|
|
||||||
await AsyncStorage.setItem("userImage", userImage);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error saving user data:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
saveUserData();
|
|
||||||
}, [userId, userName, userImage]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container,{ backgroundColor: colors.background }]}>
|
<View style={[styles.indexContainer, { backgroundColor: theme.colors.background }]}>
|
||||||
<Nav
|
<TopNav
|
||||||
toggleProfile={() => setProfileActive(true)}
|
toggleProfile={() => setProfileActive(true)}
|
||||||
/>
|
/>
|
||||||
<StatusPage
|
<Status
|
||||||
id={userId}
|
id={userId}
|
||||||
name={userName}
|
name={userName}
|
||||||
image={userImage}
|
image={userImage}
|
||||||
currentStatus={userStatus}
|
currentStatus={userStatus}
|
||||||
setStatus={setUserStatus}
|
setStatus={setUserStatus}
|
||||||
|
currentTheme={currentTheme}
|
||||||
isProfileActive={isProfileActive}
|
isProfileActive={isProfileActive}
|
||||||
/>
|
/>
|
||||||
<ProfileScreen
|
<Profile
|
||||||
visible={isProfileActive}
|
visible={isProfileActive}
|
||||||
id={userId}
|
id={userId}
|
||||||
name={userName}
|
name={userName}
|
||||||
setName={setUserName}
|
setName={setUserName}
|
||||||
image={userImage}
|
image={userImage}
|
||||||
setImage={setUserImage}
|
setImage={setUserImage}
|
||||||
|
setTheme={setTheme}
|
||||||
|
currentTheme={currentTheme}
|
||||||
|
setChanged={setUserDataChanged}
|
||||||
onClose={() => setProfileActive(false)}
|
onClose={() => setProfileActive(false)}
|
||||||
/>
|
/>
|
||||||
|
<BottomNav
|
||||||
|
isProfileActive={isProfileActive}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
container: { flex: 1, alignItems: "stretch" },
|
|
||||||
imageBackground: {
|
|
||||||
position: "absolute", // Allows child elements to layer on top
|
|
||||||
width: "100%", // Ensure full coverage of the column
|
|
||||||
height: "100%", // Fully stretches to column height
|
|
||||||
resizeMode: "cover", // Ensures it fits well
|
|
||||||
opacity: 0.3, // Fades the image
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default Index;
|
export default Index;
|
||||||
|
BIN
assets/fonts/SpaceMono-Bold.ttf
Normal file
BIN
assets/fonts/SpaceMono-Bold.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/SpaceMono-Regular.ttf
Executable file → Normal file
BIN
assets/fonts/SpaceMono-Regular.ttf
Executable file → Normal file
Binary file not shown.
BIN
assets/fonts/font-heavy.otf
Normal file
BIN
assets/fonts/font-heavy.otf
Normal file
Binary file not shown.
BIN
assets/fonts/font-light.otf
Normal file
BIN
assets/fonts/font-light.otf
Normal file
Binary file not shown.
BIN
assets/fonts/font-medium.otf
Normal file
BIN
assets/fonts/font-medium.otf
Normal file
Binary file not shown.
BIN
assets/images/broken.png
Normal file
BIN
assets/images/broken.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1022 KiB |
Binary file not shown.
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 75 KiB |
BIN
assets/images/pogdark_logo_inverse.png
Normal file
BIN
assets/images/pogdark_logo_inverse.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
assets/images/pogdark_logo_inverse_white.png
Normal file
BIN
assets/images/pogdark_logo_inverse_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
95
assets/styles.ts
Normal file
95
assets/styles.ts
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
import {StyleSheet} from "react-native";
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
//StatusPage
|
||||||
|
container: { flex: 1, alignItems: "stretch" },
|
||||||
|
listContainer: {
|
||||||
|
flex: 1,
|
||||||
|
width: "100%",
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
//alignItems: "flex-start", // Aligns subheaders properly
|
||||||
|
paddingHorizontal: 10, // Adds some spacing
|
||||||
|
},
|
||||||
|
listSubheader: {
|
||||||
|
fontFamily: "Medium",
|
||||||
|
fontSize: 18, // Larger text
|
||||||
|
textAlign: "center", // Center the text
|
||||||
|
fontWeight: "bold", // Make it more distinct
|
||||||
|
marginBottom: 10, // Add spacing below
|
||||||
|
zIndex: 0,
|
||||||
|
},
|
||||||
|
//listWrapper: { flex: 1, padding: 5 },
|
||||||
|
listColumn: { flex: 1, paddingHorizontal: 5, zIndex: 1},
|
||||||
|
buttonContainer: {
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignSelf: "stretch",
|
||||||
|
verticalAlign: "bottom",
|
||||||
|
paddingHorizontal: 10,
|
||||||
|
paddingBottom: 20,
|
||||||
|
marginHorizontal: 5,
|
||||||
|
},
|
||||||
|
actionButton: {
|
||||||
|
flex: 1,
|
||||||
|
marginHorizontal: 5,
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
marginVertical: 5,
|
||||||
|
elevation: 4, // Android shadow
|
||||||
|
shadowColor: "#000", // iOS shadow
|
||||||
|
shadowOffset: { width: 0, height: 2 },
|
||||||
|
shadowOpacity: 0.2,
|
||||||
|
shadowRadius: 4,
|
||||||
|
borderRadius: 10,
|
||||||
|
},
|
||||||
|
imageBackground: {
|
||||||
|
position: "absolute", // Allows child elements to layer on top
|
||||||
|
width: "100%", // Ensure full coverage of the column
|
||||||
|
height: "100%", // Fully stretches to column height
|
||||||
|
resizeMode: "cover", // Ensures it fits well
|
||||||
|
opacity: 0.2, // Fades the image
|
||||||
|
zIndex: -1,
|
||||||
|
},
|
||||||
|
//profile screen
|
||||||
|
themeContainer: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-around',
|
||||||
|
alignSelf: 'center',
|
||||||
|
//alignItems: 'center',
|
||||||
|
marginTop: 10,
|
||||||
|
},
|
||||||
|
themeButton: {
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
borderRadius: 25,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
overflow: 'hidden',
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: 'black',
|
||||||
|
},
|
||||||
|
halfCircle: {
|
||||||
|
width: '50%',
|
||||||
|
height: '100%',
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 0,
|
||||||
|
},
|
||||||
|
//Nav
|
||||||
|
logoContainer: { flex: 1, alignItems: "center" },
|
||||||
|
logo: { width: 140, height: 70 },
|
||||||
|
topBar: { },
|
||||||
|
bottomBar: { height: 38 },
|
||||||
|
//index
|
||||||
|
indexImageBackground: {
|
||||||
|
position: "absolute", // Allows child elements to layer on top
|
||||||
|
width: "100%", // Ensure full coverage of the column
|
||||||
|
height: "100%", // Fully stretches to column height
|
||||||
|
resizeMode: "cover", // Ensures it fits well
|
||||||
|
opacity: 0.3, // Fades the image
|
||||||
|
},
|
||||||
|
indexContainer: { flex: 1, alignItems: "stretch" },
|
||||||
|
});
|
||||||
|
|
||||||
|
export default styles;
|
450
assets/themes.ts
Normal file
450
assets/themes.ts
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
import { MD3LightTheme, MD3DarkTheme } from 'react-native-paper';
|
||||||
|
|
||||||
|
const themes = {
|
||||||
|
purple: {
|
||||||
|
light: MD3LightTheme,
|
||||||
|
dark: MD3DarkTheme,
|
||||||
|
},
|
||||||
|
red: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#7F0000',
|
||||||
|
primaryContainer: '#FF5252',
|
||||||
|
inversePrimary: '#D32F2F',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#FF5252',
|
||||||
|
primaryContainer: '#7F0000',
|
||||||
|
inversePrimary: '#D32F2F',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
blue: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#0D47A1',
|
||||||
|
primaryContainer: '#64B5F6',
|
||||||
|
inversePrimary: '#1976D2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#64B5F6',
|
||||||
|
primaryContainer: '#0D47A1',
|
||||||
|
inversePrimary: '#1976D2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
yellow: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#efb100',
|
||||||
|
primaryContainer: '#FFEB8F',
|
||||||
|
inversePrimary: '#fbc338',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#FFEB8F',
|
||||||
|
primaryContainer: '#EFB100',
|
||||||
|
inversePrimary: '#FBC02D',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
green: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#004D00',
|
||||||
|
primaryContainer: '#66BB6A',
|
||||||
|
inversePrimary: '#388E3C',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#66BB6A',
|
||||||
|
primaryContainer: '#004D00',
|
||||||
|
inversePrimary: '#388E3C',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orange: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#F57C00',
|
||||||
|
primaryContainer: '#FFCC80',
|
||||||
|
inversePrimary: '#FFAB40',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#FFCC80',
|
||||||
|
primaryContainer: '#F57C00',
|
||||||
|
inversePrimary: '#FFAB40',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const oldThemes = {
|
||||||
|
purple: {
|
||||||
|
light: MD3LightTheme,
|
||||||
|
dark: MD3DarkTheme,
|
||||||
|
},
|
||||||
|
red: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#D32F2F',
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#FFCDD2',
|
||||||
|
onPrimaryContainer: '#4A0D0D',
|
||||||
|
secondary: '#FF5252',
|
||||||
|
onSecondary: '#FFFFFF',
|
||||||
|
secondaryContainer: '#FFEBEE',
|
||||||
|
onSecondaryContainer: '#5D1E1E',
|
||||||
|
tertiary: '#C2185B',
|
||||||
|
onTertiary: '#FFFFFF',
|
||||||
|
tertiaryContainer: '#F8BBD0',
|
||||||
|
onTertiaryContainer: '#550027',
|
||||||
|
background: '#FFFFFF',
|
||||||
|
onBackground: '#121212',
|
||||||
|
surface: '#F5F5F5',
|
||||||
|
onSurface: '#1E1E1E',
|
||||||
|
error: '#B00020',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#B71C1C',
|
||||||
|
inverseSurface: '#333333',
|
||||||
|
inverseOnSurface: '#FAFAFA',
|
||||||
|
inversePrimary: '#FFB4A9',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#FF5252',
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#7F0000',
|
||||||
|
onPrimaryContainer: '#FFDAD4',
|
||||||
|
secondary: '#FF8A80',
|
||||||
|
onSecondary: '#1E0000',
|
||||||
|
secondaryContainer: '#4A0D0D',
|
||||||
|
onSecondaryContainer: '#FFEBEE',
|
||||||
|
tertiary: '#FF4081',
|
||||||
|
onTertiary: '#1E001E',
|
||||||
|
tertiaryContainer: '#7A001A',
|
||||||
|
onTertiaryContainer: '#FFD9E3',
|
||||||
|
background: '#121212',
|
||||||
|
onBackground: '#E1E1E1',
|
||||||
|
surface: '#1E1E1E',
|
||||||
|
onSurface: '#FFFFFF',
|
||||||
|
error: '#CF6679',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#FF6F61',
|
||||||
|
inverseSurface: '#E1E1E1',
|
||||||
|
inverseOnSurface: '#1E1E1E',
|
||||||
|
inversePrimary: '#D32F2F',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
blue: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#1976D2',
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#BBDEFB',
|
||||||
|
onPrimaryContainer: '#0D47A1',
|
||||||
|
secondary: '#64B5F6',
|
||||||
|
onSecondary: '#FFFFFF',
|
||||||
|
secondaryContainer: '#E3F2FD',
|
||||||
|
onSecondaryContainer: '#1565C0',
|
||||||
|
tertiary: '#0288D1',
|
||||||
|
onTertiary: '#FFFFFF',
|
||||||
|
tertiaryContainer: '#81D4FA',
|
||||||
|
onTertiaryContainer: '#01579B',
|
||||||
|
background: '#FFFFFF',
|
||||||
|
onBackground: '#121212',
|
||||||
|
surface: '#F5F5F5',
|
||||||
|
onSurface: '#1E1E1E',
|
||||||
|
error: '#B00020',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#1565C0',
|
||||||
|
inverseSurface: '#333333',
|
||||||
|
inverseOnSurface: '#FAFAFA',
|
||||||
|
inversePrimary: '#90CAF9',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#64B5F6',
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#0D47A1',
|
||||||
|
onPrimaryContainer: '#BBDEFB',
|
||||||
|
secondary: '#81D4FA',
|
||||||
|
onSecondary: '#1E1E1E',
|
||||||
|
secondaryContainer: '#1565C0',
|
||||||
|
onSecondaryContainer: '#E3F2FD',
|
||||||
|
tertiary: '#29B6F6',
|
||||||
|
onTertiary: '#1E1E1E',
|
||||||
|
tertiaryContainer: '#01579B',
|
||||||
|
onTertiaryContainer: '#81D4FA',
|
||||||
|
background: '#121212',
|
||||||
|
onBackground: '#E1E1E1',
|
||||||
|
surface: '#1E1E1E',
|
||||||
|
onSurface: '#FFFFFF',
|
||||||
|
error: '#CF6679',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#64B5F6',
|
||||||
|
inverseSurface: '#E1E1E1',
|
||||||
|
inverseOnSurface: '#1E1E1E',
|
||||||
|
inversePrimary: '#1976D2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
yellow: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#FBC02D',
|
||||||
|
onPrimary: '#000000',
|
||||||
|
primaryContainer: '#FFF9C4',
|
||||||
|
onPrimaryContainer: '#5F3700',
|
||||||
|
secondary: '#FFD54F',
|
||||||
|
onSecondary: '#000000',
|
||||||
|
secondaryContainer: '#FFF8E1',
|
||||||
|
onSecondaryContainer: '#775A00',
|
||||||
|
tertiary: '#FFB300',
|
||||||
|
onTertiary: '#FFFFFF',
|
||||||
|
tertiaryContainer: '#FFECB3',
|
||||||
|
onTertiaryContainer: '#603800',
|
||||||
|
background: '#FFFFFF',
|
||||||
|
onBackground: '#121212',
|
||||||
|
surface: '#F5F5F5',
|
||||||
|
onSurface: '#1E1E1E',
|
||||||
|
error: '#B00020',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#FF8F00',
|
||||||
|
inverseSurface: '#333333',
|
||||||
|
inverseOnSurface: '#FAFAFA',
|
||||||
|
inversePrimary: '#FDD835',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#FFD54F',
|
||||||
|
onPrimary: '#000000',
|
||||||
|
primaryContainer: '#5F3700',
|
||||||
|
onPrimaryContainer: '#FFF9C4',
|
||||||
|
secondary: '#FFEB3B',
|
||||||
|
onSecondary: '#000000',
|
||||||
|
secondaryContainer: '#775A00',
|
||||||
|
onSecondaryContainer: '#FFF8E1',
|
||||||
|
tertiary: '#FFB300',
|
||||||
|
onTertiary: '#1E1E1E',
|
||||||
|
tertiaryContainer: '#603800',
|
||||||
|
onTertiaryContainer: '#FFECB3',
|
||||||
|
background: '#121212',
|
||||||
|
onBackground: '#E1E1E1',
|
||||||
|
surface: '#1E1E1E',
|
||||||
|
onSurface: '#FFFFFF',
|
||||||
|
error: '#CF6679',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#FDD835',
|
||||||
|
inverseSurface: '#E1E1E1',
|
||||||
|
inverseOnSurface: '#1E1E1E',
|
||||||
|
inversePrimary: '#FBC02D',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
green: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#388E3C', // Material Green 700
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#C8E6C9',
|
||||||
|
onPrimaryContainer: '#004D00',
|
||||||
|
|
||||||
|
secondary: '#66BB6A',
|
||||||
|
onSecondary: '#FFFFFF',
|
||||||
|
secondaryContainer: '#E8F5E9',
|
||||||
|
onSecondaryContainer: '#1B5E20',
|
||||||
|
|
||||||
|
tertiary: '#2E7D32',
|
||||||
|
onTertiary: '#FFFFFF',
|
||||||
|
tertiaryContainer: '#A5D6A7',
|
||||||
|
onTertiaryContainer: '#003300',
|
||||||
|
|
||||||
|
background: '#FFFFFF',
|
||||||
|
onBackground: '#121212',
|
||||||
|
surface: '#F5F5F5',
|
||||||
|
onSurface: '#1E1E1E',
|
||||||
|
error: '#B00020',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#388E3C',
|
||||||
|
|
||||||
|
inverseSurface: '#333333',
|
||||||
|
inverseOnSurface: '#FAFAFA',
|
||||||
|
inversePrimary: '#A5D6A7', // Soft green
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#66BB6A',
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#004D00',
|
||||||
|
onPrimaryContainer: '#C8E6C9',
|
||||||
|
|
||||||
|
secondary: '#81C784',
|
||||||
|
onSecondary: '#1E1E1E',
|
||||||
|
secondaryContainer: '#1B5E20',
|
||||||
|
onSecondaryContainer: '#E8F5E9',
|
||||||
|
|
||||||
|
tertiary: '#43A047',
|
||||||
|
onTertiary: '#1E1E1E',
|
||||||
|
tertiaryContainer: '#003300',
|
||||||
|
onTertiaryContainer: '#A5D6A7',
|
||||||
|
|
||||||
|
background: '#121212',
|
||||||
|
onBackground: '#E1E1E1',
|
||||||
|
surface: '#1E1E1E',
|
||||||
|
onSurface: '#FFFFFF',
|
||||||
|
error: '#CF6679',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#A5D6A7',
|
||||||
|
|
||||||
|
inverseSurface: '#E1E1E1',
|
||||||
|
inverseOnSurface: '#1E1E1E',
|
||||||
|
inversePrimary: '#388E3C', // Same as light theme primary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
orange: {
|
||||||
|
light: {
|
||||||
|
...MD3LightTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3LightTheme.colors,
|
||||||
|
primary: '#F57C00', // Material Orange 700
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#FFCC80',
|
||||||
|
onPrimaryContainer: '#7A3300',
|
||||||
|
|
||||||
|
secondary: '#FFA726',
|
||||||
|
onSecondary: '#FFFFFF',
|
||||||
|
secondaryContainer: '#FFE0B2',
|
||||||
|
onSecondaryContainer: '#8E4700',
|
||||||
|
|
||||||
|
tertiary: '#EF6C00', // Deep orange
|
||||||
|
onTertiary: '#FFFFFF',
|
||||||
|
tertiaryContainer: '#FFD180',
|
||||||
|
onTertiaryContainer: '#622600',
|
||||||
|
|
||||||
|
background: '#FFFFFF',
|
||||||
|
onBackground: '#121212',
|
||||||
|
surface: '#F5F5F5',
|
||||||
|
onSurface: '#1E1E1E',
|
||||||
|
error: '#B00020',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#F57C00',
|
||||||
|
|
||||||
|
inverseSurface: '#333333',
|
||||||
|
inverseOnSurface: '#FAFAFA',
|
||||||
|
inversePrimary: '#FFAB40', // Soft orange
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
...MD3DarkTheme,
|
||||||
|
colors: {
|
||||||
|
...MD3DarkTheme.colors,
|
||||||
|
primary: '#FFA726',
|
||||||
|
onPrimary: '#FFFFFF',
|
||||||
|
primaryContainer: '#b38800',
|
||||||
|
onPrimaryContainer: '#FFCC80',
|
||||||
|
|
||||||
|
secondary: '#FFB74D',
|
||||||
|
onSecondary: '#1E1E1E',
|
||||||
|
secondaryContainer: '#5a4406',
|
||||||
|
onSecondaryContainer: '#FFE0B2',
|
||||||
|
|
||||||
|
tertiary: '#FB8C00',
|
||||||
|
onTertiary: '#1E1E1E',
|
||||||
|
tertiaryContainer: '#623400',
|
||||||
|
onTertiaryContainer: '#FFD180',
|
||||||
|
|
||||||
|
background: '#121212',
|
||||||
|
onBackground: '#E1E1E1',
|
||||||
|
surface: '#1E1E1E',
|
||||||
|
onSurface: '#FFFFFF',
|
||||||
|
error: '#CF6679',
|
||||||
|
onError: '#FFFFFF',
|
||||||
|
outline: '#FFAB40',
|
||||||
|
|
||||||
|
inverseSurface: '#E1E1E1',
|
||||||
|
inverseOnSurface: '#1E1E1E',
|
||||||
|
inversePrimary: '#F57C00', // Same as light theme primary
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const themePreviews = {
|
||||||
|
purple: {
|
||||||
|
light: '#6200EA', // Default Purple Light
|
||||||
|
dark: '#BB86FC', // Default Purple Dark
|
||||||
|
},
|
||||||
|
red: {
|
||||||
|
light: '#D32F2F',
|
||||||
|
dark: '#FF5252',
|
||||||
|
},
|
||||||
|
blue: {
|
||||||
|
light: '#1976D2',
|
||||||
|
dark: '#64B5F6',
|
||||||
|
},
|
||||||
|
yellow: {
|
||||||
|
light: '#FBC02D',
|
||||||
|
dark: '#FFD54F',
|
||||||
|
},
|
||||||
|
green: {
|
||||||
|
light: '#388E3C',
|
||||||
|
dark: '#66BB6A',
|
||||||
|
},
|
||||||
|
orange: {
|
||||||
|
light: '#F57C00',
|
||||||
|
dark: '#FFA726',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default themes;
|
47
components/About.tsx
Normal file
47
components/About.tsx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { ScrollView } from 'react-native';
|
||||||
|
import { Card, Title, Paragraph, Text, Dialog} from 'react-native-paper';
|
||||||
|
|
||||||
|
const About = () => {
|
||||||
|
return (
|
||||||
|
<Dialog.Content style={{ maxHeight: 300 }}>
|
||||||
|
<ScrollView style={{ padding: 16 }}>
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Paragraph style={{ fontSize: 20 }}>
|
||||||
|
<Text style={{ fontWeight: 'bold' }}>Pogdark</Text> is a dog park communication application that
|
||||||
|
allows users to inform others when they are on the way or have arrived at a dog park of their choice.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>How It Works</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
1. Users select a simple status:{"\n"}
|
||||||
|
{" "}• "On My Way"{"\n"}
|
||||||
|
{" "}• "Arrived"{"\n\n"}
|
||||||
|
2. The status is instantly sent via a WebSocket broker to other users who are listening.{"\n\n"}
|
||||||
|
3. Users can click again to cancel their current status, or status messages will automatically expire, ensuring no long-term data retention.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>Key Features</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
• <Text style={{ fontWeight: 'bold' }}>No Tracking, No Storage</Text> – The system doesn’t store user data or track locations. {"\n\n"}
|
||||||
|
• <Text style={{ fontWeight: 'bold' }}>Instant Updates</Text> – Real-time messaging ensures quick communication. {"\n\n"}
|
||||||
|
• <Text style={{ fontWeight: 'bold' }}>No Links or Logins</Text> – Users don’t need to generate links or sign up. Profiles are stored locally, and created on initial use.{"\n\n"}
|
||||||
|
• <Text style={{ fontWeight: 'bold' }}>Ephemeral by Design</Text> – Messages exist only for a 30 (On My Way) or 90 (Arrived) minute lifespan.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
</ScrollView>
|
||||||
|
</Dialog.Content>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default About;
|
48
components/BottomNav.tsx
Normal file
48
components/BottomNav.tsx
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import {Appbar, Portal, Button, Dialog, Text, useTheme } from "react-native-paper";
|
||||||
|
import { View } from "react-native";
|
||||||
|
import styles from "@/assets/styles";
|
||||||
|
import React, {useState} from "react";
|
||||||
|
import Location from "@/components/Location";
|
||||||
|
import Broken from "@/components/Broken";
|
||||||
|
|
||||||
|
|
||||||
|
interface BNProps {
|
||||||
|
isProfileActive: boolean;
|
||||||
|
}
|
||||||
|
const BottomNav: React.FC<BNProps> = ({ isProfileActive }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const [menuVisible, setMenuVisible] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={ isProfileActive && { display: 'none' }}>
|
||||||
|
<View style={{ backgroundColor: theme.colors.background }}>
|
||||||
|
<Appbar.Header style={[styles.bottomBar, { backgroundColor: theme.colors.primaryContainer }]} >
|
||||||
|
<View style={{ alignItems: "center", flexDirection: "row", justifyContent: "space-between", padding: 10, flex: 1, paddingHorizontal: 15 }}>
|
||||||
|
<Text style={{ color: theme.colors.primary, fontFamily: "SpaceReg" }}>Daisy Knight Dog Park</Text>
|
||||||
|
<Button
|
||||||
|
mode="text"
|
||||||
|
onPress={() => setMenuVisible(true) }
|
||||||
|
style={{ backgroundColor: theme.colors.primary, height: styles.bottomBar.height/2, justifyContent: "center"}}
|
||||||
|
labelStyle={{ color: theme.colors.onPrimary, fontFamily: "SpaceReg"}}>
|
||||||
|
Change
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</Appbar.Header>
|
||||||
|
<Portal>
|
||||||
|
<Dialog visible={menuVisible} onDismiss={() => setMenuVisible(false)} style={{ backgroundColor: theme.colors.primaryContainer, maxHeight: 400 }}>
|
||||||
|
<Dialog.Title style={{ color: theme.colors.primary, textAlign: 'center' }}>Location</Dialog.Title>
|
||||||
|
<Broken />
|
||||||
|
<Dialog.Actions style={{ justifyContent: "center" }}>
|
||||||
|
<Button onPress={() => setMenuVisible(false)} mode="contained" style={{ backgroundColor: theme.colors.inversePrimary }} labelStyle={{ color: theme.colors.primary }}>
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</Dialog.Actions>
|
||||||
|
</Dialog>
|
||||||
|
</Portal>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BottomNav;
|
21
components/Broken.tsx
Normal file
21
components/Broken.tsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import {Title, useTheme} from "react-native-paper";
|
||||||
|
import { Image, View } from "react-native";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const Broken = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Title style={{color: theme.colors.onBackground, fontSize: 16, textAlign: 'center', fontFamily: "Light"}}>The Internet is a Series of Tubes</Title>
|
||||||
|
<Image
|
||||||
|
source={require("../assets/images/broken.png")}
|
||||||
|
style={{ alignSelf: 'center', resizeMode: "contain", height: 400/3 }}
|
||||||
|
/>
|
||||||
|
<Title style={{color: theme.colors.onBackground, fontSize: 16, textAlign: 'center', fontFamily: "Light"}}>And these aren't connected. {"\n"} (We're still working on this part.)</Title>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Broken;
|
10
components/Location.tsx
Normal file
10
components/Location.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Broken from "@/components/Broken";
|
||||||
|
|
||||||
|
const Location = () => {
|
||||||
|
return (
|
||||||
|
<Broken />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Location;
|
88
components/Privacy.tsx
Normal file
88
components/Privacy.tsx
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { ScrollView } from 'react-native';
|
||||||
|
import { Card, Title, Paragraph, Text, Dialog } from 'react-native-paper';
|
||||||
|
|
||||||
|
const Privacy = () => {
|
||||||
|
return (
|
||||||
|
<Dialog.Content style={{ maxHeight: 300 }}>
|
||||||
|
<ScrollView style={{ padding: 16 }}>
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>Privacy Policy</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
<Text style={{ fontStyle: 'italic' }}>Effective Date: 4/1/25</Text>
|
||||||
|
</Paragraph>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
Thank you for using <Text style={{ fontWeight: 'bold' }}>Pogdark</Text> ("we", "our", or "us"). We are committed to protecting your privacy. This Privacy Policy explains how we handle your information when you use our application.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>1. No Tracking</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
We do <Text style={{ fontWeight: 'bold' }}>not</Text> collect or track any personal information. We do <Text style={{ fontWeight: 'bold' }}>not</Text> use analytics tools, cookies, or any third-party tracking services.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>2. Ephemeral Data Storage</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
Any data entered or generated within the app is stored only <Text style={{ fontWeight: 'bold' }}>temporarily</Text> and exists only for the duration of your session. Once the app is closed or the session ends, all data is deleted automatically. We do not retain any user data on our servers or devices beyond the current session.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>3. No Account or Registration Required</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
You are not required to create an account or provide any personal details (such as name, email address, or phone number) to use the app.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>4. No Data Sharing</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
Since we do not collect data, we do not share any data with third parties.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>5. Security</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
While we don’t store personal data, we still take standard precautions to secure ephemeral information during your use of the app.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card style={{ marginBottom: 16 }}>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>6. Changes to This Privacy Policy</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
If we ever make changes to this policy, we will update the date at the top and clearly communicate the changes within the app. However, any future version will always respect your privacy.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<Card.Content>
|
||||||
|
<Title style={{ fontSize: 20, marginBottom: 8 }}>7. Contact</Title>
|
||||||
|
<Paragraph style={{ fontSize: 16 }}>
|
||||||
|
If you have any questions or concerns about this policy, feel free to contact us at <Text style={{ fontStyle: 'italic' }}>support@pogdark.com</Text>.
|
||||||
|
</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
</ScrollView>
|
||||||
|
</Dialog.Content>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Privacy;
|
170
components/Profile.tsx
Normal file
170
components/Profile.tsx
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { Platform, View, TouchableOpacity } from "react-native";
|
||||||
|
import { Button, TextInput, Dialog, Portal, Avatar, useTheme, Text } from "react-native-paper";
|
||||||
|
import { Asset } from 'expo-asset';
|
||||||
|
import * as FileSystem from 'expo-file-system';
|
||||||
|
import * as ImagePicker from "expo-image-picker";
|
||||||
|
import themes from '@/assets/themes';
|
||||||
|
import styles from "@/assets/styles";
|
||||||
|
import log from "@/util/log"
|
||||||
|
import featureFlags from '@/util/featureFlags';
|
||||||
|
|
||||||
|
interface ProfileScreenProps {
|
||||||
|
visible: boolean;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
setName: (name: string) => void;
|
||||||
|
image: string;
|
||||||
|
setImage: (image: string) => void;
|
||||||
|
setChanged: (dataChanged: boolean) => void;
|
||||||
|
setTheme: (theme: string) => void;
|
||||||
|
currentTheme: string;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Profile: React.FC<ProfileScreenProps> = ({ visible, name, setName, image, setImage, setChanged, currentTheme, setTheme, onClose }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const isNameEmpty = !name.trim();
|
||||||
|
const themeColors = ['red', 'blue', 'yellow', 'green', 'orange', 'purple'];
|
||||||
|
|
||||||
|
// Track the initial values when the component first mounts
|
||||||
|
const [initialName, setInitialName] = useState(name);
|
||||||
|
const [initialImage, setInitialImage] = useState(image);
|
||||||
|
const [initialTheme, setInitialTheme] = useState(currentTheme);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (visible) {
|
||||||
|
setInitialName(name); // Store initial name when the profile opens
|
||||||
|
setInitialImage(image);
|
||||||
|
setInitialTheme(currentTheme)// Store initial image when the profile opens
|
||||||
|
}
|
||||||
|
}, [visible]); // Reset when the dialog is opened
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadDefaultImage = async () => {
|
||||||
|
const asset = Asset.fromModule(require("../assets/images/default_profile_image.png"));
|
||||||
|
await asset.downloadAsync();
|
||||||
|
if (Platform.OS === 'web') {
|
||||||
|
const response = await fetch(asset.uri);
|
||||||
|
const blob = await response.blob();
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onloadend = () => {
|
||||||
|
const base64String = reader.result?.toString().replace(/^data:.+;base64,/, '');
|
||||||
|
resolve(base64String);
|
||||||
|
if (typeof base64String == "string") {
|
||||||
|
setImage(base64String);
|
||||||
|
} else {
|
||||||
|
throw new Error("Failed to load asset.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(blob);
|
||||||
|
});
|
||||||
|
} else if (asset.uri) {
|
||||||
|
const base64 = await FileSystem.readAsStringAsync(asset.uri, { encoding: FileSystem.EncodingType.Base64 });
|
||||||
|
setImage(base64);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadImage = async () => {
|
||||||
|
if (!image || image === "") {
|
||||||
|
log.debug("Loading ", image);
|
||||||
|
await loadDefaultImage();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadImage().then(() => null);
|
||||||
|
}, [image]);
|
||||||
|
|
||||||
|
const pickImage = async () => {
|
||||||
|
let result = await ImagePicker.launchImageLibraryAsync({ base64: true });
|
||||||
|
if (!result.canceled && result.assets.length > 0) {
|
||||||
|
if (result.assets[0].base64 !== image) { // Only update if the image actually changes
|
||||||
|
setImage(result.assets[0].base64 || image);
|
||||||
|
log.debug("Picking Image");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = () => {
|
||||||
|
// Check if the name or image has changed
|
||||||
|
const hasChanged = name !== initialName || image !== initialImage || currentTheme !== initialTheme;
|
||||||
|
if (hasChanged) {
|
||||||
|
setChanged(true);
|
||||||
|
}
|
||||||
|
onClose(); // Close the profile screen
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Portal>
|
||||||
|
<Dialog
|
||||||
|
visible={visible}
|
||||||
|
onDismiss={() => {
|
||||||
|
if (!isNameEmpty) { // Prevent closing if name is empty
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
style={{ backgroundColor: theme.colors.background }}>
|
||||||
|
<Dialog.Title style={{ color: theme.colors.onBackground, textAlign: 'center', fontFamily: "Light"}}>Edit Your Profile</Dialog.Title>
|
||||||
|
<Dialog.Content>
|
||||||
|
<Avatar.Image
|
||||||
|
size={100}
|
||||||
|
source={image ? { uri: `data:image/png;base64,${image}` } : require("../assets/images/default_profile_image.png")}
|
||||||
|
style={{ alignSelf: 'center', marginBottom: 15 }}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
onPress={pickImage}
|
||||||
|
mode="contained"
|
||||||
|
style={{ backgroundColor: theme.colors.primaryContainer, marginBottom: 10 }}
|
||||||
|
labelStyle={{ color: theme.colors.primary, fontFamily: "SpaceReg" }}
|
||||||
|
>
|
||||||
|
Change Profile Picture
|
||||||
|
</Button>
|
||||||
|
<TextInput
|
||||||
|
label="Your Pet's Name"
|
||||||
|
mode="outlined"
|
||||||
|
value={name}
|
||||||
|
onChangeText={(newName) => {
|
||||||
|
if (newName !== name) { // Only trigger change if it's different
|
||||||
|
setName(newName);
|
||||||
|
log.debug("Name change");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
style={{ marginBottom: 15, fontFamily: "SpaceReg" }}
|
||||||
|
placeholderTextColor={theme.colors.primary}
|
||||||
|
textColor={theme.colors.primary}
|
||||||
|
theme={{ colors: { text: theme.colors.primary }}}
|
||||||
|
/>
|
||||||
|
{featureFlags.enableThemeSelection && (
|
||||||
|
<>
|
||||||
|
<Text style={{ color: theme.colors.primary, fontSize: 18, fontFamily: "SpaceReg", textAlign: 'center' }}>Choose Theme</Text>
|
||||||
|
<View style={styles.themeContainer}>
|
||||||
|
{themeColors.map((userTheme) => (
|
||||||
|
<TouchableOpacity
|
||||||
|
key={userTheme}
|
||||||
|
style={[styles.themeButton, { backgroundColor: themes[userTheme as keyof typeof themes]['light'].colors.primary }]}
|
||||||
|
onPress={() => {setTheme(userTheme); log.debug("Changing Theme: ", userTheme)}}
|
||||||
|
>
|
||||||
|
<View style={[styles.halfCircle, { backgroundColor: themes[userTheme as keyof typeof themes]['dark'].colors.primary }]} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Dialog.Content>
|
||||||
|
<Dialog.Actions>
|
||||||
|
<Button
|
||||||
|
onPress={handleSave}
|
||||||
|
mode="contained"
|
||||||
|
disabled={isNameEmpty} // Disable if name is empty
|
||||||
|
style={{
|
||||||
|
backgroundColor: theme.colors.primaryContainer,
|
||||||
|
opacity: isNameEmpty ? 0.5 : 1, // Visually dim the button
|
||||||
|
}}
|
||||||
|
labelStyle={{ color: theme.colors.primary, fontFamily: "SpaceReg" }}>Save</Button>
|
||||||
|
</Dialog.Actions>
|
||||||
|
</Dialog>
|
||||||
|
</Portal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Profile;
|
235
components/Status.tsx
Normal file
235
components/Status.tsx
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
import React, { useEffect, useState, useRef } from "react";
|
||||||
|
import useWebSocket from "react-use-websocket";
|
||||||
|
import axios from "axios";
|
||||||
|
import {Animated, Easing, ImageBackground, ScrollView, useColorScheme, View} from "react-native";
|
||||||
|
import { Avatar, List, Button, useTheme, } from "react-native-paper";
|
||||||
|
import themes from "@/assets/themes";
|
||||||
|
import styles from "@/assets/styles";
|
||||||
|
import log from "@/util/log"
|
||||||
|
|
||||||
|
export const API_URL = process.env.EXPO_PUBLIC_API_URL;
|
||||||
|
export const WS_URL = process.env.EXPO_PUBLIC_WS_URL;
|
||||||
|
|
||||||
|
interface Message {
|
||||||
|
Id: string;
|
||||||
|
Name: string;
|
||||||
|
Image: string;
|
||||||
|
Status: string;
|
||||||
|
Theme: string;
|
||||||
|
Timestamp: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StatusProps {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
image: string;
|
||||||
|
currentStatus: string;
|
||||||
|
setStatus: (currentStatus: string) => void;
|
||||||
|
currentTheme: string;
|
||||||
|
isProfileActive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Status: React.FC<StatusProps> = ({ id, name, image, currentStatus, setStatus, currentTheme, isProfileActive }) => {
|
||||||
|
log.debug("WebSocket URL: ", WS_URL);
|
||||||
|
log.debug("API URL: ", API_URL);
|
||||||
|
const theme = useTheme();
|
||||||
|
const colorScheme = useColorScheme();
|
||||||
|
log.debug(themes[currentTheme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'].colors.primary);
|
||||||
|
|
||||||
|
const [messages, setMessages] = useState<Message[]>([]);
|
||||||
|
const { lastMessage } = useWebSocket(WS_URL + "/ws", {
|
||||||
|
shouldReconnect: () => true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Animated values for background color pulsing
|
||||||
|
const pulseAnimOnTheWay = useRef(new Animated.Value(0)).current;
|
||||||
|
const pulseAnimArrived = useRef(new Animated.Value(0)).current;
|
||||||
|
|
||||||
|
// Function to trigger the color pulsing animation
|
||||||
|
const startPulsing = (animationRef: Animated.Value) => {
|
||||||
|
Animated.loop(
|
||||||
|
Animated.sequence([
|
||||||
|
Animated.timing(animationRef, {
|
||||||
|
toValue: 1,
|
||||||
|
duration: 800,
|
||||||
|
easing: Easing.inOut(Easing.ease),
|
||||||
|
useNativeDriver: false,
|
||||||
|
}),
|
||||||
|
Animated.timing(animationRef, {
|
||||||
|
toValue: 0,
|
||||||
|
duration: 800,
|
||||||
|
easing: Easing.inOut(Easing.ease),
|
||||||
|
useNativeDriver: false,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
).start();
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopPulsing = (animationRef: Animated.Value) => {
|
||||||
|
animationRef.setValue(0);
|
||||||
|
animationRef.stopAnimation();
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
log.debug("Updated status: ", currentStatus);
|
||||||
|
|
||||||
|
if (currentStatus === "On the Way") {
|
||||||
|
startPulsing(pulseAnimOnTheWay);
|
||||||
|
} else {
|
||||||
|
stopPulsing(pulseAnimOnTheWay);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentStatus === "Arrived") {
|
||||||
|
startPulsing(pulseAnimArrived);
|
||||||
|
} else {
|
||||||
|
stopPulsing(pulseAnimArrived);
|
||||||
|
}
|
||||||
|
}, [currentStatus]);
|
||||||
|
|
||||||
|
// Interpolated colors for pulsing effect
|
||||||
|
const getPulseColor = (animValue: Animated.Value) => animValue.interpolate({
|
||||||
|
inputRange: [0, 1],
|
||||||
|
outputRange: [theme.colors.inversePrimary, theme.colors.primaryContainer],
|
||||||
|
});
|
||||||
|
|
||||||
|
const pulseColorOnTheWay = getPulseColor(pulseAnimOnTheWay);
|
||||||
|
const pulseColorArrived = getPulseColor(pulseAnimArrived);
|
||||||
|
|
||||||
|
// Function to handle status change
|
||||||
|
const handleStatusPress = async (status: string) => {
|
||||||
|
try {
|
||||||
|
if (currentStatus === status) {
|
||||||
|
// If pressed again, send "none" status and clear currentStatus
|
||||||
|
log.debug(`Removing status: ${status}`);
|
||||||
|
const message: Message = {
|
||||||
|
Id: id,
|
||||||
|
Name: name,
|
||||||
|
Image: image,
|
||||||
|
Status: "none",
|
||||||
|
Theme: currentTheme,
|
||||||
|
Timestamp: new Date().toISOString()
|
||||||
|
};
|
||||||
|
await axios.post(API_URL + "/set", message);
|
||||||
|
setTimeout(() => {
|
||||||
|
setStatus("none"); // Reset status
|
||||||
|
}, 0)
|
||||||
|
} else {
|
||||||
|
// Otherwise, send the new status
|
||||||
|
log.debug(`Setting status: ${status}`);
|
||||||
|
const message: Message = {
|
||||||
|
Id: id,
|
||||||
|
Name: name,
|
||||||
|
Image: image,
|
||||||
|
Status: status,
|
||||||
|
Theme: currentTheme,
|
||||||
|
Timestamp: new Date().toISOString()
|
||||||
|
};
|
||||||
|
await axios.post(API_URL + "/set", message);
|
||||||
|
setTimeout(() => {
|
||||||
|
setStatus(status);
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log.error(`Error sending status '${status}':`, error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determine the button label based on whether it's animating
|
||||||
|
const getButtonLabel = (status: string) => {
|
||||||
|
if (status === "On the Way") return currentStatus === "On the Way" ? "Traveling" : "On the way";
|
||||||
|
if (status === "Arrived") return currentStatus === "Arrived" ? "At the dog park" : "Arrived";
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (lastMessage?.data) {
|
||||||
|
try {
|
||||||
|
const newMessage: Message = JSON.parse(lastMessage.data);
|
||||||
|
log.debug("Current Status", currentStatus);
|
||||||
|
setMessages((prev) => {
|
||||||
|
if (newMessage.Id === id && newMessage.Status !== currentStatus) {
|
||||||
|
log.debug("Status different, change to: ", newMessage.Status);
|
||||||
|
setTimeout(() => {
|
||||||
|
setStatus(newMessage.Status);
|
||||||
|
}, 0);
|
||||||
|
//return prev.filter((msg) => msg.Id !== newMessage.Id);
|
||||||
|
}else{
|
||||||
|
log.debug("Status equal, no change");
|
||||||
|
}
|
||||||
|
return prev.filter((msg) => msg.Id !== newMessage.Id).concat(newMessage);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Error parsing WebSocket message:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [lastMessage, setStatus, id]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={[styles.container, isProfileActive && { display: 'none' }]}>
|
||||||
|
<ImageBackground source={require('../assets/images/bg.webp')} style={styles.imageBackground} />
|
||||||
|
<View style={styles.listContainer}>
|
||||||
|
<List.Section style={styles.listColumn}>
|
||||||
|
<List.Subheader style={[styles.listSubheader, { color: theme.colors.primary }]}>On the Way</List.Subheader>
|
||||||
|
<ScrollView>
|
||||||
|
{messages.filter(msg => msg.Status === "On the Way")
|
||||||
|
.sort((a, b) => new Date(a.Timestamp).getTime() - new Date(b.Timestamp).getTime())
|
||||||
|
.map(item => (
|
||||||
|
<List.Item
|
||||||
|
key={item.Id}
|
||||||
|
title={item.Name}
|
||||||
|
titleStyle={{ color: themes[item.Theme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'].colors.primary, fontFamily: "SpaceBold" }}
|
||||||
|
style={[styles.card, { backgroundColor: themes[item.Theme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'].colors.primaryContainer }]}
|
||||||
|
description={new Date(item.Timestamp).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit', hour12: true })}
|
||||||
|
descriptionStyle={{ color: themes[item.Theme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'].colors.primary, fontFamily: "SpaceReg" }}
|
||||||
|
left={(props) => <Avatar.Image {...props} size={50} source={{ uri: `data:image/png;base64,${item.Image}` }} />}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ScrollView>
|
||||||
|
</List.Section>
|
||||||
|
<List.Section style={styles.listColumn}>
|
||||||
|
<List.Subheader style={[styles.listSubheader, { color: theme.colors.primary }]}>Arrived</List.Subheader>
|
||||||
|
<ScrollView>
|
||||||
|
{messages.filter(msg => msg.Status === "Arrived")
|
||||||
|
.sort((a, b) => new Date(a.Timestamp).getTime() - new Date(b.Timestamp).getTime())
|
||||||
|
.map(item => (
|
||||||
|
<List.Item
|
||||||
|
key={item.Id}
|
||||||
|
title={item.Name}
|
||||||
|
titleStyle={{ color: themes[item.Theme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'].colors.primary, fontFamily: "SpaceBold" }}
|
||||||
|
style={[styles.card, { backgroundColor: themes[item.Theme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'].colors.primaryContainer }]}
|
||||||
|
description={new Date(item.Timestamp).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit', hour12: true })}
|
||||||
|
descriptionStyle={{ color: themes[item.Theme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'].colors.primary, fontFamily: "SpaceReg" }}
|
||||||
|
left={(props) => <Avatar.Image {...props} size={50} source={{ uri: `data:image/png;base64,${item.Image}` }} />}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ScrollView>
|
||||||
|
</List.Section>
|
||||||
|
</View>
|
||||||
|
<View style={styles.buttonContainer}>
|
||||||
|
<Button
|
||||||
|
mode="contained"
|
||||||
|
onPress={() => handleStatusPress("On the Way")}
|
||||||
|
style={[
|
||||||
|
styles.actionButton,
|
||||||
|
{ backgroundColor: currentStatus === "On the Way" ? pulseColorOnTheWay : theme.colors.primaryContainer }
|
||||||
|
]}
|
||||||
|
labelStyle={{ color: theme.colors.primary, fontFamily: "Medium", fontSize: 16 }}>
|
||||||
|
{getButtonLabel("On the Way")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
mode="contained"
|
||||||
|
onPress={() => handleStatusPress("Arrived")}
|
||||||
|
style={[
|
||||||
|
styles.actionButton,
|
||||||
|
{ backgroundColor: currentStatus === "Arrived" ? pulseColorArrived : theme.colors.primaryContainer }
|
||||||
|
]}
|
||||||
|
labelStyle={{ color: theme.colors.primary, fontFamily: "Medium", fontSize: 16 }}>
|
||||||
|
{getButtonLabel("Arrived")}
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Status;
|
75
components/TopNav.tsx
Normal file
75
components/TopNav.tsx
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import {Appbar, Portal, Button, Dialog, Menu, useTheme} from "react-native-paper";
|
||||||
|
import {Image, useColorScheme, View} from "react-native";
|
||||||
|
import React, {useState} from "react";
|
||||||
|
import styles from "@/assets/styles";
|
||||||
|
import About from "@/components/About";
|
||||||
|
import Privacy from "@/components/Privacy";
|
||||||
|
import Broken from "@/components/Broken";
|
||||||
|
|
||||||
|
const TopNav = ({ toggleProfile }: { toggleProfile: () => void; }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const colorScheme = useColorScheme();
|
||||||
|
const [aboutVisible, setAboutVisible] = useState(false);
|
||||||
|
const [privacyVisible, setPrivacyVisible] = useState(false);
|
||||||
|
const [bugVisible, setBugVisible] = useState(false);
|
||||||
|
const [menuVisible, setMenuVisible] = useState(false);
|
||||||
|
const [menuAnchor, setMenuAnchor] = useState<{ x: number; y: number } | null>(null);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={{ backgroundColor: theme.colors.background }}>
|
||||||
|
<Appbar.Header style={[styles.topBar, { backgroundColor: theme.colors.primaryContainer }]}>
|
||||||
|
<View>
|
||||||
|
<Menu visible={menuVisible} onDismiss={() => setMenuVisible(false)} anchor={menuAnchor} style={{ backgroundColor: theme.colors.primaryContainer }}>
|
||||||
|
<Menu.Item onPress={() => { setMenuVisible(false); setAboutVisible(true);}} title="About Us" style={{ backgroundColor: theme.colors.primaryContainer }}/>
|
||||||
|
<Menu.Item onPress={() => { setMenuVisible(false); setPrivacyVisible(true);}} title="Privacy Policy" style={{ backgroundColor: theme.colors.primaryContainer }}/>
|
||||||
|
<Menu.Item onPress={() => { setMenuVisible(false); setBugVisible(true);}} title="Report a Bug" style={{ backgroundColor: theme.colors.primaryContainer }}/>
|
||||||
|
</Menu>
|
||||||
|
<Appbar.Action icon="menu"
|
||||||
|
onPressIn={(event) => {
|
||||||
|
setMenuAnchor({ x: event.nativeEvent.pageX, y: event.nativeEvent.pageY + 40 });
|
||||||
|
setMenuVisible(true);
|
||||||
|
}}
|
||||||
|
iconColor={theme.colors.primary} />
|
||||||
|
</View>
|
||||||
|
<View style={styles.logoContainer} >
|
||||||
|
<Image source={
|
||||||
|
colorScheme === 'dark' ?
|
||||||
|
require("../assets/images/pogdark_logo_inverse.png") : require("../assets/images/pogdark_logo.png")
|
||||||
|
} style={styles.logo} resizeMode={"contain"} />
|
||||||
|
</View>
|
||||||
|
<Appbar.Action icon="pencil" onPress={toggleProfile} iconColor={ theme.colors.primary } />
|
||||||
|
</Appbar.Header>
|
||||||
|
<Portal>
|
||||||
|
<Dialog visible={aboutVisible} onDismiss={() => setAboutVisible(false)} style={{ backgroundColor: theme.colors.primaryContainer }}>
|
||||||
|
<Dialog.Title style={{ color: theme.colors.primary, textAlign: 'center' }}>About Us</Dialog.Title>
|
||||||
|
<About />
|
||||||
|
<Dialog.Actions style={{ justifyContent: "center" }}>
|
||||||
|
<Button onPress={() => setAboutVisible(false)} mode="contained" style={{ backgroundColor: theme.colors.inversePrimary }} labelStyle={{ color: theme.colors.primary }}>
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</Dialog.Actions>
|
||||||
|
</Dialog>
|
||||||
|
<Dialog visible={privacyVisible} onDismiss={() => setPrivacyVisible(false)} style={{ backgroundColor: theme.colors.primaryContainer }}>
|
||||||
|
<Dialog.Title style={{ color: theme.colors.primary, textAlign: 'center' }}>Privacy Policy</Dialog.Title>
|
||||||
|
<Privacy />
|
||||||
|
<Dialog.Actions style={{ justifyContent: "center" }}>
|
||||||
|
<Button onPress={() => setPrivacyVisible(false)} mode="contained" style={{ backgroundColor: theme.colors.inversePrimary }} labelStyle={{ color: theme.colors.primary }}>
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</Dialog.Actions>
|
||||||
|
</Dialog>
|
||||||
|
<Dialog visible={bugVisible} onDismiss={() => setBugVisible(false)} style={{ backgroundColor: theme.colors.primaryContainer }}>
|
||||||
|
<Dialog.Title style={{ color: theme.colors.primary, textAlign: 'center' }}>Report A Bug</Dialog.Title>
|
||||||
|
<Broken />
|
||||||
|
<Dialog.Actions style={{ justifyContent: "center" }}>
|
||||||
|
<Button onPress={() => setBugVisible(false)} mode="contained" style={{ backgroundColor: theme.colors.inversePrimary }} labelStyle={{ color: theme.colors.primary }}>
|
||||||
|
Close
|
||||||
|
</Button>
|
||||||
|
</Dialog.Actions>
|
||||||
|
</Dialog>
|
||||||
|
</Portal>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TopNav;
|
158
context/UserContext.tsx
Normal file
158
context/UserContext.tsx
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
import React, { createContext, useContext, useEffect, useState, ReactNode } from "react";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
|
import { AppState } from "react-native";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
import axios from "axios";
|
||||||
|
import log from "@/util/log"
|
||||||
|
|
||||||
|
export const API_URL = process.env.EXPO_PUBLIC_API_URL;
|
||||||
|
|
||||||
|
// Define context type
|
||||||
|
interface UserContextType {
|
||||||
|
isProfileActive: boolean;
|
||||||
|
setProfileActive: (active: boolean) => void;
|
||||||
|
userId: string;
|
||||||
|
userName: string;
|
||||||
|
setUserName: (name: string) => void;
|
||||||
|
userImage: string;
|
||||||
|
setUserImage: (image: string) => void;
|
||||||
|
userStatus: string;
|
||||||
|
setUserStatus: (status: string) => void;
|
||||||
|
setUserDataChanged: (changed: boolean) => void;
|
||||||
|
isLoading: boolean;
|
||||||
|
currentTheme: string;
|
||||||
|
setTheme: (theme: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create context with default values
|
||||||
|
const UserContext = createContext<UserContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
// Define provider props type
|
||||||
|
interface UserProviderProps {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const UserProvider: React.FC<UserProviderProps> = ({ children }) => {
|
||||||
|
const [isProfileActive, setProfileActive] = useState(false);
|
||||||
|
const [userId, setUserId] = useState("");
|
||||||
|
const [userName, setUserName] = useState("");
|
||||||
|
const [userImage, setUserImage] = useState("");
|
||||||
|
const [userStatus, setUserStatus] = useState("none");
|
||||||
|
const [userDataChanged, setUserDataChanged] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [appState, setAppState] = useState(AppState.currentState);
|
||||||
|
const [currentTheme, setTheme] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadUserData = async () => {
|
||||||
|
try {
|
||||||
|
const storedUserId = await AsyncStorage.getItem("userId");
|
||||||
|
const storedUserName = await AsyncStorage.getItem("userName");
|
||||||
|
const storedUserImage = await AsyncStorage.getItem("userImage");
|
||||||
|
const storedUserTheme = await AsyncStorage.getItem("theme");
|
||||||
|
log.debug("Stored theme: ", storedUserTheme);
|
||||||
|
if (storedUserId) {
|
||||||
|
setUserId(storedUserId);
|
||||||
|
setUserName(storedUserName || "");
|
||||||
|
setUserImage(storedUserImage || "");
|
||||||
|
setTheme(storedUserTheme || "blue");
|
||||||
|
setProfileActive(false);
|
||||||
|
} else {
|
||||||
|
setUserId(uuidv4());
|
||||||
|
setUserName("");
|
||||||
|
setUserImage("");
|
||||||
|
setTheme("blue")
|
||||||
|
setProfileActive(true);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Error loading user data:", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void loadUserData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!userDataChanged) return;
|
||||||
|
|
||||||
|
const saveUserData = async () => {
|
||||||
|
try {
|
||||||
|
await AsyncStorage.setItem("userId", userId);
|
||||||
|
await AsyncStorage.setItem("userName", userName);
|
||||||
|
await AsyncStorage.setItem("userImage", userImage);
|
||||||
|
await AsyncStorage.setItem("theme", currentTheme);
|
||||||
|
log.debug("Current theme: ", currentTheme);
|
||||||
|
setUserDataChanged(false);
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Error saving user data:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void saveUserData();
|
||||||
|
}, [userDataChanged]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleAppStateChange = (nextAppState: string) => {
|
||||||
|
if (appState.match(/inactive|background/) && nextAppState === "active") {
|
||||||
|
if (!isLoading) {
|
||||||
|
void fetchCurrentStatus();
|
||||||
|
} else {
|
||||||
|
log.debug("Waiting for loading to complete before fetching status...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setAppState(AppState.currentState);
|
||||||
|
};
|
||||||
|
|
||||||
|
const listener = AppState.addEventListener("change", handleAppStateChange);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
listener.remove();
|
||||||
|
};
|
||||||
|
}, [appState]);
|
||||||
|
|
||||||
|
const fetchCurrentStatus = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(API_URL + "/get", { id: userId });
|
||||||
|
if (response.data?.status) {
|
||||||
|
setTimeout(() => {
|
||||||
|
setUserStatus("none");
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Error fetching status:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UserContext.Provider
|
||||||
|
value={{
|
||||||
|
isProfileActive,
|
||||||
|
setProfileActive,
|
||||||
|
userId,
|
||||||
|
userName,
|
||||||
|
setUserName,
|
||||||
|
userImage,
|
||||||
|
setUserImage,
|
||||||
|
userStatus,
|
||||||
|
setUserStatus,
|
||||||
|
setUserDataChanged,
|
||||||
|
isLoading,
|
||||||
|
currentTheme,
|
||||||
|
setTheme,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</UserContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Custom hook to use context
|
||||||
|
export const useUser = (): UserContextType => {
|
||||||
|
const context = useContext(UserContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error("useUser must be used within a UserProvider");
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
};
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -13,7 +13,7 @@
|
|||||||
"@react-native-async-storage/async-storage": "~2.1.1",
|
"@react-native-async-storage/async-storage": "~2.1.1",
|
||||||
"@react-navigation/bottom-tabs": "^7.2.0",
|
"@react-navigation/bottom-tabs": "^7.2.0",
|
||||||
"@react-navigation/native": "^7.0.14",
|
"@react-navigation/native": "^7.0.14",
|
||||||
"axios": "~1.7.9",
|
"axios": "~1.8.4",
|
||||||
"expo": "~52.0.25",
|
"expo": "~52.0.25",
|
||||||
"expo-blur": "~14.0.2",
|
"expo-blur": "~14.0.2",
|
||||||
"expo-constants": "~17.0.4",
|
"expo-constants": "~17.0.4",
|
||||||
@ -30,8 +30,8 @@
|
|||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-native": "0.77.1",
|
"react-native": "0.77.1",
|
||||||
"react-native-config": "~1.5.5",
|
|
||||||
"react-native-gesture-handler": "~2.20.2",
|
"react-native-gesture-handler": "~2.20.2",
|
||||||
|
"react-native-logs": "~5.3.0",
|
||||||
"react-native-paper": "~5.13.1",
|
"react-native-paper": "~5.13.1",
|
||||||
"react-native-reanimated": "~3.16.1",
|
"react-native-reanimated": "~3.16.1",
|
||||||
"react-native-safe-area-context": "4.12.0",
|
"react-native-safe-area-context": "4.12.0",
|
||||||
@ -5197,9 +5197,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.7.9",
|
"version": "1.8.4",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz",
|
||||||
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
"integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.6",
|
"follow-redirects": "^1.15.6",
|
||||||
@ -12430,20 +12430,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-native-config": {
|
|
||||||
"version": "1.5.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-native-config/-/react-native-config-1.5.5.tgz",
|
|
||||||
"integrity": "sha512-dGdLnBU0cd5xL5bF0ROTmHYbsstZnQKOEPfglvZi1vStvAjpld14X25K6mY3KGPTMWAzx6TbjKeq5dR+ILuMMA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"peerDependencies": {
|
|
||||||
"react-native-windows": ">=0.61"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"react-native-windows": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/react-native-gesture-handler": {
|
"node_modules/react-native-gesture-handler": {
|
||||||
"version": "2.20.2",
|
"version": "2.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.20.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.20.2.tgz",
|
||||||
@ -12484,6 +12470,12 @@
|
|||||||
"react-native": ">=0.73.0"
|
"react-native": ">=0.73.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-native-logs": {
|
||||||
|
"version": "5.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-native-logs/-/react-native-logs-5.3.0.tgz",
|
||||||
|
"integrity": "sha512-tq4S0JFy06ggu1D/udYeV80qPy5koURNNcKrVJmv0Hf3x44akysctaE4ARybD5Pv7MnFD8fP1VFhycSLjqXHQw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/react-native-paper": {
|
"node_modules/react-native-paper": {
|
||||||
"version": "5.13.1",
|
"version": "5.13.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-paper/-/react-native-paper-5.13.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-paper/-/react-native-paper-5.13.1.tgz",
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-native": "0.77.1",
|
"react-native": "0.77.1",
|
||||||
"react-native-gesture-handler": "~2.20.2",
|
"react-native-gesture-handler": "~2.20.2",
|
||||||
|
"react-native-logs": "~5.3.0",
|
||||||
"react-native-reanimated": "~3.16.1",
|
"react-native-reanimated": "~3.16.1",
|
||||||
"react-native-safe-area-context": "4.12.0",
|
"react-native-safe-area-context": "4.12.0",
|
||||||
"react-native-screens": "~4.4.0",
|
"react-native-screens": "~4.4.0",
|
||||||
@ -42,7 +43,7 @@
|
|||||||
"react-use-websocket": "~4.13.0",
|
"react-use-websocket": "~4.13.0",
|
||||||
"@react-native-async-storage/async-storage": "~2.1.1",
|
"@react-native-async-storage/async-storage": "~2.1.1",
|
||||||
"expo-image-picker": "~16.0.6",
|
"expo-image-picker": "~16.0.6",
|
||||||
"axios": "~1.7.9",
|
"axios": "~1.8.4",
|
||||||
"uuid": "~11.0.5",
|
"uuid": "~11.0.5",
|
||||||
"react-native-paper": "~5.13.1",
|
"react-native-paper": "~5.13.1",
|
||||||
"react-native-vector-icons": "~10.2.0",
|
"react-native-vector-icons": "~10.2.0",
|
||||||
|
BIN
public/favicon.png
Normal file
BIN
public/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
2
public/robots.txt
Normal file
2
public/robots.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
User-agent: *
|
||||||
|
Disallow: /
|
5
util/featureFlags.ts
Normal file
5
util/featureFlags.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const featureFlags = {
|
||||||
|
enableThemeSelection: true, // Toggle this to true or false to enable/disable the feature
|
||||||
|
};
|
||||||
|
|
||||||
|
export default featureFlags;
|
7
util/log.ts
Normal file
7
util/log.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { logger } from "react-native-logs";
|
||||||
|
|
||||||
|
const log = logger.createLogger({
|
||||||
|
severity: "error"
|
||||||
|
});
|
||||||
|
|
||||||
|
export default log;
|
Loading…
Reference in New Issue
Block a user