summaryrefslogtreecommitdiffstats
path: root/lib/layout_size_helper.dart
blob: 9cbb0d70483f9adf25012a8e979e4e07c2ab1925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'package:flutter/material.dart';

class LayoutSizeHelper {
  Size _size;
  double _ratio;

  LayoutSizeHelper(context)
      : _size = MediaQuery.of(context).size,
        _ratio = MediaQuery.of(context).devicePixelRatio;

  update(context) {
    _size = MediaQuery.of(context).size;
    _ratio = MediaQuery.of(context).devicePixelRatio;
  }

  get defaultIconSize {
    if (_size.height <= 480 || _size.width <= 600) {
      return 64.0 * _ratio;
    } else if (_size.height <= 900 || _size.width <= 840) {
      return 96.0 * _ratio;
    } else {
      return 128.0 * _ratio;
    }
  }

  get defaultButtonHeight {
    return defaultIconSize;
  }

  get defaultButtonWidth {
    return defaultButtonHeight * 3.0;
  }

  get defaultPadding {
    return defaultIconSize / 8.0;
  }

  get defaultBorder {
    return defaultIconSize / 16;
  }

  get baseFontSize {
    return (defaultIconSize / 3.0).floor().toDouble();
  }

  get largeIconSize {
    return 1.5 * defaultIconSize;
  }

  get largePadding {
    return largeIconSize / 4.0;
  }
}