sections.dart 4.41 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Raw data for the animation demo.

import 'package:flutter/material.dart';

9 10 11 12
const Color _mariner = Color(0xFF3B5F8F);
const Color _mediumPurple = Color(0xFF8266D4);
const Color _tomato = Color(0xFFF95B57);
const Color _mySin = Color(0xFFF3A646);
13

14 15
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';

16
class SectionDetail {
17 18 19 20 21 22
  const SectionDetail({
    this.title,
    this.subtitle,
    this.imageAsset,
    this.imageAssetPackage,
  });
23 24 25 26
  final String? title;
  final String? subtitle;
  final String? imageAsset;
  final String? imageAssetPackage;
27 28
}

29
@immutable
30
class Section {
31 32 33 34 35 36 37 38
  const Section({
    this.title,
    this.backgroundAsset,
    this.backgroundAssetPackage,
    this.leftColor,
    this.rightColor,
    this.details,
  });
39 40 41 42 43 44
  final String? title;
  final String? backgroundAsset;
  final String? backgroundAssetPackage;
  final Color? leftColor;
  final Color? rightColor;
  final List<SectionDetail>? details;
45 46 47

  @override
  bool operator==(Object other) {
48 49
    return other is Section
        && other.title == title;
50 51 52 53 54 55 56 57 58 59
  }

  @override
  int get hashCode => title.hashCode;
}

// TODO(hansmuller): replace the SectionDetail images and text. Get rid of
// the const vars like _eyeglassesDetail and insert a variety of titles and
// image SectionDetails in the allSections list.

60
const SectionDetail _eyeglassesDetail = SectionDetail(
61
  imageAsset: 'products/sunnies.png',
62
  imageAssetPackage: _kGalleryAssetsPackage,
63 64 65 66
  title: 'Flutter enables interactive animation',
  subtitle: '3K views - 5 days',
);

67
const SectionDetail _eyeglassesImageDetail = SectionDetail(
68
  imageAsset: 'products/sunnies.png',
69
  imageAssetPackage: _kGalleryAssetsPackage,
70 71
);

72
const SectionDetail _seatingDetail = SectionDetail(
73
  imageAsset: 'products/table.png',
74
  imageAssetPackage: _kGalleryAssetsPackage,
75 76 77 78
  title: 'Flutter enables interactive animation',
  subtitle: '3K views - 5 days',
);

79
const SectionDetail _seatingImageDetail = SectionDetail(
80
  imageAsset: 'products/table.png',
81
  imageAssetPackage: _kGalleryAssetsPackage,
82 83
);

84
const SectionDetail _decorationDetail = SectionDetail(
85
  imageAsset: 'products/earrings.png',
86
  imageAssetPackage: _kGalleryAssetsPackage,
87 88 89 90
  title: 'Flutter enables interactive animation',
  subtitle: '3K views - 5 days',
);

91
const SectionDetail _decorationImageDetail = SectionDetail(
92
  imageAsset: 'products/earrings.png',
93
  imageAssetPackage: _kGalleryAssetsPackage,
94 95
);

96
const SectionDetail _protectionDetail = SectionDetail(
97
  imageAsset: 'products/hat.png',
98
  imageAssetPackage: _kGalleryAssetsPackage,
99 100 101 102
  title: 'Flutter enables interactive animation',
  subtitle: '3K views - 5 days',
);

103
const SectionDetail _protectionImageDetail = SectionDetail(
104
  imageAsset: 'products/hat.png',
105
  imageAssetPackage: _kGalleryAssetsPackage,
106 107 108 109
);

final List<Section> allSections = <Section>[
  const Section(
110
    title: 'SUNGLASSES',
111 112
    leftColor: _mediumPurple,
    rightColor: _mariner,
113
    backgroundAsset: 'products/sunnies.png',
114
    backgroundAssetPackage: _kGalleryAssetsPackage,
115
    details: <SectionDetail>[
116 117 118 119 120 121 122 123 124
      _eyeglassesDetail,
      _eyeglassesImageDetail,
      _eyeglassesDetail,
      _eyeglassesDetail,
      _eyeglassesDetail,
      _eyeglassesDetail,
    ],
  ),
  const Section(
125
    title: 'FURNITURE',
126 127
    leftColor: _tomato,
    rightColor: _mediumPurple,
128
    backgroundAsset: 'products/table.png',
129
    backgroundAssetPackage: _kGalleryAssetsPackage,
130
    details: <SectionDetail>[
131 132 133 134 135 136 137 138 139
      _seatingDetail,
      _seatingImageDetail,
      _seatingDetail,
      _seatingDetail,
      _seatingDetail,
      _seatingDetail,
    ],
  ),
  const Section(
140
    title: 'JEWELRY',
141 142
    leftColor: _mySin,
    rightColor: _tomato,
143
    backgroundAsset: 'products/earrings.png',
144
    backgroundAssetPackage: _kGalleryAssetsPackage,
145
    details: <SectionDetail>[
146 147 148 149 150 151 152 153 154
      _decorationDetail,
      _decorationImageDetail,
      _decorationDetail,
      _decorationDetail,
      _decorationDetail,
      _decorationDetail,
    ],
  ),
  const Section(
155
    title: 'HEADWEAR',
156 157
    leftColor: Colors.white,
    rightColor: _tomato,
158
    backgroundAsset: 'products/hat.png',
159
    backgroundAssetPackage: _kGalleryAssetsPackage,
160
    details: <SectionDetail>[
161 162 163 164 165 166 167 168 169
      _protectionDetail,
      _protectionImageDetail,
      _protectionDetail,
      _protectionDetail,
      _protectionDetail,
      _protectionDetail,
    ],
  ),
];