diff --git a/README.md b/README.md index bcfcd05..94ad21e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ This is a monorepo containing these packages: -- [tide](packages/tide_kit/) +- [tide_kit](packages/tide_kit/) diff --git a/packages/tide_kit/.flutter-plugins b/packages/tide_kit/.flutter-plugins deleted file mode 100644 index e730d03..0000000 --- a/packages/tide_kit/.flutter-plugins +++ /dev/null @@ -1,18 +0,0 @@ -# This is a generated file; do not edit or check into version control. -device_info_plus=/Users/larry/.pub-cache/hosted/pub.dev/device_info_plus-11.1.1/ -package_info_plus=/Users/larry/.pub-cache/hosted/pub.dev/package_info_plus-8.1.1/ -path_provider_linux=/Users/larry/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/ -path_provider_windows=/Users/larry/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/ -shared_preferences=/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences-2.3.3/ -shared_preferences_android=/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.4/ -shared_preferences_foundation=/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/ -shared_preferences_linux=/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/ -shared_preferences_web=/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/ -shared_preferences_windows=/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/ -url_launcher=/Users/larry/.pub-cache/hosted/pub.dev/url_launcher-6.3.1/ -url_launcher_android=/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_android-6.3.14/ -url_launcher_ios=/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_ios-6.3.2/ -url_launcher_linux=/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_linux-3.2.1/ -url_launcher_macos=/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_macos-3.2.2/ -url_launcher_web=/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_web-2.3.3/ -url_launcher_windows=/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.3/ diff --git a/packages/tide_kit/.flutter-plugins-dependencies b/packages/tide_kit/.flutter-plugins-dependencies deleted file mode 100644 index 8f0a8a9..0000000 --- a/packages/tide_kit/.flutter-plugins-dependencies +++ /dev/null @@ -1 +0,0 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/device_info_plus-11.1.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/package_info_plus-8.1.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_ios-6.3.2/","native_build":true,"dependencies":[]}],"android":[{"name":"device_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/device_info_plus-11.1.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/package_info_plus-8.1.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.4/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_android-6.3.14/","native_build":true,"dependencies":[]}],"macos":[{"name":"device_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/device_info_plus-11.1.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/package_info_plus-8.1.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_macos-3.2.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/device_info_plus-11.1.1/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/package_info_plus-8.1.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/larry/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_linux-3.2.1/","native_build":true,"dependencies":[]}],"windows":[{"name":"device_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/device_info_plus-11.1.1/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/package_info_plus-8.1.1/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/larry/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]},{"name":"url_launcher_windows","path":"/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.3/","native_build":true,"dependencies":[]}],"web":[{"name":"device_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/device_info_plus-11.1.1/","dependencies":[]},{"name":"package_info_plus","path":"/Users/larry/.pub-cache/hosted/pub.dev/package_info_plus-8.1.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/larry/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/larry/.pub-cache/hosted/pub.dev/url_launcher_web-2.3.3/","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2025-01-05 08:01:28.539382","version":"3.24.5","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/packages/tide_kit/README.md b/packages/tide_kit/README.md index 6560d4c..467b994 100644 --- a/packages/tide_kit/README.md +++ b/packages/tide_kit/README.md @@ -57,6 +57,7 @@ This section defines key concepts of Tide Kit. # Getting started +### Example 1 When implementing a new app with Tide, start with this example to display a standard workbench with a status bar, and Tide initialization. ```dart @@ -74,6 +75,9 @@ void main() { } ``` +When running this code on macOS you should see a window like this: +![Screenshot](doc/tide_example_1.png) + Note that the use of `TideApp` is optional and does not affect the functionality of the Tide app. It is provided as a convenience to help you get started with your app. @@ -81,6 +85,230 @@ For more detailed examples, look at the `example/lib/main.dart` file [here](http When adding Tide to an existing app, just start with a `TideWindow`. +### Example 2 +Here is an example with an activity bar and a status bar item for the current time. +When running this code on macOS you should see a window like this: +```dart +void main() { + final tide = Tide(); + tide.useServices(services: [Tide.ids.service.time]); + + final workbenchService = Tide.get(); + workbenchService.layoutService.addActivityBarItems([ + TideActivityBarItem(title: 'Explorer', icon: Icons.file_copy_outlined), + TideActivityBarItem(title: 'Search', icon: Icons.search_outlined), + TideActivityBarItem(title: 'Share', icon: Icons.share_outlined), + TideActivityBarItem( + title: 'Settings', + icon: Icons.settings_outlined, + position: TideActivityBarItemPosition.end), + ]); + + runApp( + TideApp( + home: TideWindow( + workbench: TideWorkbench( + activityBar: const TideActivityBar(), + statusBar: TideStatusBar( + items: [ + TideStatusBarItemTime(position: TideStatusBarItemPosition.right) + ], + ), + ), + ), + ), + ); +} +``` +![Screenshot](doc/tide_example_2.png) + +### Example 3 +Here is a more extensive example with left and right panels, activity bar, and a few status bar items. +When running this code on macOS you should see a window like this: +```dart +void main() { + final tide = Tide(); + + tide.useServices(services: [ + Tide.ids.service.notifications, + Tide.ids.service.time, + ]); + + final leftPanelId = TideId.uniqueId(); + final mainPanelId = TideId.uniqueId(); + + final workbenchService = Tide.get(); + workbenchService.layoutService.addPanels([ + TidePanel(panelId: leftPanelId), + TidePanel(panelId: mainPanelId), + ]); + workbenchService.layoutService.addActivityBarItems([ + TideActivityBarItem( + title: 'Calendar Day', + icon: Icons.calendar_month, + ), + ]); + + final tideOS = TideOS(); + + final statusBarColor = ValueNotifier(null); + + TideNotification? timeNotification; + + tide.workbenchService.layoutService.addStatusBarItem(TideStatusBarItem( + position: TideStatusBarItemPosition.left, + builder: (context, item) { + return TideStatusBarItemContainer( + item: item, + onPressed: (TideStatusBarItem item) { + statusBarColor.value = + statusBarColor.value == null ? Colors.red : null; + }, + tooltip: 'Click to toggle the status bar', + child: const Row( + children: [ + Icon(Icons.sync, size: 16.0, color: Colors.white), + SizedBox(width: 4.0), + Text('Toggle status bar', style: TideStatusBarItemTextWidget.style), + ], + ), + ); + }, + )); + + num progressWorked = 0; + final progressItem = TideStatusBarItemProgress( + position: TideStatusBarItemPosition.center, + infinite: false, + progressTotal: 10.0, + progressWorked: progressWorked, + onPressedClose: (TideStatusBarItem item) { + if (item is TideStatusBarItemProgress) { + final newItem = item.copyWith(infinite: true); + tide.workbenchService.layoutService.replaceStatusBarItem(newItem); + } + }, + tooltip: 'Click to restart the progress bar', + ); + tide.workbenchService.layoutService.addStatusBarItem(progressItem); + + Timer.periodic(const Duration(milliseconds: 250), (timer) { + final item = tide.workbenchService.layoutService.statusBarState.value + .getItem(progressItem.itemId); + if (item is TideStatusBarItemProgress) { + if (!item.infinite) { + progressWorked = progressWorked == 10 ? 0 : progressWorked + 1; + final newItem = item.copyWith(progressWorked: progressWorked); + tide.workbenchService.layoutService.replaceStatusBarItem(newItem); + } + } + }); + + tide.workbenchService.layoutService.addStatusBarItem(TideStatusBarItem( + position: TideStatusBarItemPosition.right, + builder: (context, item) { + return TideStatusBarItemContainer( + item: item, + tooltip: 'Account', + child: + const Icon(Icons.account_circle, size: 16.0, color: Colors.white), + ); + }, + )); + + tide.workbenchService.layoutService.addStatusBarItem(TideStatusBarItemText( + position: TideStatusBarItemPosition.right, + onPressed: (TideStatusBarItem item) { + final notificationService = Tide.get(); + final notification = TideNotification( + message: 'Flutter: Hot reloading...', + severity: TideNotificationSeverity.info, + autoTimeout: true, + progressInfinite: true); + notificationService.notify(notification); + final msg2 = + '${tideOS.currentTypeFormatted} ${tideOS.operatingSystemVersion}'; + notificationService.warning(msg2, autoTimeout: true); + final msg1 = + '${tideOS.currentTypeFormatted} ${tideOS.operatingSystemVersion}' + ' This is a very long message to test out lots of wrapping across this notification.'; + notificationService.error(msg1, autoTimeout: true); + final msg = + '${tideOS.currentTypeFormatted} ${tideOS.operatingSystemVersion}'; + notificationService.info(msg, autoTimeout: true, allowClose: false); + }, + text: tideOS.currentTypeFormatted, + tooltip: 'OS Type', + )); + + tide.workbenchService.layoutService.addStatusBarItem(TideStatusBarItemTime( + position: TideStatusBarItemPosition.right, + tooltip: 'The current time', + onPressed: (TideStatusBarItem item) { + final notificationService = Tide.get(); + if (timeNotification == null || + !notificationService.notificationExists(timeNotification!.id)) { + final timeService = Tide.get(); + final msg = + 'The time is: ${timeService.currentTimeState.timeFormatted()}'; + timeNotification = + notificationService.info(msg, autoTimeout: true, allowClose: false); + } + }, + )); + + tide.workbenchService.layoutService.addStatusBarItem(TideStatusBarItem( + position: TideStatusBarItemPosition.right, + builder: (context, item) { + return TideStatusBarItemContainer( + item: item, + tooltip: 'Notifications', + child: const Icon(Icons.notifications_none_outlined, + size: 16.0, color: Colors.white), + ); + }, + )); + + runApp( + ValueListenableBuilder( + valueListenable: statusBarColor, + builder: (context, colorValue, child) { + return TideApp( + home: TideWindow( + workbench: TideWorkbench( + activityBar: const TideActivityBar(), + panelBuilder: (context, panel) { + if (panel.panelId.id == leftPanelId.id) { + return TidePanelWidget( + panelId: panel.panelId, + backgroundColor: const Color(0xFFF3F3F3), + position: TidePosition.left, + resizeSide: TidePosition.right, + minWidth: 100, + maxWidth: 450, + initialWidth: 220, + child: const Center(child: Text('Left Panel')), + ); + } else if (panel.panelId.id == mainPanelId.id) { + return const TidePanelWidget( + backgroundColor: Colors.white, + expanded: true, + position: TidePosition.center, + child: Center(child: Text('Main Panel')), + ); + } + return null; + }, + statusBar: TideStatusBar(backgroundColor: colorValue)), + ), + ); + }, + ), + ); +} +``` +![Screenshot](doc/tide_example_3.png) +