Permalink
Browse files

Merge pull request #5 from Igor1201/nail-care

💅
  • Loading branch information...
Igor1201 committed Oct 7, 2018
2 parents 0a03274 + eeb53c5 commit 5dfa802612e2ff48f834087f54a3168f09e5d296
Showing with 238 additions and 136 deletions.
  1. +45 −63 .gitignore
  2. +48 −5 README.md
  3. +0 −1 build.yaml
  4. +71 −0 example/.gitignore
  5. +0 −1 example/test/my_widget_test.showcased.dart
  6. +23 −21 lib/golden_boundary.dart
  7. +26 −24 lib/showcase_generator.dart
  8. +23 −18 lib/showcase_widgets.dart
  9. +2 −0 lib/showcased.dart
  10. +0 −3 pubspec.yaml
@@ -1,74 +1,56 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# Created by https://www.gitignore.io/api/dart,macos
# Visual Studio Code related
.vscode/
### Dart ###
# See https://www.dartlang.org/guides/libraries/private-files
# Flutter/Dart/Pub related
**/doc/api/
# Files and directories created by pub
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock
# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/
# Avoid committing generated Javascript files:
*.dart.js
*.info.json # Produced by the --dump-info flag.
*.js # When generated by dart2js. Don't specify *.js if your
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# Thumbnails
._*
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
showcase/
# End of https://www.gitignore.io/api/dart,macos
@@ -1,6 +1,6 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/735858/46577226-26fbc600-c9b8-11e8-9693-4b2098bbbb0c.png" width="150">
<h1>Showcase</h1>
<img src="https://user-images.githubusercontent.com/735858/46586739-1cddd400-ca59-11e8-9e61-42961d8a8b3b.gif" width="150">
<h1><b>Showcase</b></h1>
</p>
<!-- Badges -->
@@ -9,13 +9,56 @@
**Generates documentation screenshots of your widgets.**
## Installation
add the following to your `pubspec.yaml` file:
```shell
---
## **Installation**
Add the following to your `pubspec.yaml` file:
```yaml
dev_dependencies:
showcase: <1.0.0
```
then run:
```shell
flutter packages get
```
Then you can wither annotate the widgets you want to have showcased or manually create a test file with multiple widgets:
### **With annotations**
Add another dependency to your `pubspec.yaml` file:
```yaml
dev_dependencies:
build_runner: ^0.10.0
```
Just annotate the widgets you want with `@Showcased`:
```dart
import 'package:showcase/showcase.dart';
@Showcased()
class MyWidget extends StatelessWidget {
// ...
}
```
The builder will generate a `_test.showcased.dart` test file for each annotated class file. Just run:
```shell
flutter packages pub run build_runner build
```
### **Manually testing**
Create a test file with the following:
```dart
import 'package:flutter_test/flutter_test.dart';
import 'package:showcase/showcase.dart';
void main() {
group('Showcase!', () {
showcaseWidgets([]);
});
}
```
Replace the empty list with a collection of widgets. `showcaseWidgets` also have some options you can tweak.
Then it's just a matter of running `flutter test` and have your screenshots generated on `./showcase/` (or another output directory you had configured).
@@ -2,6 +2,5 @@ builders:
showcase:
import: 'package:showcase/showcase_generator.dart'
builder_factories: ['showcaseBuilder']
# build_to: 'source'
build_extensions: {'.dart': ['.showcased.dart']}
auto_apply: dependents
@@ -0,0 +1,71 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# Visual Studio Code related
.vscode/
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
build/
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -2,38 +2,40 @@ import 'package:flutter/material.dart';
typedef ContainerBuilder = Container Function(Widget child);
/// Use [GoldenBoundary] to wrap a [Widget] and be able to find its
/// [RenderObject] from a [GlobalKey].
class GoldenBoundary extends StatelessWidget {
/// The widget to be wrapped.
final Widget child;
/// A custom key to find this widget later.
final GlobalKey globalKey;
/// A function to customize the wrapping container.
final ContainerBuilder customContainerBuilder;
GoldenBoundary({
/// Default constructor. Use [customContainerBuilder] if you want to customize
/// the wrapping container.
const GoldenBoundary({
@required this.child,
this.globalKey,
this.customContainerBuilder,
});
Widget _defaultContainerBuilder(Widget child) {
return Container(
padding: EdgeInsets.all(10.0),
width: 640.0,
height: 480.0,
child: child,
);
}
Widget _defaultContainerBuilder(Widget child) => Container(
padding: const EdgeInsets.all(10.0),
width: 640.0,
height: 480.0,
child: child,
);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: RepaintBoundary(
key: globalKey,
child: customContainerBuilder != null ?
customContainerBuilder(child) :
_defaultContainerBuilder(child),
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
body: RepaintBoundary(
key: globalKey,
child: customContainerBuilder != null
? customContainerBuilder(child)
: _defaultContainerBuilder(child),
),
),
),
);
}
);
}
Oops, something went wrong.

0 comments on commit 5dfa802

Please sign in to comment.