diff --git a/README.md b/README.md index 8fd99562..d8f0c390 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ Zeta is the new, formal, standardized Zebra Design System based off the successe ### Prerequisites ``` - dart sdk: ">=3.2.0 <4.0.0" - flutter: ">=3.16.0" +dart sdk: ">=3.2.0 <4.0.0" +flutter: ">=3.16.0" ``` ## Installation @@ -30,7 +30,7 @@ Zeta allows you to specify an initial theme mode for your app, which can be one By default, the theme mode is set to `ThemeMode.system`. ```dart -initialThemeMode: ThemeMode.light +initialThemeMode: ThemeMode.system ``` ### Providing Initial Theme Data diff --git a/example/assets/zebra-logo-head.svg b/example/assets/zebra-logo-head.svg new file mode 100644 index 00000000..5b7ff704 --- /dev/null +++ b/example/assets/zebra-logo-head.svg @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/example/lib/home.dart b/example/lib/home.dart index 492c343b..7201d7c5 100644 --- a/example/lib/home.dart +++ b/example/lib/home.dart @@ -148,7 +148,9 @@ class _HomeState extends State { final _assets = assets..sort((a, b) => a.name.compareTo(b.name)); final _theme = theme..sort((a, b) => a.name.compareTo(b.name)); return ExampleScaffold( - name: 'Zeta', + // x-release-please-start-version + name: 'zeta_flutter v0.9.1', + // x-release-please-end child: SingleChildScrollView( child: Column( children: [ diff --git a/example/linux/flutter/generated_plugin_registrant.cc b/example/linux/flutter/generated_plugin_registrant.cc index e71a16d2..f6f23bfe 100644 --- a/example/linux/flutter/generated_plugin_registrant.cc +++ b/example/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/example/linux/flutter/generated_plugins.cmake b/example/linux/flutter/generated_plugins.cmake index 2e1de87a..f16b4c34 100644 --- a/example/linux/flutter/generated_plugins.cmake +++ b/example/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index eefcc6d7..63ad0d13 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,9 +8,11 @@ import Foundation import path_provider_foundation import shared_preferences_foundation import sqflite +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index 8ed0a812..66e9c6e8 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -9,12 +9,15 @@ PODS: - sqflite (0.0.3): - Flutter - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) EXTERNAL SOURCES: FlutterMacOS: @@ -25,12 +28,15 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin sqflite: :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec + url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 diff --git a/example/pubspec.yaml b/example/pubspec.yaml index be247afe..3e3314fb 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,9 +11,13 @@ dependencies: cached_network_image: ^3.3.1 flutter: sdk: flutter + flutter_svg: ^2.0.10+1 go_router: ^14.1.2 + google_fonts: ^6.2.1 + markdown_widget: ^2.3.2+6 path_drawing: ^1.0.1 shared_preferences: ^2.2.2 + url_launcher: ^6.2.6 zeta_flutter: path: ../ @@ -26,3 +30,4 @@ flutter: uses-material-design: true assets: - assets/ + - ../README.md diff --git a/example/web/index.html b/example/web/index.html index f9b1d73c..e1deead4 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -24,39 +24,18 @@ - + - zeta_flutter_example + zeta_flutter example - - - - - + \ No newline at end of file diff --git a/example/web/manifest.json b/example/web/manifest.json index 6a2b8dc5..9f3c9b11 100644 --- a/example/web/manifest.json +++ b/example/web/manifest.json @@ -1,11 +1,11 @@ { - "name": "zeta_flutter_example", - "short_name": "zeta_flutter_example", + "name": "zeta_flutter example", + "short_name": "zeta_flutter example", "start_url": ".", "display": "standalone", "background_color": "#0175C2", "theme_color": "#0175C2", - "description": "Demonstrates how to use the zeta_flutter plugin.", + "description": "Demonstrates how to use the zeta_flutter library", "orientation": "portrait-primary", "prefer_related_applications": false, "icons": [ @@ -32,4 +32,4 @@ "purpose": "maskable" } ] -} +} \ No newline at end of file diff --git a/example/widgetbook/main.dart b/example/widgetbook/main.dart index 5083dfe9..16547e33 100644 --- a/example/widgetbook/main.dart +++ b/example/widgetbook/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:zeta_flutter/zeta_flutter.dart'; @@ -42,22 +43,39 @@ import 'pages/components/snack_bar_widgetbook.dart'; import 'pages/components/tabs_widgetbook.dart'; import 'pages/components/time_input_widgetbook.dart'; import 'pages/components/tooltip_widgetbook.dart'; +import 'pages/introduction.dart'; import 'pages/theme/color_widgetbook.dart'; import 'pages/theme/radius_widgetbook.dart'; import 'pages/theme/spacing_widgetbook.dart'; import 'pages/theme/typography_widgetbook.dart'; import 'utils/zebra.dart'; -void main() => runApp(const HotReload()); +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + String readme = await rootBundle.loadString('../README.md'); -class HotReload extends StatelessWidget { - const HotReload({super.key}); + runApp(HotReload(readme: readme)); +} + +class HotReload extends StatefulWidget { + final String readme; + const HotReload({super.key, required this.readme}); + + @override + State createState() => _HotReloadState(); +} +class _HotReloadState extends State { @override Widget build(BuildContext context) { return Widgetbook( appBuilder: (context, child) => child, + initialRoute: '?path=introduction', directories: [ + WidgetbookUseCase( + name: 'Introduction', + builder: (BuildContext context) => IntroductionWidgetbook(readme: widget.readme), + ), WidgetbookCategory( name: 'Components', isInitiallyExpanded: false, @@ -221,6 +239,10 @@ class HotReload extends StatelessWidget { ); }, ), + AccessibilityAddon(), + InspectorAddon(enabled: false), + ZoomAddon(initialZoom: 1.0), + TextScaleAddon(scales: [1.0, 1.2, 1.4, 1.6, 1.8, 2.0], initialScale: 1), ], ); } diff --git a/example/widgetbook/pages/introduction.dart b/example/widgetbook/pages/introduction.dart new file mode 100644 index 00000000..e28c1c5d --- /dev/null +++ b/example/widgetbook/pages/introduction.dart @@ -0,0 +1,171 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:markdown_widget/config/configs.dart'; +import 'package:markdown_widget/widget/all.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:zeta_flutter/zeta_flutter.dart'; + +class IntroductionWidgetbook extends StatefulWidget { + final String readme; + const IntroductionWidgetbook({super.key, required this.readme}); + + @override + State createState() => _IntroductionWidgetbookState(); +} + +class _IntroductionWidgetbookState extends State { + late String readme; + @override + void initState() { + super.initState(); + readme = widget.readme.replaceAll('# Zeta Flutter', '').trim(); + } + + @override + Widget build(BuildContext context) { + final colors = Zeta.of(context).colors; + final radius = Radius.circular(ZetaSpacing.x5); + final isDark = Zeta.of(context).brightness == Brightness.dark; + final config = isDark ? MarkdownConfig.darkConfig : MarkdownConfig.defaultConfig; + + return LayoutBuilder(builder: (context, constraints) { + final bool largeScreen = constraints.maxWidth > 480; + return Scaffold( + backgroundColor: colors.black, + body: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.symmetric(vertical: ZetaSpacing.xxl, horizontal: ZetaSpacing.s), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + decoration: BoxDecoration( + color: colors.cool.shade20, + borderRadius: BorderRadius.only(topLeft: radius, topRight: radius), + ), + child: Padding( + padding: EdgeInsets.fromLTRB( + ZetaSpacing.x10, + ZetaSpacing.x1 * 15, + ZetaSpacing.x12, + ZetaSpacing.x10, + ), + child: Row( + children: [ + SvgPicture.asset( + './assets/zebra-logo-head.svg', + height: largeScreen ? 80 : 40, + width: largeScreen ? 80 : 40, + colorFilter: isDark + ? const ColorFilter.matrix([ + -1.0, 0.0, 0.0, 0.0, 255.0, // + 0.0, -1.0, 0.0, 0.0, 255.0, // + 0.0, 0.0, -1.0, 0.0, 255.0, // + 0.0, 0.0, 0.0, 1.0, 0.0, // + ]) + : null, + ), + SizedBox(width: largeScreen ? ZetaSpacing.x10 : ZetaSpacing.x5), + Expanded( + child: Text( + // x-release-please-start-version + 'zeta_flutter v0.9.1', + // x-release-please-end + style: ZetaTextStyles.displayLarge.copyWith(fontSize: largeScreen ? null : 24), + ), + ), + ], + ), + ), + ), + Container( + decoration: BoxDecoration( + color: isDark ? colors.warm.shade10 : colors.surfacePrimary, + borderRadius: BorderRadius.only(bottomLeft: radius, bottomRight: radius), + ), + width: double.infinity, + padding: EdgeInsets.all(ZetaSpacing.x8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + MarkdownWidget( + data: readme, + shrinkWrap: true, + config: config.copy( + configs: [ + LinkConfig( + style: TextStyle( + color: colors.blue.shade50, + decoration: TextDecoration.underline, + ), + onTap: (url) { + final Uri? uri = Uri.tryParse(url); + if (uri != null && uri.isAbsolute) { + launchUrl(uri); + } else { + final Uri? uri2 = + Uri.tryParse('https://github.com/ZebraDevs/zeta_flutter/blob/main/' + url); + if (uri2 != null && uri2.isAbsolute) { + launchUrl(uri2); + } + } + }, + ), + CodeConfig(style: GoogleFonts.ibmPlexMono()), + isDark + ? PreConfig.darkConfig.copy( + textStyle: GoogleFonts.ibmPlexMono(), + wrapper: (child, _, language) => _CodeWrapperWidget(child, language), + ) + : PreConfig( + textStyle: GoogleFonts.ibmPlexMono(), + wrapper: (child, _, language) => _CodeWrapperWidget(child, language), + ) + ], + ), + ) + ], + ), + ), + ], + ), + ), + ), + ); + }); + } +} + +class _CodeWrapperWidget extends StatelessWidget { + final Widget child; + final String language; + + const _CodeWrapperWidget(this.child, this.language, {Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final colors = Zeta.of(context).colors; + + return Stack( + children: [ + DefaultTextStyle( + style: GoogleFonts.ibmPlexMono(color: Zeta.of(context).colors.textDefault), + child: child, + ), + if (language.isNotEmpty) + Positioned( + top: ZetaSpacing.x2, + right: 0, + child: SelectionContainer.disabled( + child: Container( + child: Text(language), + padding: EdgeInsets.symmetric(vertical: ZetaSpacing.x1, horizontal: ZetaSpacing.x3), + decoration: BoxDecoration(color: colors.cool.shade40, borderRadius: ZetaRadius.rounded), + ), + ), + ), + ], + ); + } +} diff --git a/example/windows/flutter/generated_plugin_registrant.cc b/example/windows/flutter/generated_plugin_registrant.cc index 8b6d4680..4f788487 100644 --- a/example/windows/flutter/generated_plugin_registrant.cc +++ b/example/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake index b93c4c30..88b22e5c 100644 --- a/example/windows/flutter/generated_plugins.cmake +++ b/example/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/release-please-config.json b/release-please-config.json index 66d1ec8a..8a766b83 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,5 +4,63 @@ "release-type": "dart" } }, - "include-component-in-tag": false + "include-component-in-tag": false, + "extra-files": [ + "example/lib/home.dart" + ], + "changelog-sections": [ + { + "type": "feat", + "section": "โœจ New Features" + }, + { + "type": "fix", + "section": "๐Ÿชฒ Bug Fixes" + }, + { + "type": "revert", + "section": "๐Ÿ‘€ Reverts" + }, + { + "type": "docs", + "section": "๐Ÿ“ˆ Documentation" + }, + { + "type": "deps", + "section": "โ›“๏ธ Dependencies" + }, + { + "type": "test", + "section": "๐Ÿงช Tests" + }, + { + "type": "chore", + "section": "๐Ÿงน Miscellaneous Chores" + }, + { + "type": "perf", + "section": "Performance Improvements", + "hidden": true + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": true + }, + { + "type": "style", + "section": "Styles", + "hidden": true + }, + { + "type": "build", + "section": "Build System", + "hidden": true + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ] } \ No newline at end of file