Skip to content

Commit

Permalink
used WoltBreakpoints for constraints calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
durannumit committed Jul 1, 2024
1 parent 34267a0 commit 2feb4c3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/src/modal_type/wolt_alert_dialog_type.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:wolt_modal_sheet/src/utils/wolt_breakpoints.dart';
import 'package:wolt_modal_sheet/wolt_modal_sheet.dart';

class WoltAlertDialogType extends WoltDialogType {
const WoltAlertDialogType();

@override
BoxConstraints layoutModal(Size availableSize) {
const padding = 32.0;
late double width;
final availableWidth = availableSize.width;
double width = availableWidth > 523.0 ? 312.0 : availableWidth - padding;
final screenType = WoltBreakpoints.getScreenTypeForWidth(availableWidth);

if (availableWidth > 523.0) {
width = 312.0; // optimal width for larger screens
} else if (availableWidth > 240.0) {
width = 240.0; // standard width for moderate screens
} else {
width = availableWidth - padding; // adjust for very small screens
switch (screenType) {
case WoltBreakpoints.xsmall:
width = min(280, availableWidth - WoltDialogType.minPadding);
case WoltBreakpoints.small:
width = 280;
case WoltBreakpoints.medium:
case WoltBreakpoints.large:
width = 404;
}

return BoxConstraints(
Expand Down

0 comments on commit 2feb4c3

Please sign in to comment.