Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Improve dialog styling on large and notched screens #10470

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7d043b3
Refactor: Rename CustomButton -> IconButton
personalizedrefrigerator May 14, 2024
6c9f8cb
Make card and button styles closer to the original design
personalizedrefrigerator May 16, 2024
5e946c3
Make plugin screen styles (but not yet layout) closer to the Figma
personalizedrefrigerator May 17, 2024
cc7aa45
Make chip styles closer to desktop
personalizedrefrigerator May 17, 2024
7aa2395
Fix TextButton spacing when showing loading animation
personalizedrefrigerator May 17, 2024
8411b2d
Fix padding when buttons have an icon
personalizedrefrigerator May 17, 2024
8002ce1
Start restyling the about modal
personalizedrefrigerator May 17, 2024
e8afcc4
Restyle and add enable button to info modal
personalizedrefrigerator May 18, 2024
6d5d994
Add delete button to info modal, minor refactoring
personalizedrefrigerator May 20, 2024
f2ab7d8
Revert to unstyled RN Paper widgets in most cases
personalizedrefrigerator May 20, 2024
99b3dea
WIP
personalizedrefrigerator May 21, 2024
9b2f48f
Plugin info modal: Mostly functional
personalizedrefrigerator May 23, 2024
006e07c
Fix dialog size in landscape mode
personalizedrefrigerator May 23, 2024
6279841
Change style of "report an issue" to better match design
personalizedrefrigerator May 23, 2024
00d285f
Restyle "install from file
personalizedrefrigerator May 23, 2024
c77be22
Slightly decrease size of plugin chips
personalizedrefrigerator May 23, 2024
4f35657
Fix error chip, adjust global styles to simplify changes
personalizedrefrigerator May 23, 2024
cca5ebc
Adjust chip and card title styles
personalizedrefrigerator May 23, 2024
d5d3a62
Ignore auto-generated file
personalizedrefrigerator May 23, 2024
ac5b9c6
Add a disabled chip
personalizedrefrigerator May 23, 2024
360a3b8
Refactor plugin search to re-use the install handler created in
personalizedrefrigerator May 23, 2024
77a6784
Add search results text
personalizedrefrigerator May 23, 2024
c364690
Fix test compilation (running still failing)
personalizedrefrigerator May 24, 2024
81fb684
Fix several tests (many still broken)
personalizedrefrigerator May 24, 2024
e7bfe06
Try to reduce number of warnings during testing
personalizedrefrigerator May 24, 2024
4639da8
Fix tests
personalizedrefrigerator May 24, 2024
75a3e93
Adjust loading indicator
personalizedrefrigerator May 24, 2024
8d95787
Wrap installed and search sections in different accordion groups
personalizedrefrigerator May 24, 2024
d4799f3
Use correct singular/plural description for installed plugins accordi…
personalizedrefrigerator May 24, 2024
dda04ed
Search: Use data from installed plugins, when available
personalizedrefrigerator May 24, 2024
91cbaa3
Fix desktop build
personalizedrefrigerator May 24, 2024
4fdb5f7
Adjust modal styles
personalizedrefrigerator May 24, 2024
106d453
Simplify primary button default colors
personalizedrefrigerator May 24, 2024
56ffd13
Fix failing test
personalizedrefrigerator May 24, 2024
21a3c36
Revert non-dialog-related changes
personalizedrefrigerator May 24, 2024
88c8521
Reset changes to packages/tools
personalizedrefrigerator May 24, 2024
4a6d490
Reset da_DK.po to upstream/dev
personalizedrefrigerator May 24, 2024
82882de
Fix tag and link dialogs, while maintianing updated container styles
personalizedrefrigerator May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/app-mobile/components/DismissibleDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ const useStyles = (themeId: number, containerStyle: ViewStyle) => {

height: windowSize.height * 0.9,
width: windowSize.width * 0.97,
flexShrink: 1,

// Center
marginLeft: 'auto',
marginRight: 'auto',

...containerStyle,
},
dialogContainer: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
flexGrow: 1,
},
});
}, [themeId, windowSize.width, windowSize.height, containerStyle]);
};
Expand All @@ -69,7 +77,9 @@ const DismissibleDialog: React.FC<Props> = props => {
visible={props.visible}
onDismiss={props.onDismiss}
onRequestClose={props.onDismiss}
containerStyle={styles.dialogContainer}
animationType='fade'
backgroundColor='rgba(0, 0, 0, 0.1)'
transparent={true}
>
<Surface style={styles.dialog} elevation={1}>
Expand Down
46 changes: 34 additions & 12 deletions packages/app-mobile/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,58 @@
import * as React from 'react';
import { Modal, ModalProps, StyleSheet, View, ViewStyle } from 'react-native';
import { useMemo } from 'react';
import { Modal, ModalProps, StyleSheet, View, ViewStyle, useWindowDimensions } from 'react-native';
import { hasNotch } from 'react-native-device-info';

interface ModalElementProps extends ModalProps {
children: React.ReactNode;
containerStyle?: ViewStyle;
elevation?: number;
backgroundColor?: string;
}

const useStyles = (backgroundColor?: string) => {
const { width: windowWidth, height: windowHeight } = useWindowDimensions();
const isLandscape = windowWidth > windowHeight;
return useMemo(() => {
return StyleSheet.create({
contentWrapper: isLandscape ? {
marginRight: hasNotch() ? 60 : 0,
marginLeft: hasNotch() ? 60 : 0,
marginTop: 15,
marginBottom: 15,
} : {
marginTop: hasNotch() ? 65 : 15,
marginBottom: hasNotch() ? 35 : 15,
},
modalBackground: { backgroundColor, flexGrow: 1 },
});
}, [isLandscape, backgroundColor]);
};

const ModalElement: React.FC<ModalElementProps> = ({
children,
containerStyle,
backgroundColor,
...modalProps
}) => {
const styles = useStyles(backgroundColor);

// contentWrapper adds padding. To allow styling the region outside of the modal
// (e.g. to add a background), the content is wrapped twice.
const content = (
<View style={[styles.contentWrapper, containerStyle]}>
{children}
</View>
);

// supportedOrientations: On iOS, this allows the dialog to be shown in non-portrait orientations.
return (
<Modal
supportedOrientations={['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right']}
{...modalProps}
>
<View style={[styleSheet.modalContainer, containerStyle ? containerStyle : null]}>
{children}
</View>
<View style={styles.modalBackground}>{content}</View>
</Modal>
);
};

const styleSheet = StyleSheet.create({
modalContainer: {
marginTop: hasNotch() ? 65 : 15,
marginBottom: hasNotch() ? 35 : 15,
},
});

export default ModalElement;
Loading