diff --git a/Gemfile b/Gemfile index dac5d6e83..050bd30c5 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" ruby '3.2.2' +gem 'cocoapods', '~> 1.14.3' gem "fastlane" plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') diff --git a/Gemfile.lock b/Gemfile.lock index b6b67b41d..8653524f1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,8 +3,21 @@ GEM specs: CFPropertyList (3.0.6) rexml + activesupport (7.1.3) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) @@ -24,18 +37,64 @@ GEM aws-sigv4 (1.6.0) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) + base64 (0.2.0) + bigdecimal (3.1.6) claide (1.1.0) + cocoapods (1.14.3) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.14.3) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 2.1, < 3.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.6.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 2.3.0, < 3.0) + xcodeproj (>= 1.23.0, < 2.0) + cocoapods-core (1.14.3) + activesupport (>= 5.0, < 8) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (2.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) colored (1.2) colored2 (3.1.2) commander (4.6.0) highline (~> 2.0.0) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) declarative (0.0.20) digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) dotenv (2.8.1) + drb (2.2.0) + ruby2_keywords emoji_regex (3.2.3) + escape (0.0.4) + ethon (0.16.0) + ffi (>= 1.15.0) excon (0.102.0) faraday (1.10.3) faraday-em_http (~> 1.0) @@ -107,6 +166,9 @@ GEM xcpretty-travis-formatter (>= 0.0.3) fastlane-plugin-firebase_app_distribution (0.7.2) google-apis-firebaseappdistribution_v1 (~> 0.3.0) + ffi (1.16.3) + fourflusher (2.3.1) + fuzzy_match (2.0.4) gh_inspector (1.1.3) google-apis-androidpublisher_v3 (0.48.0) google-apis-core (>= 0.11.0, < 2.a) @@ -152,20 +214,27 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) httpclient (2.8.3) + i18n (1.14.1) + concurrent-ruby (~> 1.0) jmespath (1.6.2) json (2.6.3) jwt (2.7.1) memoist (0.16.2) mini_magick (4.12.0) mini_mime (1.1.5) + minitest (5.22.1) + molinillo (0.8.0) multi_json (1.15.0) multipart-post (2.3.0) + mutex_m (0.2.0) nanaimo (0.3.0) + nap (1.1.0) naturally (2.2.1) + netrc (0.11.0) optparse (0.1.1) os (1.1.4) plist (3.7.0) - public_suffix (5.0.3) + public_suffix (4.0.7) rake (13.0.6) representable (3.2.0) declarative (< 0.1.0) @@ -174,6 +243,7 @@ GEM retriable (3.1.2) rexml (3.2.6) rouge (2.0.7) + ruby-macho (2.5.1) ruby2_keywords (0.0.5) rubyzip (2.3.2) security (0.1.3) @@ -193,6 +263,10 @@ GEM tty-screen (0.8.1) tty-spinner (0.9.3) tty-cursor (~> 0.7) + typhoeus (1.4.1) + ethon (>= 0.9.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) uber (0.1.0) unf (0.1.4) unf_ext @@ -200,7 +274,7 @@ GEM unicode-display_width (1.8.0) webrick (1.8.1) word_wrap (1.0.0) - xcodeproj (1.22.0) + xcodeproj (1.24.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) @@ -216,6 +290,7 @@ PLATFORMS ruby DEPENDENCIES + cocoapods (~> 1.14.3) fastlane fastlane-plugin-firebase_app_distribution diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 972daffce..7534963e5 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -38,4 +38,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/lib/app/shared/widgets/button/widgetbook.dart b/lib/app/shared/widgets/button/widgetbook.dart new file mode 100644 index 000000000..ac81bbb08 --- /dev/null +++ b/lib/app/shared/widgets/button/widgetbook.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; +import 'package:ice/app/shared/widgets/button/button.dart'; +import 'package:widgetbook/widgetbook.dart'; +import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; + +@widgetbook.UseCase( + name: 'with green color', + type: Button, +) +Widget greenContainerUseCase(BuildContext context) { + return Center( + child: Button( + type: ButtonType.outlined, + label: Text( + context.knobs.string( + label: 'Title', + initialValue: 'Controllable Title', + ), + ), + onPressed: () {}, + ), + ); +} + +@widgetbook.UseCase( + name: 'with red color', + type: Button, +) +Widget redContainerUseCase(BuildContext context) { + return Center( + child: Button( + type: ButtonType.disabled, + label: const Text('Text'), + onPressed: () {}, + ), + ); +} diff --git a/lib/main.dart b/lib/main.dart index 0c24d8ee6..d1953b3da 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,12 +32,8 @@ class IceApp extends HookConsumerWidget { builder: (BuildContext context, Widget? widget) => MaterialApp.router( localizationsDelegates: I18n.localizationsDelegates, supportedLocales: I18n.supportedLocales, - theme: template.whenOrNull( - data: (Template data) => buildLightTheme(data), - ), - darkTheme: template.whenOrNull( - data: (Template data) => buildDarkTheme(data), - ), + theme: template.whenOrNull(data: buildLightTheme), + darkTheme: template.whenOrNull(data: buildDarkTheme), themeMode: appThemeMode, routerConfig: appRouter, ), diff --git a/lib/widgetbook/README.md b/lib/widgetbook/README.md new file mode 100644 index 000000000..cf8dedd53 --- /dev/null +++ b/lib/widgetbook/README.md @@ -0,0 +1 @@ +# A playground to streamline shared UI Widgets with Widgetbook \ No newline at end of file diff --git a/lib/widgetbook/main.dart b/lib/widgetbook/main.dart new file mode 100644 index 000000000..290a61fb8 --- /dev/null +++ b/lib/widgetbook/main.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:ice/app/features/core/providers/init_provider.dart'; +import 'package:ice/app/features/core/providers/template_provider.dart'; +import 'package:ice/app/features/core/providers/theme_mode_provider.dart'; +import 'package:ice/app/templates/template.dart'; +import 'package:ice/app/theme/theme.dart'; +import 'package:ice/generated/app_localizations.dart'; +import 'package:ice/widgetbook/main.directories.g.dart'; +import 'package:widgetbook/widgetbook.dart'; +import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; + +void main() { + runApp(const ProviderScope(child: WidgetbookApp())); +} + +@widgetbook.App() +class WidgetbookApp extends ConsumerWidget { + const WidgetbookApp({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final AsyncValue init = ref.watch(initAppProvider); + + return init.when( + data: (void data) => Widgetbook.material( + directories: directories, + appBuilder: (BuildContext context, Widget child) { + final ThemeMode appThemeMode = ref.watch(appThemeModeProvider); + final AsyncValue