1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-23 21:01:49 +00:00
Files
samples/web/slide_puzzle/lib/src/theme_seattle.dart
2019-05-25 22:12:58 -07:00

76 lines
2.1 KiB
Dart

// Copyright 2019 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.
import 'core/puzzle_proxy.dart';
import 'flutter.dart';
import 'shared_theme.dart';
import 'widgets/decoration_image_plus.dart';
class ThemeSeattle extends SharedTheme {
@override
String get name => 'Seattle';
const ThemeSeattle();
@override
Color get puzzleThemeBackground => const Color.fromARGB(153, 90, 135, 170);
@override
Color get puzzleBackgroundColor => Colors.white70;
@override
Color get puzzleAccentColor => const Color(0xff000579f);
@override
RoundedRectangleBorder puzzleBorder(bool small) =>
const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(1),
),
);
@override
EdgeInsetsGeometry tilePadding(PuzzleProxy puzzle) =>
puzzle.solved ? const EdgeInsets.all(1) : const EdgeInsets.all(4);
@override
Widget tileButton(int i, PuzzleProxy puzzle, bool small) {
if (i == puzzle.tileCount && !puzzle.solved) {
assert(puzzle.solved);
}
final decorationImage = DecorationImagePlus(
puzzleWidth: puzzle.width,
puzzleHeight: puzzle.height,
pieceIndex: i,
fit: BoxFit.cover,
image: const AssetImage('seattle.jpg'));
final correctPosition = puzzle.isCorrectPosition(i);
final content = createInk(
puzzle.solved
? const Center()
: Container(
decoration: ShapeDecoration(
shape: const CircleBorder(),
color: correctPosition ? Colors.black38 : Colors.white54,
),
alignment: Alignment.center,
child: Text(
(i + 1).toString(),
style: TextStyle(
fontWeight: FontWeight.normal,
color: correctPosition ? Colors.white : Colors.black,
fontSize: small ? 25 : 42,
),
),
),
image: decorationImage,
padding: EdgeInsets.all(small ? 20 : 32),
);
return createButton(puzzle, small, i, content);
}
}