Skip to content

Commit 86d75b5

Browse files
committed
Rework Microsoft Login prompt to remove tap bugs.
1 parent 0b275ff commit 86d75b5

File tree

1 file changed

+28
-42
lines changed

1 file changed

+28
-42
lines changed

src/components/accounts/MicrosoftLogin.tsx

+28-42
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import React, { useContext, useRef, useState } from 'react'
2-
import {
3-
StyleSheet,
4-
Modal,
5-
Platform,
6-
PlatformAndroidStatic,
7-
KeyboardAvoidingView,
8-
View
9-
} from 'react-native'
2+
import { StyleSheet, Modal, Platform, View } from 'react-native'
3+
import Ionicons from 'react-native-vector-icons/Ionicons'
104
import { WebView, WebViewNavigation } from 'react-native-webview'
115

126
import useDarkMode from '../../context/useDarkMode'
@@ -131,57 +125,49 @@ const MicrosoftLogin = ({ close }: { close: () => void }) => {
131125
const uri = loginUrl
132126
.replace('{CLIENT_ID}', config.clientId)
133127
.replace('{SCOPE}', encodeURIComponent(config.scope))
128+
// Turns out WebView modals are broken on more than Pixel, so we have a full-screen view now.
134129
return (
135130
<Modal
136131
animationType='fade'
137132
transparent
138133
visible
139-
statusBarTranslucent
134+
statusBarTranslucent={false}
140135
onRequestClose={onRequestClose}
141136
>
142-
<KeyboardAvoidingView
143-
enabled
144-
behavior='padding'
145-
style={styles.modalView}
146-
// https://stackoverflow.com/a/60254214
147-
onStartShouldSetResponder={event => {
148-
const { constants } = Platform as PlatformAndroidStatic
149-
return (
150-
event.nativeEvent.touches.length === 1 &&
151-
// FIXME: Don't handle touch events for Google Pixel devices.
152-
constants.Manufacturer !== 'Google' &&
153-
constants.Brand !== 'google'
154-
)
155-
}}
156-
onResponderRelease={event => {
157-
if (event.target === event.currentTarget) onRequestClose()
158-
}}
159-
>
160-
<View style={styles.webViewContainer}>
161-
<WebView
162-
incognito
163-
ref={webview}
164-
originWhitelist={['*']}
165-
source={html ? { html } : { uri }}
166-
onNavigationStateChange={ev => {
167-
handleNavigationStateChange(ev).catch(console.error)
168-
}}
169-
/>
137+
<View style={styles.modalView}>
138+
<View
139+
style={[
140+
darkMode ? styles.modalTopBarDarkBg : styles.modalTopBarLightBg,
141+
styles.modalTopBar
142+
]}
143+
>
144+
<Ionicons.Button name='close' onPress={onRequestClose}>
145+
Close
146+
</Ionicons.Button>
170147
</View>
171-
</KeyboardAvoidingView>
148+
<WebView
149+
incognito
150+
ref={webview}
151+
originWhitelist={['*']}
152+
source={html ? { html } : { uri }}
153+
onNavigationStateChange={ev => {
154+
handleNavigationStateChange(ev).catch(console.error)
155+
}}
156+
/>
157+
</View>
172158
</Modal>
173159
)
174160
}
175161

176162
const styles = StyleSheet.create({
177163
modalView: {
178164
flex: 1,
179-
alignItems: 'center',
180-
justifyContent: 'center',
181165
height: '100%',
182-
backgroundColor: 'rgba(0, 0, 0, 0.6)'
166+
width: '100%'
183167
},
184-
webViewContainer: { height: '80%', width: '80%' }
168+
modalTopBarLightBg: { backgroundColor: '#ffffff' },
169+
modalTopBarDarkBg: { backgroundColor: '#242424' },
170+
modalTopBar: { padding: 8, flexDirection: 'row' }
185171
})
186172

187173
export default MicrosoftLogin

0 commit comments

Comments
 (0)