### Installation - Bundle Directory Setup Source: https://github.com/tolyfx/toly_ui/blob/main/modules/form/tolyui_rich_input/example/linux/CMakeLists.txt Sets the installation prefix to the bundle directory and ensures it's clean before installation. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Installation Configuration Source: https://github.com/tolyfx/toly_ui/blob/main/linux/CMakeLists.txt Configures the installation process, setting the install prefix to a bundle directory and ensuring a clean build bundle. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Example: Create Button Module Source: https://github.com/tolyfx/toly_ui/blob/main/test/script/README.md Example of creating a button module categorized under 'form'. ```bash dart test/script/create_module.dart toly_button form ``` -------------------------------- ### Installation Configuration Source: https://github.com/tolyfx/toly_ui/blob/main/windows/CMakeLists.txt Configures installation paths and rules for the application executable, support files, and assets. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Example: Create Avatar Module Source: https://github.com/tolyfx/toly_ui/blob/main/test/script/README.md Example of creating an avatar module categorized under 'data'. ```bash dart test/script/create_module.dart toly_avatar data ``` -------------------------------- ### Project and CMake Version Setup Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Sets the minimum required CMake version and the project name with supported languages. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Installation Rules for Executable and Data Source: https://github.com/tolyfx/toly_ui/blob/main/modules/feedback/tolyui_feedback/example/windows/CMakeLists.txt Configures the installation of the main executable, ICU data file, and Flutter library to specific destinations within the installation prefix, ensuring the application can run in place. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation - Bundle Data and Library Directories Source: https://github.com/tolyfx/toly_ui/blob/main/modules/form/tolyui_rich_input/example/linux/CMakeLists.txt Defines the destination directories for data and libraries within the installation bundle. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Application Executable Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. This is a core step in making the application runnable. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Executable and Data Source: https://github.com/tolyfx/toly_ui/blob/main/linux/CMakeLists.txt Installs the application executable to the bundle's root and ICU data to the data directory. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Windows Installation Configuration Source: https://github.com/tolyfx/toly_ui/blob/main/modules/form/tolyui_rich_input/example/windows/CMakeLists.txt Configures installation rules for the Windows platform, ensuring files are placed correctly next to the executable for in-place execution. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installation Rules Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/linux/CMakeLists.txt Defines how the application bundle is installed, including the executable, data files, libraries, and assets. It ensures a clean build bundle directory and proper placement of files. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installation - Native Assets Source: https://github.com/tolyfx/toly_ui/blob/main/modules/form/tolyui_rich_input/example/linux/CMakeLists.txt Installs native assets provided by the build.dart script to the lib directory within the bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation - Bundled Plugin Libraries Source: https://github.com/tolyfx/toly_ui/blob/main/modules/form/tolyui_rich_input/example/linux/CMakeLists.txt Installs bundled libraries provided by plugins to the lib directory within the bundle. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Define Installation Directories Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Sets variables for the installation paths of data and library files within the application bundle. These paths are relative to the CMAKE_INSTALL_PREFIX. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Rule Prioritization Example Source: https://github.com/tolyfx/toly_ui/blob/main/modules/basic/tolyui_text/doc/HighlightText组件介绍.md Demonstrates best practice for defining regular expression rules in HighlightText, recommending a specific-to-general order to avoid conflicts and ensure correct pattern matching. Includes examples for email, phone numbers, and general numbers. ```dart // 推荐:从具体到通用 final rules = { Rule(RegExp(r'\S+@\S+\.\S+')): emailStyle, // 邮箱(具体) Rule(RegExp(r'1[3-9]\d{9}')): phoneStyle, // 手机号(具体) Rule(RegExp(r'\d+')): numberStyle, // 数字(通用) }; ``` -------------------------------- ### Install Libraries and Assets Source: https://github.com/tolyfx/toly_ui/blob/main/linux/CMakeLists.txt Installs the Flutter library, bundled plugin libraries, and native assets into the bundle's library directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for Windows Executable Source: https://github.com/tolyfx/toly_ui/blob/main/modules/feedback/tolyui_feedback_modal/example/windows/CMakeLists.txt Configures installation paths for the main executable, Flutter ICU data, libraries, and bundled plugin libraries, ensuring they are placed correctly for runtime execution. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Installs any bundled plugin libraries to the application bundle's runtime directory. This ensures that plugins are available at runtime. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/tolyfx/toly_ui/blob/main/linux/CMakeLists.txt Removes the existing Flutter assets directory and then installs the new one. This ensures the latest assets are present. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install( CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Basic Tag Example Source: https://github.com/tolyfx/toly_ui/blob/main/modules/data/tolyui_tag/README.md Demonstrates the creation of a default tag. Use this for simple, non-interactive labels. ```dart // 基础标签 Tag( child: Text('默认标签'), ) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the application bundle's runtime directory. This is essential for the Flutter engine to load. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### TolyAction Widget Examples Source: https://github.com/tolyfx/toly_ui/blob/main/assets/code_res/action_demo2.txt This snippet demonstrates the creation and usage of TolyAction widgets with custom styles and tap actions. It includes examples for common actions like settings, copy, and view code, as well as a sponsored action and a disabled action. ```Dart class ActionDemo2 extends StatelessWidget { const ActionDemo2({super.key}); @override Widget build(BuildContext context) { ActionStyle style = ActionStyle( borderRadius: BorderRadius.circular(4), padding: const EdgeInsets.all(4), backgroundColor: Colors.blue.withOpacity(0.2), border: Border.all(color: Colors.blue), ); return Wrap( spacing: 6, children: [ TolyAction( tooltip: '设置', style: style, onTap: () => $message.success(message: '打开设置行为触发!'), child: Icon( Icons.settings, size: 20, ), ), TolyAction( tooltip: '复制', style: style, onTap: () => $message.success(message: '复制行为触发!'), child: Icon( Icons.copy_all_outlined, size: 20, ), ), TolyAction( tooltip: '查看代码', style: style, onTap: () => $message.success(message: '查看代码行为触发!'), child: Icon( Icons.code, size: 20, ), ), TolyAction( tooltip: '赞助', style: style, toolTipPlacement: Placement.top, onTap: () => AppRoute.sponsor.go(context), child: Icon( Icons.monetization_on_rounded, size: 20, ), ), TolyAction( tooltip: '结构', onTap: null, child: Icon( Icons.account_tree_sharp, size: 20, ), ), ], ); } } ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Installs the Flutter assets directory. It first removes any existing assets to ensure a clean copy, then copies the assets from the build directory to the application's data directory. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Component Case File Structure Source: https://github.com/tolyfx/toly_ui/blob/main/doc/quick_integration_guide.md Example file names for different cases of a component. Cases should be ordered from simple to complex. ```dart progress/ ├── progress_demo1.dart # 基础进度条 ├── progress_demo2.dart # 圆形进度条 ├── progress_demo3.dart # 不确定进度 ├── progress_demo4.dart # 自定义颜色 └── progress_demo5.dart # 动态进度 ``` -------------------------------- ### Native Assets and Flutter Assets Installation Source: https://github.com/tolyfx/toly_ui/blob/main/modules/feedback/tolyui_feedback_modal/example/windows/CMakeLists.txt Installs native assets and Flutter assets, ensuring the Flutter assets directory is completely re-copied on each build to prevent stale files. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install TolyUI Image Source: https://github.com/tolyfx/toly_ui/blob/main/modules/media/tolyui_image/README.md Add the TolyUI Image dependency to your pubspec.yaml file. ```yaml dependencies: tolyui_image: ^0.0.1+2 ``` -------------------------------- ### TolyInput with Leading and Tailing Widgets Source: https://github.com/tolyfx/toly_ui/blob/main/assets/code_res/input_demo3.txt An example of TolyInput with both a leading widget ('https://') and a trailing widget ('.com'). ```dart TolyInput( hintText: 'Server Host', leadingBuilder: SlotBuilder( builder: (_, __) => const Text('https://', style: TextStyle(color: Color(0xff1e1e1e))), ), tailingBuilder: SlotBuilder( builder: (_, __) => const Text('.com', style: TextStyle(color: Color(0xff1e1e1e))), ), ) ``` -------------------------------- ### Count-up Timer Example Source: https://github.com/tolyfx/toly_ui/blob/main/assets/code_res/statistics_demo3.txt Displays a count-up timer starting from a specified past time. The 'format' property controls the display. ```dart Center( child: Row( mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(16.0), child: TolyStatisticTimer( type: TimerType.countup, title: '正计时', value: before, format: 'HH:mm:ss', ), ), const SizedBox(width: 16), Padding( padding: const EdgeInsets.all(16.0), child: TolyStatisticTimer( type: TimerType.countdown, title: '天数级倒计时', value: deadline, format: 'D天 H时 m分 s秒', ), ), ], ), ) ``` -------------------------------- ### Create Component Directory Source: https://github.com/tolyfx/toly_ui/blob/main/doc/quick_integration_guide.md Use this command to create the necessary directory structure for a new component within the TolyUI framework. ```bash mkdir -p lib/view/widgets/{module}/{component} ``` ```bash mkdir -p lib/view/widgets/data/progress ``` -------------------------------- ### Install AOT Library (Non-Debug) Source: https://github.com/tolyfx/toly_ui/blob/main/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library. This is only performed for release or other non-debug build types. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install ICU Data File Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Installs the ICU data file, which is necessary for internationalization and localization, to the data directory of the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Project and CMake Version Setup Source: https://github.com/tolyfx/toly_ui/blob/main/windows/CMakeLists.txt Sets the minimum required CMake version and the project name. It also explicitly opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.14) project(toly_ui LANGUAGES CXX) ``` ```cmake set(BINARY_NAME "toly_ui") ``` ```cmake cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Run Application Source: https://github.com/tolyfx/toly_ui/blob/main/modules/tolyui/README.md Execute this command to run the TolyUI application during development. ```bash flutter run ``` -------------------------------- ### Generate Routes and Resources Source: https://github.com/tolyfx/toly_ui/blob/main/modules/tolyui/README.md Run this command to generate necessary routes and code resources for the TolyUI project. ```bash toly ui ``` -------------------------------- ### TolyCard Shadow Modes Example Source: https://github.com/tolyfx/toly_ui/blob/main/assets/code_res/card_demo3.txt This example demonstrates the three shadow modes for TolyCard: 'always', 'hover', and 'never'. Each card is configured with a list of BoxShadows and a specific shadowMode. ```dart class CardDemo3 extends StatelessWidget { const CardDemo3({super.key}); @override Widget build(BuildContext context) { List shadows = [ BoxShadow( color: Colors.blue.withOpacity(0.04), blurRadius: 8, spreadRadius: 2, offset: const Offset(0, 0), ), BoxShadow( color: Colors.blue.withOpacity(0.08), blurRadius: 6, spreadRadius: 4, offset: Offset(0, 2), ), ]; return Wrap( spacing: 12, children: [ SizedBox( width: 100, child: TolyCard( shadowMode: ShadowMode.always, shadows: shadows, child: DebugDisplayTile( title: 'always', centerTitle: true, content: '总是会展示阴影效果', foot: '阴影模式', )), ), SizedBox( width: 100, child: TolyCard( shadowMode: ShadowMode.hover, shadows: shadows, child: DebugDisplayTile( title: 'hover', centerTitle: true, content: '悬浮时展示阴影效果', foot: '阴影模式', )), ), SizedBox( width: 100, child: TolyCard( shadowMode: ShadowMode.never, shadows: shadows, child: DebugDisplayTile( title: 'never', centerTitle: true, content: '永不展示阴影效果', foot: '阴影模式', )), ), ], ); } } ``` -------------------------------- ### Project-level Configuration Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/linux/CMakeLists.txt Sets up the minimum CMake version, project name, and executable name. It also defines the application ID and opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Root filesystem for cross-building. if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() # Define build configuration options. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Basic TolyPagination Setup Source: https://github.com/tolyfx/toly_ui/blob/main/assets/code_res/pagination_demo2.txt This snippet shows the basic configuration of the TolyPagination widget. It requires the total number of items, the number of items per page, and the display capacity for the pagination controls. ```dart class PaginationDemo2 extends StatelessWidget { const PaginationDemo2({super.key}); @override Widget build(BuildContext context) { return Align( alignment: Alignment.centerLeft, child: TolyPagination( total: 10000, pageSize: 10, capacity: 15, )); } } ``` -------------------------------- ### Set Installation Prefix for Windows Bundle Source: https://github.com/tolyfx/toly_ui/blob/main/modules/advanced/tolyui_refresh/example/windows/CMakeLists.txt Configures the installation prefix to be adjacent to the executable for Windows builds. This allows the application to run directly from the build directory without a separate bundle. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Development Commands Source: https://github.com/tolyfx/toly_ui/blob/main/README.md Common commands for developing with TolyUI, including running the app, generating resources, creating new modules, and integrating components. ```bash # Run the application flutter run # Generate routing and code resources toly ui # Create a new module dart test/script/create_module.dart # Integrate a component dart test/script/integrate_component.dart