sections.dart 4.46 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2017 The Chromium Authors. All rights reserved.
// 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
  final String title;
  final String subtitle;
  final String imageAsset;
26
  final String imageAssetPackage;
27 28 29
}

class Section {
30 31 32 33 34 35 36 37
  const Section({
    this.title,
    this.backgroundAsset,
    this.backgroundAssetPackage,
    this.leftColor,
    this.rightColor,
    this.details,
  });
38 39
  final String title;
  final String backgroundAsset;
40
  final String backgroundAssetPackage;
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  final Color leftColor;
  final Color rightColor;
  final List<SectionDetail> details;

  @override
  bool operator==(Object other) {
    if (other is! Section)
      return false;
    final Section otherSection = other;
    return title == otherSection.title;
  }

  @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.

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

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

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

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

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

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

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

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

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