Skip to content

Commit

Permalink
dynamic button width for message popup
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Nov 10, 2023
1 parent 8794751 commit 4dd4c00
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 265 deletions.
3 changes: 2 additions & 1 deletion src/containers/MessageBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const MessageBox = () => {
style={{
position: "absolute",
top: height / 2 - 90 - 25, // titlebar height is 25
left: width / 2 - 160,
left: width / 2 - Number(args.boxWidth) / 2,
width: args.boxWidth,
borderRadius: 4,
backgroundColor: theme.listHeaderBackgroundColor,
Expand Down Expand Up @@ -81,6 +81,7 @@ const MessageBox = () => {
style={{
paddingHorizontal: 10,
height: 30,
width: args.buttonWidth,
marginTop: 5,
backgroundColor: theme.primary,
borderRadius: 8,
Expand Down
5 changes: 5 additions & 0 deletions src/states/messageModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface MessageBoxArgs {
onPress: () => void;
}[];
boxWidth?: number;
buttonWidth?: number;
}

interface MessageModalState {
Expand All @@ -18,6 +19,7 @@ interface MessageModalState {
}

const MESSAGE_BOX_WIDTH = 320;
const MESSAGE_BOX_BUTTON_WIDTH = 120;

const useMessageBox = create<MessageModalState>()((set) => ({
visible: false,
Expand All @@ -32,6 +34,9 @@ const useMessageBox = create<MessageModalState>()((set) => ({
args: {
...args,
boxWidth: args.boxWidth ? args.boxWidth : MESSAGE_BOX_WIDTH,
buttonWidth: args.buttonWidth
? args.buttonWidth
: MESSAGE_BOX_BUTTON_WIDTH,
},
})),
hideMessageBox: () =>
Expand Down
3 changes: 2 additions & 1 deletion src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export const fetchUpdateInfo = async () => {
Your launcher build version: #${version}
Current launcher vuild version: #${updateInfo.version}
Click "Download" to open release page`,
boxWidth: 500,
boxWidth: 550,
buttonWidth: 160,
buttons: [
{
title: "Download",
Expand Down
Loading

0 comments on commit 4dd4c00

Please sign in to comment.