Skip to content

Commit 4dd4c00

Browse files
committed
dynamic button width for message popup
1 parent 8794751 commit 4dd4c00

File tree

4 files changed

+306
-265
lines changed

4 files changed

+306
-265
lines changed

src/containers/MessageBox/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const MessageBox = () => {
2525
style={{
2626
position: "absolute",
2727
top: height / 2 - 90 - 25, // titlebar height is 25
28-
left: width / 2 - 160,
28+
left: width / 2 - Number(args.boxWidth) / 2,
2929
width: args.boxWidth,
3030
borderRadius: 4,
3131
backgroundColor: theme.listHeaderBackgroundColor,
@@ -81,6 +81,7 @@ const MessageBox = () => {
8181
style={{
8282
paddingHorizontal: 10,
8383
height: 30,
84+
width: args.buttonWidth,
8485
marginTop: 5,
8586
backgroundColor: theme.primary,
8687
borderRadius: 8,

src/states/messageModal.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface MessageBoxArgs {
88
onPress: () => void;
99
}[];
1010
boxWidth?: number;
11+
buttonWidth?: number;
1112
}
1213

1314
interface MessageModalState {
@@ -18,6 +19,7 @@ interface MessageModalState {
1819
}
1920

2021
const MESSAGE_BOX_WIDTH = 320;
22+
const MESSAGE_BOX_BUTTON_WIDTH = 120;
2123

2224
const useMessageBox = create<MessageModalState>()((set) => ({
2325
visible: false,
@@ -32,6 +34,9 @@ const useMessageBox = create<MessageModalState>()((set) => ({
3234
args: {
3335
...args,
3436
boxWidth: args.boxWidth ? args.boxWidth : MESSAGE_BOX_WIDTH,
37+
buttonWidth: args.buttonWidth
38+
? args.buttonWidth
39+
: MESSAGE_BOX_BUTTON_WIDTH,
3540
},
3641
})),
3742
hideMessageBox: () =>

src/utils/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ export const fetchUpdateInfo = async () => {
113113
Your launcher build version: #${version}
114114
Current launcher vuild version: #${updateInfo.version}
115115
Click "Download" to open release page`,
116-
boxWidth: 500,
116+
boxWidth: 550,
117+
buttonWidth: 160,
117118
buttons: [
118119
{
119120
title: "Download",

0 commit comments

Comments
 (0)