1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-11 23:39:14 +00:00

update slide_puzzle (#420)

* update slide_puzzle

* run createThumbnails before build-release grind task

* add license headers
This commit is contained in:
John Ryan
2020-04-29 13:41:36 -07:00
committed by GitHub
parent ddf610d682
commit 9a464fad00
24 changed files with 241 additions and 33 deletions

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'src/core/puzzle_animator.dart';
import 'src/flutter.dart';
import 'src/puzzle_home_state.dart';

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'core/puzzle_proxy.dart';

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math' show Point;
const zeroPoint = Point<double>(0, 0);

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math' as math;
class Point extends math.Point<int> {

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:collection';
import 'dart:convert';
import 'dart:math' show Random, max;

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:math' show Point, Random;

View File

@@ -0,0 +1,25 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math' show Point;
enum PuzzleEvent { click, random, reset, noop }
abstract class PuzzleProxy {
int get width;
int get height;
int get length;
bool get solved;
void clickOrShake(int tileValue);
int get tileCount;
Point<double> location(int index);
bool isCorrectPosition(int value);
}

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of 'puzzle.dart';
class _PuzzleSimple extends Puzzle {

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of 'puzzle.dart';
mixin _SliceListMixin on ListMixin<int> {

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
void requireArgument(bool truth, String argName, [String message]) {
if (!truth) {
if (message == null || message.isEmpty) {

View File

@@ -0,0 +1,6 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
export 'package:flutter/material.dart';
export 'package:flutter/scheduler.dart' show Ticker;

View File

@@ -0,0 +1,17 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/foundation.dart';
abstract class PuzzleControls implements Listenable {
void reset();
int get clickCount;
int get incorrectTiles;
bool get autoPlay;
void Function(bool newValue) get setAutoPlayFunction;
}

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. 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';

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:provider/provider.dart';

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. 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 'puzzle_controls.dart';

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. 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';

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. 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';

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. 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';

View File

@@ -0,0 +1,13 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'theme_plaster.dart';
import 'theme_seattle.dart';
import 'theme_simple.dart';
const themes = [
ThemeSimple(),
ThemeSeattle(),
ThemePlaster(),
];

View File

@@ -0,0 +1,92 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ValueTabController<T> extends StatefulWidget {
/// Creates a default tab controller for the given [child] widget.
const ValueTabController({
Key key,
@required this.child,
@required this.values,
}) : super(key: key);
/// The widget below this widget in the tree.
///
/// Typically a [Scaffold] whose [AppBar] includes a [TabBar].
///
/// {@macro flutter.widgets.child}
final Widget child;
final List<T> values;
/// The closest instance of this class that encloses the given context.
///
/// Typical usage:
///
/// ```dart
/// TabController controller = DefaultTabBarController.of(context);
/// ```
static TabController of(BuildContext context) {
final scope = context.inheritFromWidgetOfExactType(_ValueTabControllerScope)
as _ValueTabControllerScope;
return scope?.controller;
}
@override
_ValueTabControllerState<T> createState() => _ValueTabControllerState<T>();
}
class _ValueTabControllerState<T> extends State<ValueTabController<T>>
with SingleTickerProviderStateMixin {
final _notifier = ValueNotifier<T>(null);
TabController _controller;
@override
void initState() {
super.initState();
_controller = TabController(
vsync: this,
length: widget.values.length,
initialIndex: 0,
);
_notifier.value = widget.values.first;
_controller.addListener(() {
_notifier.value = widget.values[_controller.index];
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => _ValueTabControllerScope(
controller: _controller,
enabled: TickerMode.of(context),
child: ValueListenableProvider.value(
valueListenable: _notifier,
child: widget.child,
),
);
}
class _ValueTabControllerScope extends InheritedWidget {
const _ValueTabControllerScope(
{Key key, this.controller, this.enabled, Widget child})
: super(key: key, child: child);
final TabController controller;
final bool enabled;
@override
bool updateShouldNotify(_ValueTabControllerScope old) =>
enabled != old.enabled || controller != old.controller;
}

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// ignore_for_file: omit_local_variable_types, annotate_overrides
import 'dart:developer' as developer;

View File

@@ -1,3 +1,7 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import '../flutter.dart';
// Copied from