Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
robiness committed Jun 29, 2023
2 parents ab29629 + bfb8a7b commit 61bd1c2
Show file tree
Hide file tree
Showing 29 changed files with 1,616 additions and 1,032 deletions.
Binary file added assets/ruler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 0 additions & 24 deletions example/lib/example_widget_stage.dart

This file was deleted.

11 changes: 7 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:example/stage_data/my_app_stage_data.dart';
import 'package:example/stage_data/my_list_tile_widget_stage.dart';
import 'package:example/stage_data/my_other_widget_stage.dart';
import 'package:example/stage_data/my_widget_stage.dart';
Expand All @@ -16,15 +17,17 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {

final ThemeData theme = ThemeData.light();

late final StageController _stageController = StageController(theme: theme);
late final StageController _stageController = StageController(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
);

final widgetsOnStage = [
MyWidgetStageData(),
MyOtherWidgetStageData(),
MyListTileWidgetStage(),
MyAppStageData(),
];

@override
Expand All @@ -50,8 +53,8 @@ class _MyAppState extends State<MyApp> {
),
),
Expanded(
child: WidgetStage(
controller: _stageController,
child: StageCraft(
stageController: _stageController,
),
),
],
Expand Down
21 changes: 21 additions & 0 deletions example/lib/stage_data/my_app_stage_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:example/widgets/my_app.dart';
import 'package:flutter/material.dart';
import 'package:stage_craft/stage_craft.dart';

class MyAppStageData extends WidgetStageData {
@override
String get name => 'My App';

@override
List<FieldConfigurator> get stageConfigurators => [];

@override
List<FieldConfigurator> get widgetConfigurators => [];

@override
Widget widgetBuilder(BuildContext context) {
return const MyApp(
maxContentWidth: 1440,
);
}
}
35 changes: 14 additions & 21 deletions example/lib/stage_data/my_list_tile_widget_stage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class MyListTileWidgetStage extends WidgetStageData {
: _tileCount = IntFieldConfigurator(value: 1, name: 'tileCount'),
_listPadding = PaddingFieldConfigurator(value: EdgeInsets.zero, name: 'listPadding'),
_title = StringFieldConfigurator(value: 'My List Tile', name: 'title'),
_stageColor = ColorFieldConfigurator(value: Colors.transparent, name: 'stageColor'),
_circleColor = ColorFieldConfigurator(value: Colors.purple, name: 'circleColor'),
_tileColor = ColorFieldConfiguratorNullable(value: Colors.cyan, name: 'tileColor'),
_textColor = ColorFieldConfiguratorNullable(value: Colors.white, name: 'textColor'),
Expand All @@ -30,8 +29,6 @@ class MyListTileWidgetStage extends WidgetStageData {
_tileCount,
_tileGap,
_listPadding,
_stageColor,
_circleColor,
];
}

Expand All @@ -43,30 +40,26 @@ class MyListTileWidgetStage extends WidgetStageData {
final DoubleFieldConfiguratorNullable _borderRadius;
final PaddingFieldConfigurator _listPadding;
final StringFieldConfigurator _title;
final ColorFieldConfigurator _stageColor;
final ColorFieldConfigurator _circleColor;
final ColorFieldConfiguratorNullable _textColor;
final ColorFieldConfiguratorNullable _tileColor;

@override
Widget widgetBuilder(BuildContext context) {
return ColoredBox(
color: _stageColor.value,
child: ListView.separated(
padding: _listPadding.value,
itemCount: _tileCount.value,
separatorBuilder: (_, __) => SizedBox(height: _tileGap.value),
itemBuilder: (context, index) {
return _MyTitleTileWidget(
title: _title.value,
index: index,
circleColor: _circleColor.value,
tileColor: _tileColor.value,
borderRadius: _borderRadius.value,
textColor: _textColor.value,
);
},
),
return ListView.separated(
padding: _listPadding.value,
itemCount: _tileCount.value,
separatorBuilder: (_, __) => SizedBox(height: _tileGap.value),
itemBuilder: (context, index) {
return _MyTitleTileWidget(
title: _title.value,
index: index,
circleColor: _circleColor.value,
tileColor: _tileColor.value,
borderRadius: _borderRadius.value,
textColor: _textColor.value,
);
},
);
}
}
Expand Down
142 changes: 142 additions & 0 deletions example/lib/widgets/my_app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
const MyApp({
super.key,
required this.maxContentWidth,
});

final double maxContentWidth;

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Page(),
);
}
}

class Page extends StatefulWidget {
const Page({super.key});

@override
State<Page> createState() => _PageState();
}

class _PageState extends State<Page> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 1440,
),
child: Container(
decoration: const BoxDecoration(
color: Colors.grey,
),
child: const PageContent(),
),
),
),
);
}
}

class PageContent extends StatefulWidget {
const PageContent({super.key});

@override
State<PageContent> createState() => _PageContentState();
}

class _PageContentState extends State<PageContent> {
int _selectedItem = 1;

@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxWidth > 700) {
return Row(
children: [
SizedBox(
width: 500,
child: ItemList(
onItemSelected: (int selectedItem) {
setState(() {
_selectedItem = selectedItem;
});
},
),
),
DetailView(id: _selectedItem),
],
);
}
return ItemList(
onItemSelected: (int selectedItem) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return DetailView(id: selectedItem);
},
),
);
},
);
},
);
}
}

class ItemList extends StatelessWidget {
const ItemList({
super.key,
required this.onItemSelected,
});

final void Function(int selectedItem) onItemSelected;

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: ListView.builder(
shrinkWrap: true,
itemCount: 30,
itemBuilder: (context, index) {
return MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
onItemSelected(index);
},
child: Container(
height: 100,
color: Colors.blue,
child: Text('Item $index'),
),
),
);
},
),
);
}
}

class DetailView extends StatelessWidget {
const DetailView({
super.key,
required this.id,
});

final int id;

@override
Widget build(BuildContext context) {
return Center(
child: Text('Detail $id'),
);
}
}
24 changes: 4 additions & 20 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.3"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -92,21 +84,13 @@ packages:
source: hosted
version: "0.6.7"
lint:
dependency: "direct main"
dependency: "direct dev"
description:
name: lint
sha256: "3e9343b1cededcfb1e8b40d0dbd3592b7a1c6c0121545663a991433390c2bc97"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
name: lints
sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593"
sha256: f4bd4dbaa39f4ae8836f2d1275f2f32bc68b3a8cce0a0735dd1f7a601f06682a
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "2.1.2"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -208,5 +192,5 @@ packages:
source: hosted
version: "2.1.4"
sdks:
dart: ">=3.0.0-0 <4.0.0"
dart: ">=3.0.0 <4.0.0"
flutter: ">=1.17.0"
4 changes: 1 addition & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ environment:
dependencies:
flutter:
sdk: flutter
lint: ^2.0.1

stage_craft:
path: ../


dev_dependencies:
flutter_lints: ^2.0.0

lint: ^2.1.2
flutter_test:
sdk: flutter

Expand Down
3 changes: 1 addition & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:example/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:example/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down
Loading

0 comments on commit 61bd1c2

Please sign in to comment.