import 'dart:math' as math;

import 'package:flutter/material.dart';

const double androidDetailDesktopTitleBarHeight = 38.0;
const double androidDetailNavigationContentHeight = 30.0;

double computeAndroidDetailNavigationHeight(BuildContext context) {
  final topInset = MediaQuery.paddingOf(context).top;
  return math.max(topInset, androidDetailDesktopTitleBarHeight) +
      androidDetailNavigationContentHeight;
}

double computeAndroidDetailBannerHeight(BuildContext context) {
  final mediaQuery = MediaQuery.of(context);
  final bodyHeight = mediaQuery.size.height - mediaQuery.padding.top;
  final preferredHeight = (bodyHeight * 0.46).clamp(300.0, 390.0);
  final landscapeSafeHeight = bodyHeight * 0.55;

  return math.min(preferredHeight, landscapeSafeHeight);
}

double computeAndroidDetailCollapseExtent(BuildContext context) {
  final bannerHeight = computeAndroidDetailBannerHeight(context);
  final navigationHeight = computeAndroidDetailNavigationHeight(context);
  return math.max(1.0, bannerHeight - navigationHeight);
}
