-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix modal height * Change files * reverse change * add override
- Loading branch information
1 parent
bb2851e
commit 1529ea5
Showing
4 changed files
with
158 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-d345ae30-34cd-425c-97ac-fdf1c22fc508.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "fix modal height", | ||
"packageName": "react-native-windows", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
packages/@react-native-windows/tester/src/js/examples/Modal/ModalOnShow.windows.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import RNTesterText from '../../components/RNTesterText'; | ||
import * as React from 'react'; | ||
import {useState} from 'react'; | ||
import {Modal, Pressable, StyleSheet, Text, View} from 'react-native'; | ||
|
||
function ModalOnShowOnDismiss(): React.Node { | ||
const [modalShowComponent, setModalShowComponent] = useState(true); | ||
const [modalVisible, setModalVisible] = useState(false); | ||
const [onShowCount, setOnShowCount] = useState(0); | ||
const [onDismissCount, setOnDismissCount] = useState(0); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
{modalShowComponent && ( | ||
<Modal | ||
animationType="slide" | ||
transparent={true} | ||
visible={modalVisible} | ||
onShow={() => { | ||
setOnShowCount(showCount => showCount + 1); | ||
}} | ||
onDismiss={() => { | ||
setOnDismissCount(dismissCount => dismissCount + 1); | ||
}} | ||
onRequestClose={() => { | ||
setModalVisible(false); | ||
}}> | ||
<View style={[styles.centeredView, styles.modalBackdrop]}> | ||
<View style={styles.modalView}> | ||
<Text testID="modal-on-show-count"> | ||
onShow is called {onShowCount} times | ||
</Text> | ||
<Text testID="modal-on-dismiss-count"> | ||
onDismiss is called {onDismissCount} times | ||
</Text> | ||
<Pressable | ||
style={[styles.button, styles.buttonClose]} | ||
onPress={() => setModalVisible(false)}> | ||
<Text testID="dismiss-modal" style={styles.textStyle}> | ||
Hide modal by setting visible to false | ||
</Text> | ||
</Pressable> | ||
<Pressable | ||
style={[styles.button, styles.buttonClose]} | ||
onPress={() => setModalShowComponent(false)}> | ||
<Text | ||
testID="dismiss-modal-by-removing-component" | ||
style={styles.textStyle}> | ||
Hide modal by removing component | ||
</Text> | ||
</Pressable> | ||
</View> | ||
</View> | ||
</Modal> | ||
)} | ||
<RNTesterText testID="on-show-count"> | ||
onShow is called {onShowCount} times | ||
</RNTesterText> | ||
<RNTesterText testID="on-dismiss-count"> | ||
onDismiss is called {onDismissCount} times | ||
</RNTesterText> | ||
<Pressable | ||
style={[styles.button, styles.buttonOpen]} | ||
onPress={() => { | ||
setModalShowComponent(true); | ||
setModalVisible(true); | ||
}}> | ||
<Text testID="open-modal" style={styles.textStyle}> | ||
Show Modal | ||
</Text> | ||
</Pressable> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
paddingVertical: 30, | ||
}, | ||
centeredView: { | ||
// flex: 1, // [Windows] - This will cause the modal to stretch to be as tall as the availiable space given to it. | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
modalBackdrop: { | ||
backgroundColor: 'rgba(0, 0, 0, 0.5)', | ||
}, | ||
modalView: { | ||
margin: 20, | ||
borderRadius: 20, | ||
padding: 35, | ||
alignItems: 'center', | ||
shadowColor: '#000', | ||
shadowOffset: { | ||
width: 0, | ||
height: 2, | ||
}, | ||
shadowOpacity: 0.25, | ||
shadowRadius: 4, | ||
elevation: 5, | ||
}, | ||
button: { | ||
borderRadius: 20, | ||
padding: 10, | ||
marginVertical: 20, | ||
elevation: 2, | ||
}, | ||
buttonOpen: { | ||
backgroundColor: '#F194FF', | ||
}, | ||
buttonClose: { | ||
backgroundColor: '#2196F3', | ||
}, | ||
textStyle: { | ||
color: 'white', | ||
fontWeight: 'bold', | ||
textAlign: 'center', | ||
}, | ||
}); | ||
|
||
export default ({ | ||
title: "Modal's onShow/onDismiss", | ||
name: 'onShow', | ||
description: | ||
'onShow and onDismiss (iOS only) callbacks are called when a modal is shown/dismissed', | ||
render: (): React.Node => <ModalOnShowOnDismiss />, | ||
}: RNTesterModuleExample); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters