-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UI tests * WIP * Update curves_test.dart * wip * wip * Update README.md * wip * Update restart_widget.dart
- Loading branch information
1 parent
c86a64c
commit 0537786
Showing
21 changed files
with
647 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
targets: | ||
$default: | ||
sources: | ||
exclude: | ||
- lib/tests/**.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Configuration { | ||
const Configuration({ | ||
this.route = '404', | ||
this.repeatAnimations = true, | ||
}); | ||
|
||
factory Configuration.fromJson(Map<String, dynamic> json) { | ||
return Configuration( | ||
route: json['route'], | ||
repeatAnimations: json['enableAnimations'], | ||
); | ||
} | ||
|
||
final String route; | ||
final bool repeatAnimations; | ||
|
||
Map<String, dynamic> toJson() => { | ||
'route': route, | ||
'enableAnimations': repeatAnimations, | ||
}; | ||
} | ||
|
||
class Routes { | ||
static const root = '/'; | ||
static const curves = '/curves'; | ||
static const sliver_fill_remaining = '/sliver-fill-remaining'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import 'package:animation_cheat_page/animations_cheat_sheet.dart'; | ||
import 'package:animation_cheat_page/config.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
void main() { | ||
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; | ||
runApp(const AnimationCheatSheet()); | ||
runApp( | ||
const AnimationCheatSheet( | ||
config: Configuration(route: Routes.curves), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'dart:io'; | ||
|
||
class Commands { | ||
Flutter get flutter => const Flutter._(); | ||
} | ||
|
||
class Flutter { | ||
const Flutter._(); | ||
|
||
String run(String target) { | ||
return 'flutter run -d $_device --target=$target'; | ||
} | ||
|
||
String attach(String debugUri) { | ||
return 'flutter attach -d $_device --debug-uri $debugUri'; | ||
} | ||
|
||
String dart(String file, [List<String> arguments]) { | ||
return 'dart $file ${arguments != null ? arguments.join(' ') : ''}'; | ||
} | ||
|
||
String get _device { | ||
if (Platform.isWindows) { | ||
return 'windows'; | ||
} else if (Platform.isLinux) { | ||
return 'linux'; | ||
} else { | ||
return 'macos'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'dart:io'; | ||
|
||
String platformPath(String path) { | ||
return Platform.isWindows ? path.replaceAll('/', '\\') : path; | ||
} | ||
|
||
bool exists(String path) => | ||
path != null && File(platformPath(path)).existsSync(); | ||
|
||
String get platformNativeFile { | ||
return platformPath('${Directory.current.path}/$_nativeFile'); | ||
} | ||
|
||
String get _nativeFile { | ||
if (Platform.isWindows) { | ||
return 'windows/window_configuration.cpp'; | ||
} else if (Platform.isLinux) { | ||
return 'linux/main.cc'; | ||
} else if (Platform.isMacOS) { | ||
return 'macos/Runner/MainFlutterWindow.swift'; | ||
} | ||
assert(false); | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
class RestartWidget<T> extends StatelessWidget { | ||
const RestartWidget({ | ||
Key key, | ||
@required this.stream, | ||
@required this.builder, | ||
@required this.initialData, | ||
}) : super(key: key); | ||
|
||
final T initialData; | ||
final Stream<T> stream; | ||
final Widget Function(BuildContext, T) builder; | ||
|
||
Stream<T> _invalidate(T config) async* { | ||
yield null; | ||
await Future.delayed(const Duration(milliseconds: 16)); | ||
yield config; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return StreamBuilder<T>( | ||
stream: stream, | ||
initialData: initialData, | ||
builder: (context, snapshot) { | ||
return StreamBuilder( | ||
initialData: snapshot.data, | ||
stream: _invalidate(snapshot.data), | ||
builder: (context, snapshot) { | ||
return snapshot.data != null | ||
? builder(context, snapshot.data) | ||
: const SizedBox(); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:args/args.dart'; | ||
|
||
const url = 'url'; | ||
const resolutionArg = 'resolution'; | ||
|
||
ArgParser testParser = ArgParser() | ||
..addOption( | ||
url, | ||
abbr: url[0], | ||
help: 'Url for dartVmServiceUrl', | ||
) | ||
..addOption( | ||
resolutionArg, | ||
abbr: resolutionArg[0], | ||
help: 'Resolution of device', | ||
); | ||
|
||
class TestProperties { | ||
TestProperties(List<String> args) : _arguments = testParser.parse(args); | ||
|
||
final ArgResults _arguments; | ||
|
||
String get vmUrl => _arguments[url]; | ||
|
||
Resolution get resolution => Resolution.fromSize(_arguments[resolutionArg]); | ||
} | ||
|
||
enum DeviceOrientation { | ||
portraitPhone, | ||
landscapePhone, | ||
portraitTablet, | ||
landscapeTablet, | ||
} | ||
|
||
const wideLayoutThreshold = 550; | ||
|
||
class Resolution { | ||
const Resolution(this.width, this.height); | ||
|
||
factory Resolution.fromSize(String screenResolution) { | ||
final dimensions = screenResolution.split('x'); | ||
return Resolution(double.parse(dimensions[0]), double.parse(dimensions[1])); | ||
} | ||
|
||
final double width; | ||
final double height; | ||
|
||
double get shortestSide => min(width.abs(), height.abs()); | ||
|
||
bool get isTablet => shortestSide >= wideLayoutThreshold; | ||
|
||
DeviceOrientation get orientation { | ||
if (isTablet) { | ||
return width < height | ||
? DeviceOrientation.portraitTablet | ||
: DeviceOrientation.landscapeTablet; | ||
} else { | ||
return width < height | ||
? DeviceOrientation.portraitPhone | ||
: DeviceOrientation.landscapePhone; | ||
} | ||
} | ||
|
||
Map<String, dynamic> toJson() => { | ||
'width': width.floor(), | ||
'height': height.floor(), | ||
}; | ||
} |
Oops, something went wrong.