Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding a basic gallery brick #100

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
channel: 'stable'
cache: true
- run: flutter format --set-exit-if-changed lib test
- run: dart format --set-exit-if-changed lib test

analyze:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Add the dependency to your `pubspec.yaml`
dashbook: ^0.1.12
```

> Tip ℹ️: If you use [mason](https://pub.dev/packages/mason_cli), a basic Dashbook brick called
`dashbook_gallery` is available in brickhub.dev, which creates a basic gallery in seconds.


A `Dashbook` instance has a collection of the app widgets (Stories) and its variants (Chapters). Here you can see a very simple example of how to use it.

```dart
Expand Down
13 changes: 13 additions & 0 deletions bricks/dashbook_gallery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# dashbook_gallery

[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)

Creates a simple, opionated structure for a [Dashbook](https://github.com/bluefireteam/dashbook)
based gallery for your Flutter Application.

Note that this brick does not include any platform folders, so in order to run it, be sure to
create the desired platforms:

```sh
flutter create . --platforms ...
```
3 changes: 3 additions & 0 deletions bricks/dashbook_gallery/__brick__/gallery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Gallery

Dashbook based gallery sandbox.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:very_good_analysis/analysis_options.5.0.0.yaml
linter:
rules:
public_member_api_docs: false
11 changes: 11 additions & 0 deletions bricks/dashbook_gallery/__brick__/gallery/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:dashbook/dashbook.dart';
import 'package:flutter/material.dart';
import 'package:gallery/widgets/widgets.dart';

void main() {
final dashbook = Dashbook();

addTextStories(dashbook);

runApp(dashbook);
}
47 changes: 47 additions & 0 deletions bricks/dashbook_gallery/__brick__/gallery/lib/widgets/text.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:dashbook/dashbook.dart';
import 'package:flutter/material.dart';

void addTextStories(Dashbook dashbook) {
dashbook
.storiesOf('Text')
.decorator(CenterDecorator())
.add(
'default',
(context) => Text(
context.textProperty('text', 'Hello'),
),
)
.add(
'with style',
(_) => const Text(
'Hello world',
style: TextStyle(
color: Colors.blue,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
)
.add(
'with overflow',
(_) => const SizedBox(
width: 100,
child: Text(
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world'
'Hello world',
overflow: TextOverflow.ellipsis,
),
),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'text.dart';
16 changes: 16 additions & 0 deletions bricks/dashbook_gallery/__brick__/gallery/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: gallery
publish_to: none

environment:
sdk: '>=3.0.6 <4.0.0'

dependencies:
dashbook: ^0.1.12
flutter:
sdk: flutter

dev_dependencies:
very_good_analysis: ^5.1.0

flutter:
uses-material-design: true
7 changes: 7 additions & 0 deletions bricks/dashbook_gallery/brick.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: dashbook_gallery
description: Creates a simple dashbook gallery app with a minimal structure to get started.

version: 0.1.0+1

environment:
mason: ">=0.1.0-dev.50 <0.1.0"
4 changes: 2 additions & 2 deletions example/lib/stories.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void addStories(Dashbook dashbook) {
children: [
Text(
'Using DateTimeProperty:',
style: Theme.of(context).textTheme.headline6,
style: Theme.of(context).textTheme.titleLarge,
),
Text(
DateTimePropertyView.dateFormat.format(
Expand All @@ -148,7 +148,7 @@ void addStories(Dashbook dashbook) {
const Divider(),
Text(
'Using anonymous property widget builder:',
style: Theme.of(context).textTheme.headline6,
style: Theme.of(context).textTheme.titleLarge,
),
Text(
DateTimePropertyView.dateFormat.format(
Expand Down
3 changes: 1 addition & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ version: 1.0.0+1
publish_to: none

environment:
sdk: ">=2.18.0 <3.0.0"
sdk: ">=2.18.0 <4.0.0"

dependencies:
cupertino_icons: ^0.1.2
dashbook:
path: ../
flutter:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/actions_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ActionsContainer extends StatelessWidget {
onCancel: onCancel,
child: Column(
children: [
for (MapEntry<String, void Function(BuildContext)> entry
for (final MapEntry<String, void Function(BuildContext)> entry
in currentChapter.ctx.actions.entries)
Padding(
padding: const EdgeInsets.all(8),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/device_settings_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class _DeviceToggles extends StatelessWidget {
TextButton(
onPressed: deviceSettings.reset,
child: const Text('Reset'),
)
),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class _FourIntegerFormState extends State<FourIntegerForm> {
widget._value1,
widget._value2,
widget._value3,
widget._value4
widget._value4,
];
return values.every((v) => v == values[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PropertyScaffold extends StatelessWidget {
)
: Text(label),
),
Expanded(flex: 6, child: child)
Expanded(flex: 6, child: child),
],
),
);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/select_device/select_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class SelectDevice extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Column(
children: const [
return const Column(
children: [
DevicePropertyScaffold(
label: 'Select a device frame:',
child: DeviceDropdown(),
Expand Down Expand Up @@ -54,7 +54,7 @@ class DevicePropertyScaffold extends StatelessWidget {
)
: Text(label),
),
Expanded(flex: 6, child: child)
Expanded(flex: 6, child: child),
],
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/stories_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class _StoriesListState extends State<StoriesList> {
controller: _filterTextController,
),
),
for (Story story in widget.stories)
for (final Story story in widget.stories)
if (_storyMatchesFilter(story))
ExpansionTile(
key: PageStorageKey('story_${story.name}'),
Expand All @@ -143,7 +143,7 @@ class _StoriesListState extends State<StoriesList> {
),
initiallyExpanded: true,
children: [
for (Chapter chapter in story.chapters)
for (final Chapter chapter in story.chapters)
if (_matchesFilter(story.name) ||
_matchesFilter(chapter.name))
Align(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.1.12
homepage: https://github.com/bluefireteam/dashbook

environment:
sdk: ">=2.18.0 <3.0.0"
sdk: ">=2.18.0 <4.0.0"

dependencies:
device_frame: ^1.0.0
Expand Down
2 changes: 1 addition & 1 deletion test/properties/list_property_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Dashbook _getDashbook() {
return Text(
'Current: ${ctx.listProperty('listValue', 'ValueX', [
'ValueX',
'ValueY'
'ValueY',
])}',
);
});
Expand Down
Loading