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

[MDS-364] Add storybook_flutter #4

Merged
merged 1 commit into from
Jan 23, 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
93 changes: 72 additions & 21 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:moon_design/moon_design.dart';
import 'package:storybook_flutter/storybook_flutter.dart';

void main() {
runApp(const MyApp());
Expand All @@ -17,33 +19,82 @@ class MyApp extends StatelessWidget {
}
}

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

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
final plugins = initializePlugins(
contentsSidePanel: true,
knobsSidePanel: true,
initialDeviceFrameData: DeviceFrameData(
device: Devices.ios.iPhone13,
),
);

bool _isInStorybookMode = false;

void toggleStorybookMode() {
setState(() {
_isInStorybookMode = !_isInStorybookMode;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Moon Design for Flutter",
style: TextStyle(
fontSize: MediaQuery.of(context).size.width > 800 ? 72 : 32,
),
return _isInStorybookMode
? Storybook(
initialStory: "Default",
plugins: plugins,
wrapperBuilder: (context, child) => MaterialApp(
theme: ThemeData.light().copyWith(extensions: <ThemeExtension<dynamic>>[MoonTheme.light]),
darkTheme: ThemeData.dark().copyWith(extensions: <ThemeExtension<dynamic>>[MoonTheme.dark]),
useInheritedMediaQuery: true,
home: Scaffold(body: child),
),
SizedBox(height: MediaQuery.of(context).size.width > 800 ? 36 : 16),
Text(
"Coming soon...",
style: TextStyle(
fontSize: MediaQuery.of(context).size.width > 800 ? 24 : 20,
color: const Color(0xFF999CA0),
stories: [
Story(
name: "Test Story",
description: "Test description",
builder: (context) {
final theme = Theme.of(context).extension<MoonTheme>()!;
return Container(
color: theme.colors.piccolo,
alignment: Alignment.center,
child: Text("Test text", style: theme.typography.heading.text32),
);
},
),
],
)
: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Moon Design for Flutter",
style: TextStyle(
fontSize: MediaQuery.of(context).size.width > 800 ? 72 : 32,
),
),
SizedBox(height: MediaQuery.of(context).size.width > 800 ? 36 : 16),
GestureDetector(
onLongPress: toggleStorybookMode,
child: Text(
"Coming soon...",
style: TextStyle(
fontSize: MediaQuery.of(context).size.width > 800 ? 24 : 20,
color: const Color(0xFF999CA0),
),
),
),
],
),
),
],
),
),
);
);
}
}
58 changes: 57 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
device_frame:
dependency: transitive
description:
name: device_frame
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
fake_async:
dependency: transitive
description:
Expand All @@ -67,6 +74,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
freezed_annotation:
dependency: transitive
description:
name: freezed_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "4.8.0"
lint:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -109,13 +130,41 @@ packages:
relative: true
source: path
version: "0.0.1"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
pointer_interceptor:
dependency: transitive
description:
name: pointer_interceptor
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.3+3"
provider:
dependency: transitive
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.5"
recase:
dependency: transitive
description:
name: recase
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -135,6 +184,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
storybook_flutter:
dependency: "direct dev"
description:
name: storybook_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.4"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -172,4 +228,4 @@ packages:
version: "2.1.2"
sdks:
dart: ">=2.18.6 <3.0.0"
flutter: ">=1.17.0"
flutter: ">=2.10.0"
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
lint: ^2.0.1
storybook_flutter: ^0.11.4


flutter:
Expand Down
11 changes: 11 additions & 0 deletions lib/moon_design.dart
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
library moon_design;

export "package:moon_design/src/theme/borders.dart";
export "package:moon_design/src/theme/colors.dart";
export "package:moon_design/src/theme/hover_effects.dart";
export "package:moon_design/src/theme/shadows.dart";
export "package:moon_design/src/theme/sizes.dart";
export "package:moon_design/src/theme/text_styles.dart";
export "package:moon_design/src/theme/theme.dart";
export "package:moon_design/src/theme/transition_effects.dart";
export "package:moon_design/src/theme/transitions.dart";
export "package:moon_design/src/theme/typography.dart";