Skip to content

Commit 6f262cf

Browse files
committed
Added free-text input and issuer
1 parent 70a44e9 commit 6f262cf

File tree

4 files changed

+66
-29
lines changed

4 files changed

+66
-29
lines changed

Auth/AuthConfig.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ export default async function config(environment: AppEnvironment): Promise<AuthC
1717
const json = await response.json();
1818

1919
const config: AuthConfiguration = {
20-
// serviceConfiguration: {
21-
// authorizationEndpoint: environment.baseUrl + '/oauth/authorize',
22-
// tokenEndpoint: environment.baseUrl + '/oauth/token',
23-
// },
2420
issuer: environment.baseUrl,
2521
clientId: json.info.oAuthClients.reactNative.clientId,
2622
redirectUrl: 'org.robojackets.apiary://oauth',

Auth/EnvironmentSelect.tsx

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useState } from 'react';
2-
import { StyleSheet, Text, View } from 'react-native';
1+
import React, { useEffect, useState } from 'react';
2+
import { StyleSheet, Text, TextInput, View } from 'react-native';
33
import { Modal, RadioButton } from 'react-native-paper';
44
import { APP_ENVIRONMENTS, useAppEnvironment } from '../AppEnvironment';
55
import RoundedButton from '../Components/RoundedButton';
@@ -16,31 +16,63 @@ export default function EnvironmentSelect({
1616

1717
const {environment, setEnvironment} = useAppEnvironment();
1818
const [selectedEnv, setSelectedEnv] = useState<string>(environment.name.toLowerCase());
19+
const [customUrl, setCustomUrl] = useState<string>('');
1920

20-
return (
21-
<Modal visible={visible} onDismiss={onDismiss} contentContainerStyle={styles.sheet}>
22-
<Text style={styles.title}>Change Server</Text>
21+
useEffect(() => {
22+
if (visible) {
23+
setSelectedEnv(environment.name.toLowerCase());
24+
setCustomUrl('');
25+
}
26+
}, [visible]);
2327

24-
<RadioButton.Group onValueChange={setSelectedEnv} value={selectedEnv}>
25-
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 8 }}>
26-
<RadioButton.Android value="production" />
27-
<Text>Production</Text>
28-
</View>
29-
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 8 }}>
30-
<RadioButton.Android value="test" />
31-
<Text>Test</Text>
32-
</View>
33-
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 8 }}>
34-
<RadioButton.Android value="demo" />
35-
<Text>Demo</Text>
36-
</View>
37-
</RadioButton.Group>
28+
return (
29+
<Modal visible={visible} onDismiss={onDismiss} contentContainerStyle={styles.sheet}>
30+
<Text style={styles.title}>Change Server</Text>
31+
<RadioButton.Group onValueChange={setSelectedEnv} value={selectedEnv}>
32+
<View style={styles.row}>
33+
<RadioButton.Android value="production" />
34+
<Text>Production</Text>
35+
</View>
36+
<View style={styles.row}>
37+
<RadioButton.Android value="test" />
38+
<Text>Test</Text>
39+
</View>
40+
<View style={styles.row}>
41+
<RadioButton.Android value="demo" />
42+
<Text>Demo</Text>
43+
</View>
44+
<View style={styles.row}>
45+
<RadioButton.Android value="other" />
46+
<Text>Other</Text>
47+
</View>
48+
</RadioButton.Group>
3849

39-
<RoundedButton title="Save Changes" onPress={() => {
50+
{selectedEnv === "other" && (
51+
<TextInput
52+
style={styles.textInput}
53+
placeholder="Enter base URL"
54+
value={customUrl}
55+
onChangeText={setCustomUrl}
56+
/>
57+
)}
58+
59+
<RoundedButton title="Save Changes" onPress={() => {
60+
if (selectedEnv === "other") {
61+
if (!customUrl.trim()) {
62+
onDismiss();
63+
return;
64+
}
65+
setEnvironment({
66+
name: "Other",
67+
production: false,
68+
baseUrl: customUrl,
69+
});
70+
} else {
4071
setEnvironment(APP_ENVIRONMENTS[selectedEnv]);
41-
onDismiss();
42-
}} />
43-
</Modal>
72+
}
73+
onDismiss();
74+
}} />
75+
</Modal>
4476
);
4577
}
4678

@@ -60,4 +92,13 @@ const styles = StyleSheet.create({
6092
marginBottom: 16,
6193
textAlign: 'center',
6294
},
95+
row: {
96+
flexDirection: 'row',
97+
alignItems: 'center',
98+
marginBottom: 8,
99+
},
100+
textInput: {
101+
padding: 8,
102+
marginBottom: 12,
103+
},
63104
});

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"jwt-decode": "^4.0.0",
2222
"react": "19.1.0",
2323
"react-native": "0.80.1",
24-
"react-native-app-auth": "^8.0.3",
24+
"react-native-app-auth": "^8.1.0",
2525
"react-native-keychain": "^10.0.0",
2626
"react-native-nfc-manager": "^3.16.2",
2727
"react-native-paper": "^5.14.5",

0 commit comments

Comments
 (0)