Skip to content

Commit

Permalink
feat: initial work on serer settings!
Browse files Browse the repository at this point in the history
related: #26
  • Loading branch information
Rexogamer committed Oct 28, 2023
1 parent 049500e commit 512bc52
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/Generic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ export const app = {
);
},
openSettings: o => {},
openServerSettings: (s: Server | null) => {
console.log(
`[FUNCTIONS] Tried to run uninitialised function openServerSettings (args: ${s})`,
);
},
setMessageBoxInput: t => {},
setReplyingMessages: (m: ReplyingMessage[]) => {
console.log(
Expand Down
14 changes: 13 additions & 1 deletion src/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {observer} from 'mobx-react-lite';
import ImageViewer from 'react-native-image-zoom-viewer';
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';

import {API, Channel, User} from 'revolt.js';
import {API, Channel, Server, User} from 'revolt.js';

import {app, client, openUrl, setFunction} from './Generic';
import {currentTheme} from './Theme';
Expand All @@ -19,6 +19,7 @@ import {
ReportSheet,
ServerInfoSheet,
ServerInviteSheet,
ServerSettingsSheet,
SettingsSheet,
StatusSheet,
} from './components/sheets/';
Expand All @@ -28,6 +29,7 @@ export const Modals = observer(() => {
i: null as any,
});
const [settingsVisibility, setSettingsVisibility] = React.useState(false);
const [serverSettingsServer, setServerSettingsServer] = React.useState(null as Server | null)
const [inviteServer, setInviteServer] = React.useState({
inviteServer: null,
inviteServerCode: '',
Expand All @@ -47,6 +49,9 @@ export const Modals = observer(() => {
setFunction('openSettings', async (o: boolean) => {
setSettingsVisibility(o);
});
setFunction('openServerSettings', async (s: Server | null) => {
setServerSettingsServer(s);
});
setFunction('openInvite', async (i: string) => {
try {
let community = await client.fetchInvite(i);
Expand Down Expand Up @@ -162,6 +167,13 @@ export const Modals = observer(() => {
bot={inviteBot!}
/>
</Modal>
<Modal
visible={!!serverSettingsServer}
transparent={true}
animationType="slide"
onRequestClose={() => setServerSettingsServer(null)}>
<ServerSettingsSheet server={serverSettingsServer!} setState={() => setServerSettingsServer(null)} />
</Modal>
</>
);
});
9 changes: 9 additions & 0 deletions src/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ function refreshStyles() {
textAlign: 'center',
marginTop: '30%',
},
serverSettingsInitials: {
borderRadius: 5000,
justifyContent: 'center',
alignItems: 'center',
width: 80,
height: 80,
backgroundColor: currentTheme.backgroundSecondary,
overflow: 'hidden',
},
serverIcon: {
width: 48,
height: 48,
Expand Down
41 changes: 28 additions & 13 deletions src/components/sheets/ServerInfoSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,40 +119,55 @@ export const ServerInfoSheet = observer(() => {
alignItems: 'center',
justifyContent: 'center',
}}>
{server.havePermission("ManageServer") ? (<ContextButton
key={'server-ctx-menu-settings'}
onPress={() => {
app.openServerSettings(server);
}}>
<View style={styles.iconContainer}>
<MaterialIcon
name={"settings"}
size={20}
color={currentTheme.foregroundPrimary}
/>
</View>
<Text>Server Settings</Text>
</ContextButton>) : null}
{app.settings.get('ui.showDeveloperFeatures') ? (
<CopyIDButton id={server._id} />
) : null}
{server.owner !== client.user?._id ? (
<>
<ContextButton
key={'server-ctx-menu-leave'}
onPress={async () => {
app.openServer();
<ContextButton
key={'server-ctx-menu-report'}
onPress={() => {
app.openReportMenu({object: server, type: 'Server'});
app.openServerContextMenu(null);
server.delete();
}}>
<View style={styles.iconContainer}>
<MaterialIcon
name="exit-to-app"
name="flag"
size={20}
color={currentTheme.error}
/>
</View>
<Text colour={currentTheme.error}>Leave Server</Text>
<Text colour={currentTheme.error}>Report Server</Text>
</ContextButton>
<ContextButton
key={'server-ctx-menu-report'}
onPress={() => {
app.openReportMenu({object: server, type: 'Server'});
key={'server-ctx-menu-leave'}
onPress={async () => {
app.openServer();
app.openServerContextMenu(null);
server.delete();
}}>
<View style={styles.iconContainer}>
<MaterialIcon
name="flag"
name="exit-to-app"
size={20}
color={currentTheme.foregroundPrimary}
color={currentTheme.error}
/>
</View>
<Text>Report Server</Text>
<Text colour={currentTheme.error}>Leave Server</Text>
</ContextButton>
</>
) : null}
Expand Down
Loading

0 comments on commit 512bc52

Please sign in to comment.