sections.dart 4.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
// 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';

const Color _mariner = const Color(0xFF3B5F8F);
const Color _mediumPurple = const Color(0xFF8266D4);
const Color _tomato = const Color(0xFFF95B57);
const Color _mySin = const Color(0xFFF3A646);

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

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

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

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

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

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

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

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

const SectionDetail _protectionImageDetail = const SectionDetail(
105 106
  imageAsset: 'shrine/products/helmet.png',
  imageAssetPackage: _kGalleryAssetsPackage,
107 108 109 110 111 112 113
);

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