updateSectionHeight method

void updateSectionHeight(
  1. String section,
  2. double delta
)

Implementation

void updateSectionHeight(String section, double delta) {
  if (resizingSection.value != section) return;

  // Get current heights
  double currentHeight = _getCurrentSectionHeight(section);
  double nextHeight = currentHeight + delta;

  // Apply min/max constraints
  nextHeight = nextHeight.clamp(50.0, section == 'body' ? 450 : 300.0);

  // Calculate how much we can actually change
  double actualDelta = nextHeight - currentHeight;

  // If no change needed, return early
  if (actualDelta == 0) return;

  switch (section) {
    case 'header':
    // Check if we can take space from subHeader
      if (actualDelta > 0 && subHeaderHeight.value - actualDelta < 50) {
        actualDelta = subHeaderHeight.value - 50;
      }
      headerHeight.value += actualDelta;
      subHeaderHeight.value -= actualDelta;
      break;

    case 'subHeader':
    // Check if we can take space from body
      if (actualDelta > 0 && bodyHeight.value - actualDelta < 50) {
        actualDelta = bodyHeight.value - 50;
      }
      subHeaderHeight.value += actualDelta;
      bodyHeight.value -= actualDelta;
      break;

    case 'body':
    // Check if we can take space from subBody
      if (actualDelta > 0 && subBodyHeight.value - actualDelta < 50) {
        actualDelta = subBodyHeight.value - 50;
      }
      bodyHeight.value += actualDelta;
      subBodyHeight.value -= actualDelta;
      break;

    case 'subBody':
    // Check if we can take space from footer
      if (actualDelta > 0 && footerHeight.value - actualDelta < 50) {
        actualDelta = footerHeight.value - 50;
      }
      // Enforce max footer height of 250
      if (footerHeight.value - actualDelta > 240) {
        actualDelta = footerHeight.value - 240;
      }
      subBodyHeight.value += actualDelta;
      footerHeight.value -= actualDelta;
      break;
  }
  // Update positions
  _updateSectionPositionsOnly();
}