├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DEVELOPER_GUIDE.md ├── Documentation ├── Apis │ ├── Flutter.md │ ├── JS通信与工具.md │ ├── JS页面渲染.md │ └── Native.md ├── README_EN.md ├── 使用Javascript构建Flutter应用程序的原理.md ├── 基于Native的三端通信机制.md ├── 基础组件 │ ├── AppBar.md │ ├── Button.md │ ├── Checkbox.md │ ├── Container.md │ ├── DragableScrollView.md │ ├── Icon.md │ ├── Image.md │ ├── Input.md │ ├── ListView.md │ ├── NativeView.md │ ├── NestScrollView.md │ ├── Page.md │ ├── Picker.md │ ├── Radio.md │ ├── Refresh.md │ ├── ScrollView.md │ ├── SwipeActionsView.md │ ├── SwiperView.md │ ├── Text.md │ └── 组件说明.md ├── 打包说明.md ├── 目录.md └── 调试工具说明.md ├── LICENSE ├── LICENSE.md ├── README.md ├── ROADMAP.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── io │ └── manbang │ └── frontend │ └── thresh │ ├── Thresh.kt │ ├── ThreshPlugin.java │ ├── channel │ ├── BridgeCallback.java │ ├── BridgeUtil.java │ ├── MethodChannelModule.java │ ├── MethodChannelProvider.java │ ├── MethodConstants.java │ └── nativemodule │ │ ├── BridgeRequestInvoke.java │ │ ├── NativeModule.java │ │ ├── ReportPerformanceInvoke.java │ │ ├── SendResultInvoke.java │ │ └── TimerOperatorInvoke.java │ ├── containers │ ├── ThreshActivity.java │ ├── ThreshFlutterActivityAndFragmentDelegate.java │ ├── ThreshFlutterActivityLaunchConfigs.java │ ├── ThreshFlutterSplashView.java │ └── ThreshFragment.java │ ├── manager │ ├── ContextIdManager.kt │ ├── config │ │ ├── ThreshConfigManager.kt │ │ └── configparse │ │ │ ├── AssetConfigParse.kt │ │ │ ├── CommonConfigParse.kt │ │ │ └── FileAssetConfigParse.kt │ ├── flutterengine │ │ ├── FlutterEngineExecute.java │ │ ├── IFlutterEngineExecute.java │ │ ├── ThreshActivityFlutterContainer.java │ │ ├── ThreshFragmentContainer.java │ │ └── ThreshIntentContainer.java │ └── handler │ │ ├── ThreshHandlerManager.kt │ │ └── interfaces │ │ └── IReportHandler.kt │ ├── runtime │ ├── EngineService.java │ ├── JSManager.java │ ├── JSModule.java │ ├── JSThread.java │ ├── ThreshEngine.java │ ├── ThreshEngineOptions.java │ ├── ThreshException.java │ ├── jscore │ │ ├── MBJSExecutor.java │ │ ├── bundle │ │ │ ├── BundleCallback.java │ │ │ ├── BundleOptions.java │ │ │ ├── BundleType.java │ │ │ ├── ContainerType.java │ │ │ ├── JSBundleLoader.java │ │ │ └── JSBundleLoaderDelegate.java │ │ ├── runtime │ │ │ ├── CompatInjectJS.java │ │ │ ├── JSCallback.java │ │ │ └── JSExecutor.java │ │ └── util │ │ │ ├── FileUtils.java │ │ │ └── V8Util.java │ └── release │ │ ├── JsModuleReleaseConfig.java │ │ ├── ModuleRelease.java │ │ └── ReleaseService.java │ ├── util │ ├── CompactUtil.java │ ├── ThreshLogger.java │ ├── ThreshReporter.java │ └── ThreshToast.java │ └── view │ ├── LifecycleListener.java │ ├── ThreshFlutterView.java │ └── platformview │ └── ThreshNativeViewRegistrant.java ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── assets │ │ │ └── bundle.js │ │ │ ├── java │ │ │ └── io │ │ │ │ └── manbang │ │ │ │ └── frontend │ │ │ │ └── thresh_example │ │ │ │ ├── MainActivity.java │ │ │ │ ├── TestJSBundleLoader.java │ │ │ │ ├── ThreshApplication.kt │ │ │ │ ├── ThreshDemoActivity.java │ │ │ │ ├── ThreshDemoBridge.java │ │ │ │ ├── ThreshDemoFragment.java │ │ │ │ ├── ThreshDemoFragmentActivity.java │ │ │ │ ├── ThreshDemoMethodChannel.java │ │ │ │ └── nativeview │ │ │ │ ├── NativeTextView.java │ │ │ │ └── NativeViewFactory.java │ │ │ └── res │ │ │ ├── drawable │ │ │ ├── btn_shape_roundrect.xml │ │ │ ├── btn_switch.xml │ │ │ └── launch_background.xml │ │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ ├── activity_thresh_container.xml │ │ │ └── activity_thresh_flutter_fragment_container.xml │ │ │ ├── mipmap-xhdpi │ │ │ ├── btn_switch_checked.webp │ │ │ ├── btn_switch_none.webp │ │ │ ├── btn_switch_thumb_on.png │ │ │ ├── common_error_banner.png │ │ │ ├── df_title_btn_back.png │ │ │ └── logo.png │ │ │ └── values │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── Flutter │ │ ├── .last_build_id │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ ├── Flutter.podspec │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── AppIcon120.png │ │ │ ├── AppIcon180.png │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── common_error_banner.imageset │ │ │ ├── Contents.json │ │ │ └── common_error_banner.png │ │ └── scroll_image.imageset │ │ │ ├── Contents.json │ │ │ └── example_ios_Runner_Assets.xcassets_scroll_image.imageset_2.png │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── JS.bundle │ │ ├── Root.plist │ │ ├── bundle.js │ │ └── en.lproj │ │ │ └── Root.strings │ │ ├── NativeImagePlatformView.h │ │ ├── NativeImagePlatformView.m │ │ ├── NativeScrollPlatformView.h │ │ ├── NativeScrollPlatformView.m │ │ ├── SettingViewController.h │ │ ├── SettingViewController.m │ │ ├── ThreshScrollView.h │ │ ├── ThreshScrollView.m │ │ ├── main.m │ │ └── threshOptions │ │ ├── InfoCollector.h │ │ ├── InfoCollector.m │ │ ├── Loader.h │ │ ├── Loader.m │ │ ├── Logger.h │ │ ├── Logger.m │ │ ├── NativeBridge.h │ │ ├── NativeBridge.m │ │ ├── ThreshConfig.h │ │ └── ThreshConfig.m ├── js │ ├── README.md │ ├── dist │ │ ├── assets │ │ │ └── test_image.png │ │ └── bundle.js │ ├── package.json │ ├── src │ │ ├── assets │ │ │ ├── icon_dealing.png │ │ │ ├── icon_fail.png │ │ │ ├── icon_success.png │ │ │ └── test_image.png │ │ ├── config.ts │ │ ├── images.d.ts │ │ ├── index.ts │ │ ├── pages │ │ │ ├── apis │ │ │ │ ├── ModalActions.tsx │ │ │ │ ├── PageActions.tsx │ │ │ │ ├── TestModal.tsx │ │ │ │ ├── ThemeProviderActions.tsx │ │ │ │ └── ToastActions.tsx │ │ │ ├── basic │ │ │ │ ├── ButtonDemo.tsx │ │ │ │ ├── CheckboxDemo.tsx │ │ │ │ ├── ContainerDemo.tsx │ │ │ │ ├── DragableScrollViewDemo.tsx │ │ │ │ ├── GridViewDemo.tsx │ │ │ │ ├── IconDemo.tsx │ │ │ │ ├── ImageDemo.tsx │ │ │ │ ├── InputDemo.tsx │ │ │ │ ├── ListViewDemo.tsx │ │ │ │ ├── NativeViewDemo.tsx │ │ │ │ ├── NestScrollViewDemo.tsx │ │ │ │ ├── NoticeBarDemo.tsx │ │ │ │ ├── PageAppBar.tsx │ │ │ │ ├── PickerDemo.tsx │ │ │ │ ├── QrImageDemo.tsx │ │ │ │ ├── RadioDemo.tsx │ │ │ │ ├── RefreshDemo.tsx │ │ │ │ ├── ScrollViewDemo.tsx │ │ │ │ ├── SwipeActionsViewDemo.tsx │ │ │ │ ├── SwiperViewDemo.tsx │ │ │ │ ├── SwitchDemo.tsx │ │ │ │ ├── TabControllerDemo.tsx │ │ │ │ └── TextDemo.tsx │ │ │ ├── examples │ │ │ │ ├── formExamples.tsx │ │ │ │ ├── iconViewer.tsx │ │ │ │ ├── imageViewer.tsx │ │ │ │ ├── longList.tsx │ │ │ │ ├── scrollViewInModal.tsx │ │ │ │ └── timer.tsx │ │ │ ├── homePage.tsx │ │ │ └── preDialog.tsx │ │ └── widgets │ │ │ ├── ActionSheet.tsx │ │ │ ├── Box.tsx │ │ │ ├── Center.tsx │ │ │ ├── Loading.tsx │ │ │ ├── Modal.tsx │ │ │ └── Title.tsx │ ├── tsconfig.json │ ├── webpack │ │ ├── config.js │ │ ├── loader │ │ │ ├── image-loader.js │ │ │ └── try-catch-loader │ │ │ │ ├── index.js │ │ │ │ └── plugin.js │ │ └── webpack.config.js │ └── yarn.lock ├── lib │ ├── assets │ │ ├── icon_back_black.png │ │ ├── icon_back_white.png │ │ └── on_error.png │ ├── main.dart │ ├── page │ │ ├── not_found_page.dart │ │ └── white_screen_page.dart │ └── thresh.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── images ├── image1.png ├── image10.png ├── image11.png ├── image12.png ├── image13.png ├── image14.png ├── image15.png ├── image16.png ├── image17.png ├── image18.png ├── image19.png ├── image2.png ├── image20.png ├── image21.png ├── image22.png ├── image23.png ├── image24.png ├── image3.png ├── image4.png ├── image5.png ├── image6.png ├── image7.png ├── image8.png ├── image9.png ├── logo.png └── qrcode.jpg ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── Interface │ │ ├── ThreshDataLoader.h │ │ ├── ThreshInfoExport.h │ │ ├── ThreshLogger.h │ │ ├── ThreshNativeBridge.h │ │ ├── ThreshNativePlatformView.h │ │ ├── ThreshOptions.h │ │ ├── ThreshProtocol.h │ │ └── ThreshRouterParams.h │ ├── Thresh.h │ ├── ThreshAppDelegate.h │ ├── ThreshAppDelegate.m │ ├── ThreshPlugin.h │ ├── ThreshPlugin.m │ ├── container │ │ ├── ThreshViewController.h │ │ └── ThreshViewController.m │ ├── platformView │ │ ├── ThreshPlatformViewFactory.h │ │ ├── ThreshPlatformViewFactory.m │ │ └── ThreshPlatformViewProtocol.h │ ├── runtime │ │ ├── ThreshEngine.h │ │ ├── ThreshEngine.m │ │ ├── dartModule │ │ │ ├── ThreshFlutterPluginChannel.h │ │ │ ├── ThreshFlutterPluginChannel.m │ │ │ ├── ThreshPlatformUniqueChannelKeyGenerator.h │ │ │ └── ThreshPlatformUniqueChannelKeyGenerator.m │ │ ├── jsCore │ │ │ ├── ThreshJSCoreDef.h │ │ │ ├── ThreshJSExecutor.h │ │ │ ├── ThreshJSExecutor.m │ │ │ ├── ThreshJSLoader.h │ │ │ └── ThreshJSLoader.m │ │ └── jsModule │ │ │ ├── ThreshJSChannelManager.h │ │ │ ├── ThreshJSChannelManager.m │ │ │ ├── ThreshJSCoreChannel.h │ │ │ ├── ThreshJSCoreChannel.m │ │ │ ├── ThreshJSTimerManager.h │ │ │ └── ThreshJSTimerManager.m │ └── util │ │ ├── NSTimer+Thresh.h │ │ ├── NSTimer+Thresh.m │ │ ├── ThreshDef.h │ │ ├── ThreshLogHandler.h │ │ └── ThreshLogHandler.m └── thresh.podspec ├── js-core ├── LICENSE ├── README.md ├── index.ts ├── package-lock.json ├── package.json ├── src │ ├── channel │ │ ├── MethodChannel.ts │ │ └── dispatchMethod.ts │ ├── core │ │ ├── AppContainer.ts │ │ ├── ChildrenRule.ts │ │ ├── PageContainer.ts │ │ ├── ThreshApp.ts │ │ ├── ThreshAppContext.ts │ │ ├── VNode.ts │ │ ├── Widget.ts │ │ ├── basicWidget.ts │ │ ├── createElement.ts │ │ └── scheduleUpdate.ts │ ├── manager │ │ ├── BridgeManager.ts │ │ ├── DevtoolsManager.ts │ │ ├── EventManager.ts │ │ ├── RenderManager.ts │ │ ├── TimerManager.ts │ │ ├── UIManager.ts │ │ └── UtilManager.ts │ ├── shared │ │ ├── Util.ts │ │ └── bus.ts │ └── types │ │ ├── type.d.ts │ │ └── widget.d.ts ├── tsconfig.json └── yarn.lock ├── lib ├── basic │ ├── bus.dart │ ├── device_info.dart │ ├── global_def.dart │ └── util.dart ├── devtools │ ├── dev_buttons.dart │ ├── dev_panel.dart │ ├── dev_tools.dart │ ├── panel_content.dart │ └── panel_content_item.dart ├── framework │ ├── channel │ │ ├── basic.dart │ │ ├── bridge.dart │ │ ├── controller.dart │ │ ├── dev.dart │ │ ├── render.dart │ │ └── util.dart │ ├── core │ │ ├── dynamic_app.dart │ │ ├── dynamic_builder.dart │ │ ├── dynamic_model.dart │ │ ├── dynamic_page.dart │ │ ├── dynamic_proxy.dart │ │ └── dynamic_widget.dart │ ├── main.dart │ └── widget │ │ ├── data │ │ ├── widget_icon.dart │ │ ├── widget_image.dart │ │ ├── widget_notice_bar.dart │ │ ├── widget_picker.dart │ │ ├── widget_qr_image.dart │ │ ├── widget_refresh.dart │ │ ├── widget_spin.dart │ │ ├── widget_text.dart │ │ └── widget_toast.dart │ │ ├── form │ │ ├── widget_button.dart │ │ ├── widget_checkbox.dart │ │ ├── widget_input.dart │ │ ├── widget_radio.dart │ │ └── widget_switch.dart │ │ ├── layout │ │ ├── widget_app_bar.dart │ │ ├── widget_bottom_sheet.dart │ │ ├── widget_container.dart │ │ ├── widget_dragable_scroll_view │ │ │ ├── dragable_scroll_view.dart │ │ │ └── index.dart │ │ ├── widget_drawer_scroll_view.dart │ │ ├── widget_grid_view.dart │ │ ├── widget_list_view.dart │ │ ├── widget_native_view.dart │ │ ├── widget_nest_scroll_view.dart │ │ ├── widget_page.dart │ │ ├── widget_scroll_view.dart │ │ ├── widget_stack_view.dart │ │ ├── widget_swipe_actions_view.dart │ │ ├── widget_swiper_view.dart │ │ └── widget_tabbar_controller_view.dart │ │ ├── main.dart │ │ └── widget_basic.dart └── thresh.dart ├── pubspec.lock └── pubspec.yaml /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 1.0.24 2 | 1. flutterSdk升级到v2.2.2 3 | 2. 引入EngineGroup优化内存表现,提高加载速度 4 | 3. 优化部分低端机型黑屏及其他bug修复 5 | 4. 新增jsModule释放策略控制(可单个指定页面是否释放,延迟释放) 6 | 5. 新增远程调试模式,日志输出 7 | 8 | ### 0.0.6 9 | 1. 支持了JSContext单例化 10 | 2. 主框架代码优化,以及部分bug fix 11 | 3. 新增Switch/DragableScrollView/Picker基础组件 12 | 4. 支持Native定时器,提高通信效率 13 | 5. 新增对应 Flutter 1.22.5 版本 14 | 15 | ## 0.0.4 16 | 初始版本发布,详细说明见 [README](README.md) 17 | 18 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # 参与者公约 2 | 3 | ## 我们的保证 4 | 5 | 为了促进一个开放透明且友好的环境,我们作为贡献者和维护者保证:无论年龄、种族、民族、性别认同和表达(方式)、体型、身体健全与否、经验水平、国籍、个人表现、宗教或性别取向,参与者在我们项目和社区中都免于骚扰。 6 | 7 | ## 我们的标准 8 | 9 | 有助于创造正面环境的行为包括但不限于: 10 | 11 | * 使用友好和包容性语言 12 | * 尊重不同的观点和经历 13 | * 耐心地接受建设性批评 14 | * 关注对社区最有利的事情 15 | * 友善对待其他社区成员 16 | 17 | 身为参与者不能接受的行为包括但不限于: 18 | 19 | * 使用与性有关的言语或是图像,以及不受欢迎的性骚扰 20 | * 捣乱/煽动/造谣的行为或进行侮辱/贬损的评论,人身攻击及政治攻击 21 | * 公开或私下的骚扰 22 | * 未经许可地发布他人的个人资料,例如住址或是电子地址 23 | * 其他可以被合理地认定为不恰当或者违反职业操守的行为 24 | 25 | ## 我们的责任 26 | 27 | 项目维护者有责任为「可接受的行为」标准做出诠释,以及对已发生的不被接受的行为采取恰当且公平的纠正措施。 28 | 29 | 项目维护者有权利及责任去删除、编辑、拒绝与本行为标准有所违背的评论 (comments)、提交 (commits)、代码、wiki 编辑、问题 (issues) 和其他贡献,以及项目维护者可暂时或永久性的禁止任何他们认为有不适当、威胁、冒犯、有害行为的贡献者。 30 | 31 | ## 使用范围 32 | 33 | 当一个人代表该项目或是其社区时,本行为标准适用于其项目平台和公共平台。 34 | 35 | 代表项目或是社区的情况,举例来说包括使用官方项目的电子邮件地址、通过官方的社区媒体账号发布或线上或线下事件中担任指定代表。 36 | 37 | 该项目的呈现方式可由其项目维护者进行进一步的定义及解释。 38 | 39 | ## 强制执行 40 | 41 | 可以通过 weishun.xu@amh-group.com,来联系项目团队来举报滥用、骚扰或其他不被接受的行为。 42 | 43 | 任何维护团队认为有必要且适合的所有投诉都将进行审查及调查,并做出相对应的回应。项目小组有对事件回报者有保密的义务。具体执行的方针近一步细节可能会单独公布。 44 | 45 | 没有切实地遵守或是执行本行为标准的项目维护人员,可能会因项目领导人或是其他成员的决定,暂时或是永久地取消其参与资格。 46 | 47 | ## 来源 48 | 49 | 本行为标准改编自[贡献者公约][主页],版本 1.4 50 | 可在此观看 https://www.contributor-covenant.org/zh-cn/version/1/4/code-of-conduct.html -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 贡献指南 2 | 3 | 感谢关注和使用 Thresh,为了让解决问题、贡献代码的效率更高,请按照下面流程 4 | 5 | ## 关于 Issues 6 | 7 | ### 问题反馈 8 | 9 | * 查看 [Issue 列表](https://github.com/ymm-tech/thresh/issues)或者相关评论,确认 Bug 是否已经有人提交过,如果有,请直接回复之前的反馈者; 10 | * 确认 Bug 是否已经被修复 11 | * 隔离使用场景,确认 Bug 是否由于使用方法不当导致 12 | * 详细描述 Bug 出现的场景,包括: 13 | * 复现步骤 14 | * 期望结果 15 | * 实际结果 16 | * 复现问题的设备机型、系统版本、Thresh版本 17 | * 日志,截图以及其它有助于定位问题的相关信息 18 | 19 | ### 功能需求 20 | 21 | * 说明使用场景 22 | * 详细描述需求 23 | -------------------------------------------------------------------------------- /Documentation/Apis/Native.md: -------------------------------------------------------------------------------- 1 | # Native Apis 2 | 3 | ## Channels 4 | 5 | 待补充... -------------------------------------------------------------------------------- /Documentation/基础组件/Button.md: -------------------------------------------------------------------------------- 1 | # Button 2 | 3 | ### 概述[按钮] 4 | 5 | ` 26 | } 27 | } 28 | } 29 | ``` 30 | 31 | 32 | 33 | ### 组件属性 34 | 35 | 无 -------------------------------------------------------------------------------- /Documentation/基础组件/Checkbox.md: -------------------------------------------------------------------------------- 1 | # Checkbox 2 | 3 | ### 概述[多选框] 4 | 5 | `` 是一个多选框组件。 6 | 7 | > **注意:** 8 | > 9 | > `` 是一个单一子节点组件! 10 | > 11 | > 务必为 `` 赋值高度,否则将不可见。 12 | 13 | 14 | 15 | ### 示例代码 16 | 17 | ```javascript 18 | import Thresh, { basicWidgets } from 'thresh-js' 19 | 20 | const { Container, Checkbox, Text } = basicWidgets 21 | 22 | export default class CheckboxGroup extends Thresh.Widget { 23 | state = { 24 | checkboxGroup: [ 25 | { label: 'Apple', selected: true }, 26 | { label: 'Banana', selected: false }, 27 | { label: 'Orange', selected: false }, 28 | ] 29 | } 30 | 31 | render () { 32 | return { 33 | 34 | { 35 | this.state.checkboxGroup.map(({ label, selected }, index) => ( 36 | { 39 | const { checkboxGroup } = this.state 40 | checkboxGroup[index].selected = value 41 | this.setState({ checkboxGroup }) 42 | }} 43 | > 44 | {label} 45 | 46 | )) 47 | } 48 | 49 | } 50 | } 51 | } 52 | ``` 53 | 54 | 55 | 56 | ### 组件属性 57 | 58 | | 属性名 | 类型 | 说明 | 59 | | ----------- | ---------- | ------------------------------------------------------------ | 60 | | value | `boolean` | 当前是否被选中 | 61 | | activeColor | `number` | 选中后高亮的颜色值 | 62 | | onChange | `Function` | 选中的值发生变化时的回调事件,具有 1 个参数

参数具有 `value` 属性,`boolean` 类型,表示当前是否选中 | -------------------------------------------------------------------------------- /Documentation/基础组件/Icon.md: -------------------------------------------------------------------------------- 1 | # Icon 2 | 3 | ### 概述[图标] 4 | 5 | `` 是图标组件,其提供了部分 Flutter 中支持的图标。 6 | 7 | 8 | 9 | ### 示例代码 10 | 11 | ```javascript 12 | import Thresh, { basicWidgets } from 'thresh-js' 13 | 14 | const { Container, Icon } = basicWidgets 15 | 16 | export default class Loading extends Thresh.Widget { 17 | render () { 18 | return { 19 | 20 | 21 | 22 | } 23 | } 24 | } 25 | ``` 26 | 27 | 28 | 29 | ### 组件属性 30 | 31 | | 属性名 | 类型 | 说明 | 32 | | ------ | ---------- | -------- | 33 | | type | `string` | 图标类型 | 34 | | color | `number` | 图标大小 | 35 | | size | `Function` | 图标颜色 | -------------------------------------------------------------------------------- /Documentation/基础组件/Image.md: -------------------------------------------------------------------------------- 1 | # Image 2 | 3 | ### 概述[图片] 4 | 5 | `` 是一个用来显示图片的组件。 6 | 7 | 8 | 9 | ### 示例代码 10 | 11 | ```javascript 12 | import Thresh, { basicWidgets } from 'thresh-js' 13 | 14 | const { Image } = basicWidgets 15 | 16 | export default class ImageItem extends Thresh.Widget { 17 | render () { 18 | return { 19 | 20 | } 21 | } 22 | } 23 | ``` 24 | 25 | 26 | 27 | ### 组件属性 28 | 29 | | 属性名 | 类型 | 说明 | 默认值 | 30 | | ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------- | 31 | | src | `string` | 图片路径 | | 32 | | placeholder | `string` | 占位图片路径 | | 33 | | fit | `string`

- 'fill'
- 'contain'
- 'cover'
- 'fitWidth'
- 'fitHeight'
- 'scaleDown'
- 'none' | 图片显示效果 | | 34 | | fadeIn | `boolean` | 是否开启隐藏占位图时的动画效果 | `false` | 35 | | onLoad | `Function` | 滑动时触发的滑动回调事件,具有 1 个参数

参数具有 `width` `height` 属性,表示当前图片资源的实际宽高
如果需要取得图片显示宽高,需要通过 `onLayout` 进行获取 | | -------------------------------------------------------------------------------- /Documentation/基础组件/NativeView.md: -------------------------------------------------------------------------------- 1 | # NativeView 2 | 3 | ### 概述[原生视图] 4 | 5 | `` 组件会显示一个已经被 Native 注册在 Flutter 中的原生组件。 6 | 7 | > **注意:** 8 | > 9 | > 使用该组件需要 Native 端同步配合,对于未被注册的原生组件,使用 `` 将无效。 10 | 11 | 12 | 13 | ### 示例代码 14 | 15 | ```javascript 16 | import Thresh, { basicWidgets } from 'thresh-js' 17 | 18 | const { NativeView } = basicWidgets 19 | 20 | export default class MapView extends Thresh.Widget { 21 | render () { 22 | return { 23 | 24 | } 25 | } 26 | } 27 | ``` 28 | 29 | 30 | 31 | ### 组件属性 32 | 33 | | 属性名 | 类型 | 说明 | 34 | | ------ | ---------- | ---------------------------- | 35 | | type | `string` | 对应 Native 中注册的组件名 | 36 | | params | `any` | 被传递到 Native 组件中的参数 | 37 | | onLoad | `Function` | NativeView 加载完成回调事件 | 38 | 39 | 40 | 41 | ### 组件方法 42 | 43 | ```javascript 44 | /** 45 | * 通过此方法可以刷新当前 Native View 46 | * @param {any} params 刷新时传递的参数 47 | */ 48 | refresh(params?: any) 49 | 50 | /** 51 | * 通过此方法可以销毁当前 Native View 52 | * @param {any} params 刷新时传递的参数 53 | */ 54 | destroy(params?: any) 55 | 56 | /** 57 | * 通过此方法可以向 Native View 发送任意自定义事件 58 | * @param {string} methodName 事件名称 59 | * @param {any} methodParams 事件参数 60 | */ 61 | invokeCustomMethod(methodName: string, methodParams?: any) 62 | ``` 63 | 64 | -------------------------------------------------------------------------------- /Documentation/基础组件/Page.md: -------------------------------------------------------------------------------- 1 | # Page 2 | 3 | ### 概述[页面容器] 4 | 5 | `` 组件是用来承载页面的最外层组件。当需要显示一个完整页面时,务必在最外层使用该组件。 6 | 7 | ### 示例代码 8 | 9 | ```javascript 10 | import Thresh, { basicWidgets } from 'thresh-js' 11 | 12 | const { Page, Container, Text } = basicWidgets 13 | 14 | export default class Homepage extends Thresh.Widget { 15 | render () { 16 | return { 17 | 18 | 19 | 页面容器1 20 | 21 | 22 | 页面容器2 23 | 24 | 25 | 页面容器3 26 | 27 | 28 | } 29 | } 30 | } 31 | ``` 32 | 33 | 34 | 35 | ### 组件属性 36 | 37 | | 属性名 | 类型 | 说明 | 38 | | --------------- | ---------- | ------------------------------------------------------------ | 39 | | appBar | `Widget` | 导航栏 | 40 | | backgroundColor | `number` | 背景色 | 41 | | onShow | `Function` | 页面即将显示时的回调事件 | 42 | | onHide | `Function` | 页面即将隐藏时的回调事件 | 43 | | beforePop | `Function` | 当前页面 pop 之前的回调
如果返回 false 或者 Promise 将停止 pop | 44 | 45 | -------------------------------------------------------------------------------- /Documentation/基础组件/Radio.md: -------------------------------------------------------------------------------- 1 | # Radio 2 | 3 | ### 概述[单选框] 4 | 5 | `` 是一个单选框组件。 6 | 7 | > **注意:** 8 | > 9 | > `` 是一个单一子节点组件! 10 | > 11 | > 当存在多个 `` 时,其分组依据 `groupValue` 属性的值。 12 | > 13 | > 务必为 `` 赋值高度,否则将不可见。 14 | 15 | 16 | 17 | ### 示例代码 18 | 19 | ```javascript 20 | import Thresh, { basicWidgets } from 'thresh-js' 21 | 22 | const { Container, Radio, Text } = basicWidgets 23 | 24 | export default class RadioGroup extends Thresh.Widget { 25 | state = { 26 | selected: '' 27 | } 28 | radioGroup = [ 29 | { label: 'Apple', value: 'apple' }, 30 | { label: 'Banana', value: 'banana' }, 31 | { label: 'Orange', value: 'orange' }, 32 | ] 33 | 34 | render () { 35 | return { 36 | 37 | { 38 | this.radioGroup.map(({ label, value }) => ( 39 | { 43 | this.setState({ 44 | selected: value 45 | }) 46 | }} 47 | > 48 | {label} 49 | 50 | )) 51 | } 52 | 53 | } 54 | } 55 | } 56 | ``` 57 | 58 | 59 | 60 | ### 组件属性 61 | 62 | | 属性名 | 类型 | 说明 | 63 | | ----------- | ---------- | ------------------------------------------------------------ | 64 | | value | `string` | 当前 `Radio` 的值 | 65 | | groupValue | `string` | 当前 `Radio` 组选中的值

通过 `groupValue` 区分不同的 `Radio` 组 | 66 | | activeColor | `number` | 选中后高亮的颜色值 | 67 | | onChange | `Function` | 选中的值发生变化时的回调事件,具有 1 个参数

参数具有 `value` 属性,`string` 类型,表示当前选中的值 | -------------------------------------------------------------------------------- /Documentation/基础组件/Refresh.md: -------------------------------------------------------------------------------- 1 | # Refresh 2 | 3 | ### 概述[刷新指示器] 4 | `` 是一个刷新指示器组件。 5 | 6 | 7 | 8 | ### 示例代码 9 | 10 | ```javascript 11 | import Thresh, { basicWidgets } from 'thresh-js' 12 | 13 | const { Refresh } = basicWidgets 14 | 15 | export default class RefreshView extends Thresh.Widget { 16 | render () { 17 | return { 18 | 19 | } 20 | } 21 | } 22 | ``` 23 | 24 | 25 | 26 | ### 组件属性 27 | 28 | | 属性名 | 类型 | 说明 | 默认值 | 29 | | ----------- | -------- | -------------- | ------------ | 30 | | color | `number` | 指示器主色 | `0xff0000ff` | 31 | | secondColor | `number` | 指示器辅色 | | 32 | | size | `number` | 指示器尺寸 | | 33 | | strokeWidth | `number` | 指示器绘制粗细 | | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Documentation/基础组件/ScrollView.md: -------------------------------------------------------------------------------- 1 | # ScrollView 2 | 3 | ### 概述[滚动视图] 4 | 5 | `` 是一个内部可以滚动的组件。 6 | 7 | > **注意:** 8 | > 9 | > ``不能使用 `flex` 属性,且在未设置宽高的情况下,默认会取其直接父组件的宽高。 10 | 11 | 12 | 13 | ### 示例代码 14 | 15 | ```javascript 16 | import Thresh, { basicWidgets } from 'thresh-js' 17 | 18 | const { Page, ScrollView, Container, Text } = basicWidgets 19 | 20 | export default class ScrollableView extends Thresh.Widget { 21 | render () { 22 | return { 23 | 24 | 25 | 滚动视图子组件1 26 | 27 | 28 | 滚动视图子组件2 29 | 30 | 31 | 滚动视图子组件3 32 | 33 | 34 | 滚动视图子组件4 35 | 36 | 37 | 滚动视图子组件5 38 | 39 | 40 | 滚动视图子组件6 41 | 42 | 43 | } 44 | } 45 | } 46 | ``` 47 | 48 | 49 | 50 | ### 组件属性 51 | 52 | | 属性名 | 类型 | 说明 | 默认值 | 53 | | --------- | ---------------------------------------------------- | ------------------------------------------------------------ | ------------ | 54 | | direction | `string`

- 'vertical'
- 'horizontal' | 滑动方向,默认垂直 | `'vertical'` | 55 | | onScroll | `Function` | 滑动时触发的滑动回调事件,具有 1 个参数

参数具有 `offset` 属性,表示当前滑动位移值 | | 56 | 57 | 58 | 59 | ### 组件方法 60 | 61 | ```javascript 62 | /** 63 | * 使 ScrollView 滚动到指定位置 64 | * @param {number} offset 相对应原始位置的偏移量 65 | * @param {number} duration 滚动到指定位置的耗时 66 | */ 67 | scrollTo(offset: number, duration?: number) 68 | ``` -------------------------------------------------------------------------------- /Documentation/基础组件/SwipeActionsView.md: -------------------------------------------------------------------------------- 1 | # SwipeActionsView 2 | 3 | ### 概述[侧滑按钮视图] 4 | 5 | `` 是一个可以向左侧滑动,显示右侧按钮的组件。 6 | 7 | > `` 不能够通过嵌套方式传递子组件,而应通过 `content` 属性进行传递。 8 | 9 | ### 示例代码 10 | 11 | ```javascript 12 | import Thresh, { basicWidgets, Util, ui } from 'thresh-js' 13 | 14 | const { SwipeActionsView, Container, Text } = basicWidgets 15 | 16 | export default class ListDemo extends Thresh.Widget { 17 | render () { 18 | return { 19 | 23 | 点击关闭 24 | 25 | ]} 26 | content={ 27 | 28 | 向左侧横向滑动显示按钮 29 | 30 | } 31 | onActionsOpen={() => { 32 | Util.log('SwipeActionView is opening.') 33 | }} 34 | onActionsClose={() => { 35 | Util.log('SwipeActionView is closing.') 36 | }} 37 | /> 38 | } 39 | } 40 | } 41 | ``` 42 | 43 | 44 | 45 | ### 组件属性 46 | 47 | | 属性名 | 类型 | 说明 | 默认值 | 48 | | ---------------- | ---------- | ------------------------------------------------------------ | ------ | 49 | | swipeMaxDistance | `number` | 向左侧滑动的最大距离,如不设置将会禁止滑动 | | 50 | | actions | `Widget[]` | 滑动后显示的按钮,按钮高度将会默认撑满容器高度,如不设置将会禁止滑动 | | 51 | | content | `Widget` | 组件可滑动部分的内容,必传 | | 52 | | onActionsOpen | `Function` | 滑动打开完成后的回调 | | 53 | | onActionsClose | `Function` | 滑动关闭完成后的回调 | | 54 | 55 | 56 | 57 | ### 组件方法 58 | 59 | ```javascript 60 | /** 61 | * 如果 SwipeActionsView 正在关闭状态,调用会打开 62 | */ 63 | openActions() 64 | 65 | /** 66 | * 如果 SwipeActionsView 正在打开状态,调用会关闭 67 | */ 68 | closeActions() 69 | ``` 70 | 71 | -------------------------------------------------------------------------------- /Documentation/基础组件/SwiperView.md: -------------------------------------------------------------------------------- 1 | # SwiperView 2 | 3 | ### 概述[滚动视图] 4 | 5 | `` 是一个识别手势滑动并切换显示页面的组件。 6 | 7 | > **注意:** 8 | > 9 | > `` 的直接子组件不论有没有设置宽高,都会被赋值为``的宽高。 10 | 11 | 12 | 13 | ### 示例代码 14 | 15 | ```javascript 16 | import Thresh, { basicWidgets } from 'thresh-js' 17 | 18 | const { SwiperView, Container, Image } = basicWidgets 19 | 20 | export default class ImageViewer extends Thresh.Widget { 21 | render () { 22 | return { 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | } 35 | } 36 | } 37 | ``` 38 | 39 | 40 | 41 | ### 组件属性 42 | 43 | | 属性名 | 类型 | 说明 | 默认值 | 44 | | --------- | ---------- | ------------------------------------------------------------ | ------ | 45 | | row | `boolean` | 是否水平方向滑动,默认水平方向滑动 | `true` | 46 | | initIndex | `number` | 初始显示的内容 index | `0` | 47 | | onChange | `Function` | 发生切换时的回调事件,具有 1 个参数

参数具有 `index` 属性,表示切换后显示内容的 index | | 48 | 49 | 50 | 51 | ### 组件方法 52 | 53 | ```javascript 54 | /** 55 | * 使 SwiperView 滚动到指定内容 56 | * @param {number} index 需要显示的内容 index 57 | * @param {number} duration 移动到指定内容的耗时 58 | */ 59 | swipeTo(index: number, duration?: number) 60 | ``` 61 | 62 | -------------------------------------------------------------------------------- /Documentation/打包说明.md: -------------------------------------------------------------------------------- 1 | # 打包说明 2 | 3 | ### JS 脚本打包 4 | 5 | JS 打包依赖 webpack,在项目根目录下的 /webpack 目录即为打包目录。目前打包目录下分为 3 部分,分别是: 6 | 7 | 1. weback 打包脚本; 8 | 2. 打包配置项; 9 | 3. webpack loaders. 10 | 11 | 通过执行 `yarn build` 命令可以对业务代码进行打包,打包后的文件会存在于项目根目录下的 /dist 目录中。 12 | 13 | 14 | 15 | #### Webpack loaders 16 | 17 | Loaders 分为两块: 18 | 19 | 1. 为 js 业务代码中的所有函数添加异常捕获; 20 | 2. 将图片转换为对应环境下的 url 链接以保证图片的正确显示。 21 | 22 | 一般情况下请勿改动 loader 目录下的任何内容! 23 | 24 | 25 | 26 | #### 打包配置项 27 | 28 | 打包配置项在 /webpack/config.js 中,目前一共包含 3 个可配置项: 29 | 30 | 1. host: 项目启动 ip,默认 0.0.0.0,一般情况下不需要修改; 31 | 2. port: 项目启用端口,默认 12345,一般情况下不需要修改; 32 | 3. imageProxyHost: 该参数默认情况下被注释或与 host 值相同,当使用安卓设备进行调试时,需要开启代理,此时会导致项目中的静态资源图片因为默认端口被代理无法正常显示图片。通过添加或修改该值为代理 ip 后可以保证图片正常显示。 33 | 34 | 35 | 36 | #### Webpack 打包脚本 37 | 38 | 打包脚本中的各项参数请参考 webpack 官方文档。在绝大多数情况下可以不对打包脚本进行任何修改,除非存在其他特殊的打包需求。 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 AMH Group 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 AMH Group 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | # 未来RoadMap 2 | 3 | - **性能优化** 4 | 5 | 1、首帧加载时长 6 | 7 | 8 | 9 | - **稳定性** 10 | 11 | 1、Flutter 已有线上异常问题逐步推进解决,主要集中在低端机型so异常 12 | 13 | 2、端可用性指标提升 14 | 15 | - **完善组件以及开发文档** 16 | 17 | - **开发工具链以及Debug模式建设** 18 | 19 | - **5+ 业务线接入支持【目前接入页面70+】** 20 | 21 | - **技术扩展** 22 | 23 | 1、Android端支持 JS引擎切换,降低安装包大小【v8 or jsc】 24 | 25 | 2、支持Flutter新版本切换,目前支持 v1.5.4-Hotfix2 \ v1.9.1-Hotfix6\v1.22.5 \ v2.2.2 26 | 27 | 3、支持动画 28 | 29 | 4、混合模式工程化链路优化 -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.class 3 | .gradle 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | GeneratedPluginRegistrant.java -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'io.manbang.frontend.thresh' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext{ 6 | kotlin_version = '1.3.72' 7 | } 8 | repositories { 9 | maven {url 'https://maven.aliyun.com/repository/google'} 10 | maven {url 'http://maven.aliyun.com/mvn/repository/'} 11 | maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'} 12 | google() 13 | jcenter() 14 | maven {url "https://jitpack.io"} 15 | } 16 | 17 | dependencies { 18 | classpath 'com.android.tools.build:gradle:3.2.1' 19 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 20 | } 21 | } 22 | 23 | rootProject.allprojects { 24 | repositories { 25 | maven {url 'https://maven.aliyun.com/repository/google'} 26 | maven {url 'http://maven.aliyun.com/mvn/repository/'} 27 | maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'} 28 | google() 29 | jcenter() 30 | maven {url "https://jitpack.io"} 31 | } 32 | 33 | configurations.all { 34 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds' 35 | } 36 | } 37 | 38 | apply plugin: 'com.android.library' 39 | apply plugin: 'kotlin-android-extensions' 40 | apply plugin: 'kotlin-android' 41 | 42 | android { 43 | compileSdkVersion 28 44 | buildToolsVersion '28.0.3' 45 | defaultConfig { 46 | minSdkVersion 16 47 | targetSdkVersion 28 48 | } 49 | lintOptions { 50 | disable 'InvalidPackage' 51 | } 52 | } 53 | 54 | dependencies { 55 | implementation 'androidx.appcompat:appcompat:1.0.0' 56 | implementation 'androidx.annotation:annotation:1.0.0' 57 | implementation 'androidx.lifecycle:lifecycle-common-java8:2.0.0' 58 | implementation'com.squareup.retrofit2:retrofit:2.3.0' 59 | implementation 'com.eclipsesource.j2v8:j2v8:6.2.0@aar' 60 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 61 | implementation 'com.google.code.gson:gson:2.6.2' 62 | // api "com.ymm.lib:flutter-sdk:1.22.5-SNAPSHOT" 63 | } 64 | 65 | ext { 66 | groupId = 'io.manbang.frontend.thresh' 67 | artifactId = "Thresh" 68 | } 69 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | 5 | v_lib_jscore=1.1.6-SNAPSHOT 6 | 7 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'thresh' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/ThreshPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | *

4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | *

12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | *

15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | package io.manbang.frontend.thresh; 24 | 25 | import io.flutter.plugin.common.MethodCall; 26 | import io.flutter.plugin.common.MethodChannel; 27 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; 28 | import io.flutter.plugin.common.MethodChannel.Result; 29 | import io.flutter.plugin.common.PluginRegistry.Registrar; 30 | 31 | /** ThreshPlugin */ 32 | public class ThreshPlugin implements MethodCallHandler { 33 | /** Plugin registration. */ 34 | public static void registerWith(Registrar registrar) { 35 | final MethodChannel channel = new MethodChannel(registrar.messenger(), "thresh_demo"); 36 | channel.setMethodCallHandler(new ThreshPlugin()); 37 | } 38 | 39 | @Override 40 | public void onMethodCall(MethodCall call, Result result) { 41 | if (call.method.equals("getPlatformVersion")) { 42 | result.success("Android " + android.os.Build.VERSION.RELEASE); 43 | } else { 44 | result.notImplemented(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/channel/BridgeCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.channel; 25 | 26 | import java.util.Map; 27 | 28 | public interface BridgeCallback { 29 | /** 30 | * 31 | * @param code 0 32 | * 0 : success 33 | * @param reason callback message 34 | * @param bridgeResult result 35 | */ 36 | void onResult(int code, String reason, Map bridgeResult); 37 | } 38 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/channel/MethodChannelProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.channel; 25 | 26 | import java.util.Map; 27 | 28 | import io.flutter.plugin.common.MethodChannel; 29 | 30 | /** An interface for classes that initialize MethodChannel using {@link io.manbang.frontend.thresh.channel.MethodChannelModule} */ 31 | public interface MethodChannelProvider { 32 | 33 | /** 34 | * invoke flutter method 35 | * 36 | * @param method dart method 37 | * @param params params 38 | */ 39 | void invokeMethod(String method,Map params); 40 | 41 | /** 42 | * dispatch MethodChannel event 43 | * 44 | * @param module 45 | * @param method 46 | * @param params 47 | * @param result 48 | */ 49 | Object dispatchModuleChannelEvent(String module, String method, Object params, MethodChannel.Result result); 50 | } 51 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/channel/nativemodule/SendResultInvoke.java: -------------------------------------------------------------------------------- 1 | package io.manbang.frontend.thresh.channel.nativemodule; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | 6 | import com.google.gson.Gson; 7 | 8 | import org.json.JSONObject; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | import io.flutter.plugin.common.JSONUtil; 14 | import io.manbang.frontend.thresh.runtime.ThreshEngine; 15 | 16 | public class SendResultInvoke implements NativeModule.INativeInvoke { 17 | 18 | private Activity activity; 19 | 20 | SendResultInvoke(Activity activity) { 21 | 22 | this.activity = activity; 23 | } 24 | 25 | @Override 26 | public void invoke(ThreshEngine engine, Map params) { 27 | Intent intent = new Intent(); 28 | final String PARAM_KEY = "params"; 29 | if(params!=null&¶ms.size()>0&¶ms.containsKey(PARAM_KEY)){ 30 | Object resultParam = params.get(PARAM_KEY); 31 | if(resultParam instanceof String){ 32 | intent.putExtra(PARAM_KEY,(String) resultParam); 33 | }else if(resultParam instanceof Map){ 34 | intent.putExtra(PARAM_KEY,new JSONObject((Map) resultParam).toString()); 35 | } 36 | } 37 | activity.setResult(Activity.RESULT_OK, intent); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/config/configparse/AssetConfigParse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.manager.config.configparse 25 | 26 | import io.manbang.frontend.thresh.manager.config.IParseConfig 27 | import io.manbang.frontend.thresh.manager.config.ThreshConfig 28 | 29 | /** 30 | * 通过将asset文件,转化为配置项 31 | */ 32 | class AssetConfigParse(val assetName: String) :IParseConfig { 33 | 34 | override fun parse(): ThreshConfig { 35 | TODO("Not yet implemented") 36 | } 37 | } -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/config/configparse/CommonConfigParse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.manager.config.configparse 25 | 26 | import io.manbang.frontend.thresh.manager.config.IParseConfig 27 | import io.manbang.frontend.thresh.manager.config.ThreshConfig 28 | 29 | 30 | /** 31 | * 通用配置解析器 32 | * 仅仅直接将配置返回 33 | */ 34 | class CommonConfigParse(val config: ThreshConfig) : IParseConfig { 35 | 36 | override fun parse(): ThreshConfig { 37 | return config 38 | } 39 | } -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/config/configparse/FileAssetConfigParse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.manager.config.configparse 25 | 26 | import io.manbang.frontend.thresh.manager.config.IParseConfig 27 | import io.manbang.frontend.thresh.manager.config.ThreshConfig 28 | import java.io.File 29 | 30 | /** 31 | * 通过将文件转化为配置项目 32 | */ 33 | class FileAssetConfigParse(val file: File) : IParseConfig { 34 | override fun parse(): ThreshConfig { 35 | TODO("Not yet implemented") 36 | } 37 | } -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/IFlutterEngineExecute.java: -------------------------------------------------------------------------------- 1 | package io.manbang.frontend.thresh.manager.flutterengine; 2 | 3 | public interface IFlutterEngineExecute { 4 | 5 | interface IFlutterContainer { 6 | void putEngineId(String key, String engineId); 7 | 8 | String getInitialRoute(); 9 | 10 | String engineIdKey(); 11 | 12 | String dartEntryPointFunctionName(); 13 | 14 | } 15 | 16 | void initFlutterEngine(IFlutterContainer flutterContainer) ; 17 | 18 | void loadFlutterPage(); 19 | } 20 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/ThreshActivityFlutterContainer.java: -------------------------------------------------------------------------------- 1 | package io.manbang.frontend.thresh.manager.flutterengine; 2 | 3 | import io.manbang.frontend.thresh.containers.ThreshActivity; 4 | import io.manbang.frontend.thresh.manager.ContextIdManager; 5 | 6 | public class ThreshActivityFlutterContainer implements FlutterEngineExecute.IFlutterContainer { 7 | 8 | private ThreshActivity activity; 9 | private String dartEntryPointFunctionName; 10 | 11 | public ThreshActivityFlutterContainer(ThreshActivity activity){ 12 | 13 | this(activity,"main"); 14 | } 15 | 16 | public ThreshActivityFlutterContainer(ThreshActivity activity,String dartEntryPointFunctionName){ 17 | 18 | this.activity = activity; 19 | this.dartEntryPointFunctionName = dartEntryPointFunctionName; 20 | } 21 | 22 | @Override 23 | public void putEngineId(String key, String engineId) { 24 | activity.getIntent().putExtra(key,engineId); 25 | } 26 | 27 | @Override 28 | public String getInitialRoute() { 29 | return activity.getInitialRoute(); 30 | } 31 | 32 | @Override 33 | public String engineIdKey() { 34 | 35 | return ContextIdManager.INSTANCE.getContextId(activity); 36 | } 37 | 38 | @Override 39 | public String dartEntryPointFunctionName() { 40 | return dartEntryPointFunctionName; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/ThreshFragmentContainer.java: -------------------------------------------------------------------------------- 1 | package io.manbang.frontend.thresh.manager.flutterengine; 2 | 3 | import io.manbang.frontend.thresh.containers.ThreshFragment; 4 | import io.manbang.frontend.thresh.manager.ContextIdManager; 5 | 6 | public class ThreshFragmentContainer implements FlutterEngineExecute.IFlutterContainer { 7 | 8 | private ThreshFragment fragment; 9 | private String dartEntryPointFunctionName ; 10 | 11 | public ThreshFragmentContainer(ThreshFragment fragment) { 12 | 13 | this(fragment,"main"); 14 | } 15 | 16 | public ThreshFragmentContainer(ThreshFragment fragment,String dartEntryPointFunctionName) { 17 | this.fragment = fragment; 18 | this.dartEntryPointFunctionName = dartEntryPointFunctionName; 19 | } 20 | 21 | @Override 22 | public void putEngineId(String key, String engineId) { 23 | if (fragment.getArguments() != null) { 24 | fragment.getArguments().putString(key, engineId); 25 | } 26 | } 27 | 28 | @Override 29 | public String getInitialRoute() { 30 | return fragment.getInitialRoute(); 31 | } 32 | 33 | @Override 34 | public String engineIdKey() { 35 | return ContextIdManager.INSTANCE.getContextId(fragment); 36 | } 37 | 38 | @Override 39 | public String dartEntryPointFunctionName() { 40 | return dartEntryPointFunctionName; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/flutterengine/ThreshIntentContainer.java: -------------------------------------------------------------------------------- 1 | package io.manbang.frontend.thresh.manager.flutterengine; 2 | 3 | import android.content.Intent; 4 | 5 | public class ThreshIntentContainer implements FlutterEngineExecute.IFlutterContainer { 6 | 7 | private final Intent intent; 8 | private final String route; 9 | private String engineId; 10 | private String dartEntryPointFunctionName; 11 | 12 | public ThreshIntentContainer(Intent intent, String route,String engineId,String dartEntryPointFunctionName){ 13 | 14 | this.intent = intent; 15 | this.route = route; 16 | this.engineId = engineId; 17 | this.dartEntryPointFunctionName = dartEntryPointFunctionName; 18 | } 19 | 20 | public ThreshIntentContainer(Intent intent, String route,String engineId){ 21 | 22 | this(intent,route,engineId,"main"); 23 | } 24 | 25 | @Override 26 | public void putEngineId(String key, String engineId) { 27 | intent.putExtra(key,engineId); 28 | } 29 | 30 | @Override 31 | public String getInitialRoute() { 32 | return route; 33 | } 34 | 35 | @Override 36 | public String engineIdKey() { 37 | return engineId; 38 | } 39 | 40 | @Override 41 | public String dartEntryPointFunctionName() { 42 | return dartEntryPointFunctionName; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/handler/ThreshHandlerManager.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.manager.handler 25 | 26 | import io.manbang.frontend.thresh.manager.handler.interfaces.IReportHandler 27 | import java.lang.reflect.Proxy 28 | 29 | object ThreshHandlerManager { 30 | 31 | private var reportHandler: IReportHandler? = null 32 | 33 | fun setReportHandler(reportHandler: IReportHandler){ 34 | this.reportHandler = reportHandler 35 | } 36 | 37 | /** 38 | * 上报数据功能 39 | */ 40 | fun reportHandler(): IReportHandler { 41 | return returnProxyIfEmpty(reportHandler, IReportHandler::class.java) 42 | } 43 | 44 | //如果空返回代理对象,否则原对象返回 45 | private fun returnProxyIfEmpty(handler: T?, clazz: Class): T { 46 | return handler ?: emptyProxy(clazz) 47 | } 48 | 49 | private fun emptyProxy(clazz: Class): T { 50 | 51 | return Proxy.newProxyInstance(clazz.classLoader, arrayOf(clazz)) { _, _, _ -> null } as T 52 | 53 | } 54 | } -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/manager/handler/interfaces/IReportHandler.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.manager.handler.interfaces 25 | 26 | /** 27 | * 上报数据的能力 28 | */ 29 | interface IReportHandler { 30 | fun log(level: Int, tag: String?, message: String?, tr: Throwable?) 31 | 32 | /** 33 | * Report performance management data 34 | * 35 | * @param params 36 | */ 37 | fun reportPerformance(params: Map<*, *>?) 38 | 39 | /** 40 | * Report exception log 41 | * 42 | * @param errorMessage 43 | * @param errorDetails 44 | */ 45 | fun reportException(errorMessage: String?, errorDetails: Any?) 46 | } -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/ThreshException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.runtime; 25 | 26 | /** 27 | * Signals that a method has been invoked at a thresh exception time. 28 | */ 29 | public class ThreshException extends RuntimeException { 30 | 31 | public ThreshException() { 32 | } 33 | 34 | 35 | public ThreshException(String exceptionMessage) { 36 | super(exceptionMessage); 37 | } 38 | 39 | public ThreshException(String exceptionMessage, Throwable reason) { 40 | super(exceptionMessage, reason); 41 | } 42 | 43 | public ThreshException(Throwable cause) { 44 | super(cause); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/MBJSExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.runtime.jscore; 25 | 26 | import io.manbang.frontend.thresh.runtime.jscore.bundle.BundleOptions; 27 | import io.manbang.frontend.thresh.runtime.jscore.runtime.JSExecutor; 28 | 29 | /** 30 | * js执行器 31 | */ 32 | public final class MBJSExecutor extends JSExecutor { 33 | 34 | private BundleOptions bundleOptions; 35 | 36 | public MBJSExecutor(BundleOptions bundleOptions) { 37 | this.bundleOptions= bundleOptions; 38 | } 39 | 40 | public BundleOptions getBundleOptions(){ 41 | return bundleOptions; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/bundle/BundleCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.runtime.jscore.bundle; 25 | 26 | /** 27 | * bundle callback 28 | */ 29 | public interface BundleCallback { 30 | 31 | /** 32 | * 33 | * @param code 0 成功 34 | * @param reason 错误原因 35 | * @param data 文件流 36 | */ 37 | void onResult(int code, String reason, String data); 38 | } 39 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/bundle/BundleType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.runtime.jscore.bundle; 25 | 26 | /** 27 | * bundle包运行类型 28 | *

29 | * 101: 本地内置包 30 | * 102: 宿主,加载本地Assets内置包 31 | * -100:js服务器 32 | */ 33 | public enum BundleType { 34 | 35 | /** 36 | * 宿主,加载本地内置包 37 | */ 38 | LOCAL_FILE(101), 39 | /** 40 | * 宿主,加载本地Assets内置包 41 | */ 42 | ASSETS_FILE(102), 43 | /** 44 | * 本地调试模式,连接js服务器端口 45 | */ 46 | JS_SERVER(-100); 47 | 48 | private final int type; 49 | 50 | BundleType(int type) { 51 | this.type = type; 52 | } 53 | 54 | public int getType(){ 55 | return type; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/bundle/ContainerType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.runtime.jscore.bundle; 25 | 26 | /** 27 | * 容器方 28 | */ 29 | public enum ContainerType { 30 | 31 | /** 32 | * Thresh - 动态flutter 33 | */ 34 | Thresh("Thresh"), 35 | /** 36 | * 达芬奇 - 配置化平台 37 | */ 38 | Davinci("Davinci"); 39 | 40 | private final String type; 41 | 42 | ContainerType(String type) { 43 | this.type = type; 44 | } 45 | 46 | public String getType(){ 47 | return type; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/runtime/CompatInjectJS.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.runtime.jscore.runtime; 25 | 26 | import io.manbang.frontend.thresh.util.ThreshLogger; 27 | 28 | /** 29 | * 自定义函数注入 解决V8兼容性问题 30 | */ 31 | public class CompatInjectJS { 32 | 33 | public CompatInjectJS() { 34 | } 35 | 36 | public void log(Object obj) { 37 | ThreshLogger.d("native-log", obj.toString()); 38 | } 39 | 40 | public void group(Object obj) { 41 | ThreshLogger.d("native-group", obj.toString()); 42 | } 43 | 44 | public void groupEnd(Object obj) { 45 | ThreshLogger.d("native-groupEnd", obj.toString()); 46 | } 47 | 48 | public void groupEnd() { 49 | ThreshLogger.d("native-groupEnd"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/jscore/runtime/JSCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.runtime.jscore.runtime; 25 | 26 | import androidx.annotation.Nullable; 27 | 28 | /** 29 | * Method call result callback. 30 | * 31 | *

All methods of this class must be called on the platform thread (Android main thread).

32 | * 33 | */ 34 | public interface JSCallback { 35 | 36 | /** 37 | * Handles a successful result. 38 | * 39 | * @param result The result, possibly null. 40 | */ 41 | void success(@Nullable Object result); 42 | 43 | /** 44 | * Handles an error result. 45 | * 46 | * @param errorCode error code. 47 | * @param errorMessage A human-readable error message String, possibly null. 48 | * @param errorDetails Error details, possibly null 49 | */ 50 | void error(int errorCode, @Nullable String errorMessage, @Nullable Object errorDetails); 51 | } 52 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/runtime/release/JsModuleReleaseConfig.java: -------------------------------------------------------------------------------- 1 | package io.manbang.frontend.thresh.runtime.release; 2 | 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * Module释放配置 8 | */ 9 | public class JsModuleReleaseConfig { 10 | public static class ModuleItemConfig { 11 | String moduleName; 12 | boolean release; 13 | long delayReleaseTime; 14 | } 15 | 16 | boolean lowMemoryRelease; 17 | List modules; 18 | } 19 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/util/ThreshToast.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.util; 25 | 26 | import android.content.Context; 27 | import android.widget.Toast; 28 | 29 | /** 30 | * toast 31 | */ 32 | public class ThreshToast { 33 | 34 | public static void makeText(Context context, CharSequence text, int duration) { 35 | Toast.makeText(context, text, duration).show(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /android/src/main/java/io/manbang/frontend/thresh/view/ThreshFlutterView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh.view; 25 | 26 | import android.content.Context; 27 | import android.util.AttributeSet; 28 | 29 | import io.flutter.embedding.android.FlutterSurfaceView; 30 | import io.flutter.embedding.android.FlutterTextureView; 31 | import io.flutter.embedding.android.FlutterView; 32 | 33 | /** 34 | * fix FlutterView bug 35 | */ 36 | public class ThreshFlutterView extends FlutterView { 37 | 38 | public ThreshFlutterView(Context context) { 39 | super(context); 40 | } 41 | 42 | public ThreshFlutterView(Context context, AttributeSet attrs) { 43 | super(context, attrs); 44 | } 45 | 46 | public ThreshFlutterView(Context context, FlutterSurfaceView flutterSurfaceView) { 47 | super(context,flutterSurfaceView); 48 | } 49 | 50 | public ThreshFlutterView(Context context, FlutterTextureView flutterTextureView) { 51 | super(context, flutterTextureView); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Generated.xcconfig 62 | **/ios/Flutter/app.flx 63 | **/ios/Flutter/app.zip 64 | **/ios/Flutter/flutter_assets/ 65 | **/ios/Flutter/flutter_export_environment.sh 66 | **/ios/ServiceDefinitions.json 67 | **/ios/Runner/GeneratedPluginRegistrant.* 68 | 69 | # Exceptions to above rules. 70 | !**/ios/**/default.mode1v3 71 | !**/ios/**/default.mode2v3 72 | !**/ios/**/default.pbxuser 73 | !**/ios/**/default.perspectivev3 74 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 75 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: eb6877bf926e5454379e42c95d49dcd60952dc62 8 | channel: v1.9.1-hotfixes 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # thresh_example 2 | 3 | Demonstrates how to use the thresh plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/io/manbang/frontend/thresh_example/ThreshDemoMethodChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | package io.manbang.frontend.thresh_example; 25 | 26 | import io.flutter.embedding.engine.FlutterEngine; 27 | import io.flutter.plugin.common.MethodChannel; 28 | import io.manbang.frontend.thresh.channel.MethodChannelModule; 29 | import io.manbang.frontend.thresh.runtime.EngineService; 30 | 31 | public class ThreshDemoMethodChannel extends MethodChannelModule { 32 | 33 | public ThreshDemoMethodChannel(FlutterEngine engine, EngineService engineService) { 34 | super(engine,engineService); 35 | } 36 | 37 | @Override 38 | public Object dispatchModuleChannelEvent(String module, String method, Object params, 39 | MethodChannel.Result result) { 40 | return null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/btn_shape_roundrect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/btn_switch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/layout/activity_thresh_flutter_fragment_container.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/btn_switch_checked.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/android/app/src/main/res/mipmap-xhdpi/btn_switch_checked.webp -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/btn_switch_none.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/android/app/src/main/res/mipmap-xhdpi/btn_switch_none.webp -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/btn_switch_thumb_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/android/app/src/main/res/mipmap-xhdpi/btn_switch_thumb_on.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/common_error_banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/android/app/src/main/res/mipmap-xhdpi/common_error_banner.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/df_title_btn_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/android/app/src/main/res/mipmap-xhdpi/df_title_btn_back.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/android/app/src/main/res/mipmap-xhdpi/logo.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 19 | 20 | 25 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext{ 3 | kotlin_version = '1.3.72' 4 | } 5 | repositories { 6 | maven {url 'https://maven.aliyun.com/repository/google'} 7 | maven {url 'http://maven.aliyun.com/mvn/repository/'} 8 | maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'} 9 | google() 10 | jcenter() 11 | maven {url "https://jitpack.io"} 12 | } 13 | 14 | dependencies { 15 | classpath 'com.android.tools.build:gradle:3.2.1' 16 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 17 | } 18 | } 19 | 20 | allprojects { 21 | repositories { 22 | maven {url 'https://maven.aliyun.com/repository/google'} 23 | maven {url 'http://maven.aliyun.com/mvn/repository/'} 24 | maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'} 25 | google() 26 | jcenter() 27 | maven {url "https://jitpack.io"} 28 | } 29 | 30 | configurations.all { 31 | resolutionStrategy.cacheChangingModulesFor 0, 'seconds' 32 | } 33 | } 34 | 35 | rootProject.buildDir = '../build' 36 | subprojects { 37 | project.buildDir = "${rootProject.buildDir}/${project.name}" 38 | } 39 | subprojects { 40 | project.evaluationDependsOn(':app') 41 | } 42 | 43 | task clean(type: Delete) { 44 | delete rootProject.buildDir 45 | } 46 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | android.enableR8=true 5 | v_lib_jscore=1.1.0 -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Flutter/.last_build_id: -------------------------------------------------------------------------------- 1 | 7a214be9adc6357136a0a0aa82cfe52f -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Flutter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: This podspec is NOT to be published. It is only used as a local source! 3 | # This is a generated file; do not edit or check into version control. 4 | # 5 | 6 | Pod::Spec.new do |s| 7 | s.name = 'Flutter' 8 | s.version = '1.0.0' 9 | s.summary = 'High-performance, high-fidelity mobile apps.' 10 | s.homepage = 'https://flutter.io' 11 | s.license = { :type => 'MIT' } 12 | s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } 13 | s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } 14 | s.ios.deployment_target = '8.0' 15 | # Framework linking is handled by Flutter tooling, not CocoaPods. 16 | # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs. 17 | s.vendored_frameworks = 'path/to/nothing' 18 | end 19 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | 43 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | #import 27 | 28 | @interface AppDelegate : FlutterAppDelegate 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon120.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon180.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/common_error_banner.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "common_error_banner.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/common_error_banner.imageset/common_error_banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/Assets.xcassets/common_error_banner.imageset/common_error_banner.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/scroll_image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "example_ios_Runner_Assets.xcassets_scroll_image.imageset_2.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/scroll_image.imageset/example_ios_Runner_Assets.xcassets_scroll_image.imageset_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/Assets.xcassets/scroll_image.imageset/example_ios_Runner_Assets.xcassets_scroll_image.imageset_2.png -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSAppTransportSecurity 6 | 7 | NSAllowsArbitraryLoads 8 | 9 | 10 | CFBundleDevelopmentRegion 11 | $(DEVELOPMENT_LANGUAGE) 12 | CFBundleExecutable 13 | $(EXECUTABLE_NAME) 14 | CFBundleIdentifier 15 | $(PRODUCT_BUNDLE_IDENTIFIER) 16 | CFBundleInfoDictionaryVersion 17 | 6.0 18 | CFBundleName 19 | Thresh 20 | CFBundlePackageType 21 | APPL 22 | CFBundleShortVersionString 23 | $(FLUTTER_BUILD_NAME) 24 | CFBundleSignature 25 | ???? 26 | CFBundleVersion 27 | $(FLUTTER_BUILD_NUMBER) 28 | LSRequiresIPhoneOS 29 | 30 | UILaunchStoryboardName 31 | LaunchScreen 32 | UIMainStoryboardFile 33 | Main 34 | UISupportedInterfaceOrientations 35 | 36 | UIInterfaceOrientationPortrait 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | UISupportedInterfaceOrientations~ipad 41 | 42 | UIInterfaceOrientationPortrait 43 | UIInterfaceOrientationPortraitUpsideDown 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | UIViewControllerBasedStatusBarAppearance 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /example/ios/Runner/JS.bundle/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | StringsTable 6 | Root 7 | PreferenceSpecifiers 8 | 9 | 10 | Type 11 | PSGroupSpecifier 12 | Title 13 | Group 14 | 15 | 16 | Type 17 | PSTextFieldSpecifier 18 | Title 19 | Name 20 | Key 21 | name_preference 22 | DefaultValue 23 | 24 | IsSecure 25 | 26 | KeyboardType 27 | Alphabet 28 | AutocapitalizationType 29 | None 30 | AutocorrectionType 31 | No 32 | 33 | 34 | Type 35 | PSToggleSwitchSpecifier 36 | Title 37 | Enabled 38 | Key 39 | enabled_preference 40 | DefaultValue 41 | 42 | 43 | 44 | Type 45 | PSSliderSpecifier 46 | Key 47 | slider_preference 48 | DefaultValue 49 | 0.5 50 | MinimumValue 51 | 0 52 | MaximumValue 53 | 1 54 | MinimumValueImage 55 | 56 | MaximumValueImage 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /example/ios/Runner/JS.bundle/en.lproj/Root.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/ios/Runner/JS.bundle/en.lproj/Root.strings -------------------------------------------------------------------------------- /example/ios/Runner/NativeImagePlatformView.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @interface NativeImagePlatformView : NSObject 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /example/ios/Runner/NativeScrollPlatformView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NativeScrollPlatformView.h 3 | // Runner 4 | // 5 | // Created by 汤靖咚 on 2021/7/21. 6 | // Copyright © 2021 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface NativeScrollPlatformView : NSObject 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /example/ios/Runner/NativeScrollPlatformView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NativeScrollPlatformView.m 3 | // Runner 4 | // 5 | // Created by 汤靖咚 on 2021/7/21. 6 | // Copyright © 2021 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import "NativeScrollPlatformView.h" 10 | #import 11 | #import "ThreshScrollView.h" 12 | 13 | @interface NativeScrollPlatformView () 14 | 15 | @property (nonatomic, assign) CGRect frame; 16 | @property (nonatomic, assign) int64_t viewId; 17 | @property (nonatomic, strong) id args; 18 | 19 | @property (nonatomic, strong) ThreshScrollView *scrollView; 20 | 21 | @end 22 | 23 | @implementation NativeScrollPlatformView 24 | 25 | #pragma mark - ThreshPlatformViewProtocol 26 | 27 | - (instancetype)initWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args registrar:(nonnull NSObject *)registrar { 28 | if (self = [super init]) { 29 | _frame = frame; 30 | _viewId = viewId; 31 | _args = args; 32 | } 33 | return self; 34 | } 35 | 36 | #pragma mark - FlutterPlatformView 37 | 38 | - (UIView *)view { 39 | 40 | return self.scrollView; 41 | } 42 | 43 | - (UIScrollView *)scrollView { 44 | if (!_scrollView) { 45 | _scrollView = [[ThreshScrollView alloc] init]; 46 | UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"scroll_image"]]; 47 | _scrollView.contentSize = CGSizeMake(imgView.frame.size.width, 0); 48 | [_scrollView addSubview:imgView]; 49 | _scrollView.backgroundColor = [UIColor blueColor]; 50 | } 51 | return _scrollView; 52 | } 53 | 54 | @end 55 | 56 | -------------------------------------------------------------------------------- /example/ios/Runner/SettingViewController.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @interface SettingViewController : UIViewController 30 | 31 | @end 32 | 33 | NS_ASSUME_NONNULL_END 34 | -------------------------------------------------------------------------------- /example/ios/Runner/ThreshScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ThreshScrollView.h 3 | // Runner 4 | // 5 | // Created by 汤靖咚 on 2021/7/21. 6 | // Copyright © 2021 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface ThreshScrollView : UIScrollView 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /example/ios/Runner/ThreshScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // ThreshScrollView.m 3 | // Runner 4 | // 5 | // Created by 汤靖咚 on 2021/7/21. 6 | // Copyright © 2021 The Chromium Authors. All rights reserved. 7 | // 8 | 9 | #import "ThreshScrollView.h" 10 | 11 | @implementation ThreshScrollView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/InfoCollector.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | #import 27 | 28 | NS_ASSUME_NONNULL_BEGIN 29 | 30 | @interface InfoCollector : NSObject 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/InfoCollector.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import "InfoCollector.h" 26 | 27 | @implementation InfoCollector 28 | 29 | - (void)lifeCycle:(ThreshLifeCycle)lifeCycle ext:(NSDictionary *)ext { 30 | NSLog(@" lifeCycle: %@ - ext: %@", @(lifeCycle), ext); 31 | } 32 | 33 | - (void)exceptionType:(ThreshExceptionType)exceptionType msg:(NSString *)msg { 34 | 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/Loader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | #import 27 | 28 | NS_ASSUME_NONNULL_BEGIN 29 | 30 | @interface Loader : NSObject 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/Loader.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import "Loader.h" 26 | 27 | @implementation Loader 28 | 29 | - (ThreshLoadType)loadType { 30 | 31 | return [[NSUserDefaults standardUserDefaults] boolForKey:@"local"] ? LoadWithCustomized : LoadWithURL; 32 | } 33 | 34 | - (NSString *)serverAddress { 35 | return [[NSUserDefaults standardUserDefaults] objectForKey:@"addressStr"]; 36 | } 37 | 38 | - (void)getJSDataWithModuleName:(NSString *)moduleName callback:(void (^)(NSData *))callback { 39 | NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"JS" withExtension:@"bundle"]; 40 | if (bundleURL) { 41 | NSBundle *bundle = [NSBundle bundleWithURL:bundleURL]; 42 | NSString *path = [bundle pathForResource:@"bundle" ofType:@"js"]; 43 | NSData *jsData = [NSData dataWithContentsOfFile:path]; 44 | callback(jsData); 45 | } 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/Logger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | #import 27 | 28 | NS_ASSUME_NONNULL_BEGIN 29 | 30 | @interface Logger : NSObject 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/Logger.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import "Logger.h" 26 | 27 | @implementation Logger 28 | 29 | - (void)log:(ThreshLogLevel)level msg:(NSString *)msg { 30 | NSLog(@"%@", msg); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/NativeBridge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | #import 27 | 28 | NS_ASSUME_NONNULL_BEGIN 29 | 30 | @interface NativeBridge : NSObject 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /example/ios/Runner/threshOptions/ThreshConfig.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import 26 | #import 27 | #import "Loader.h" 28 | #import "NativeBridge.h" 29 | #import "InfoCollector.h" 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | @interface ThreshConfig : NSObject 34 | 35 | - (instancetype)initWithOpaque:(BOOL)opaque; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /example/js/README.md: -------------------------------------------------------------------------------- 1 | ### 进入开发 2 | 3 | 1. 安装 yarn 4 | 2. 执行 `yarn config set registry http://npm.amh-group.com/` 切换 npm 源至运满满 5 | 3. 进入工程根目录,执行 `yarn install` 安装依赖 6 | 4. 执行 `yarn dev` 启动本地服务 7 | 5. 进入 Thresh - example 项目,执行 `flutter run` 启动 flutter 本地调试工程 8 | > Thresh-example 将会自动连接到 http://127.0.0.1:12345 并加载 js 执行文件 9 | 10 | > iOS 宿主工程支持连接本地服务进行调试,首先使用 `yarn prod` 代替 `yarn dev`,之后进入 iOS 宿主工程调试面板填写本地 ip 即可 11 | 12 | ### 项目打包 13 | 14 | 执行 `yarn build` 即可打包,打包后的项目会在 `/dist` 目录中 15 | 16 | -------------------------------------------------------------------------------- /example/js/dist/assets/test_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/js/dist/assets/test_image.png -------------------------------------------------------------------------------- /example/js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "thresh-demo", 3 | "version": "1.0.0", 4 | "main": "index.ts", 5 | "scripts": { 6 | "dev": "cross-env NODE_ENV=development HOT_UPDATE=true webpack-dev-server --config webpack/webpack.config.js", 7 | "prod": "cross-env NODE_ENV=production HOT_UPDATE=true webpack-dev-server --config webpack/webpack.config.js", 8 | "build": "cross-env NODE_ENV=production webpack --config webpack/webpack.config.js" 9 | }, 10 | "devDependencies": { 11 | "@babel/core": "^7.6.0", 12 | "@babel/plugin-proposal-class-properties": "^7.7.4", 13 | "@babel/plugin-proposal-object-rest-spread": "^7.5.5", 14 | "@babel/plugin-transform-runtime": "^7.7.6", 15 | "@babel/polyfill": "^7.8.7", 16 | "@babel/preset-env": "^7.7.7", 17 | "@babel/preset-react": "^7.7.4", 18 | "@babel/preset-typescript": "^7.7.7", 19 | "@babel/runtime": "^7.7.7", 20 | "@babel/runtime-corejs3": "^7.9.2", 21 | "babel-loader": "^8.0.6", 22 | "babel-plugin-transform-class-properties": "^6.24.1", 23 | "babel-plugin-transform-react-jsx": "^6.24.1", 24 | "cross-env": "^6.0.3", 25 | "expose-loader": "^0.7.5", 26 | "file-loader": "^5.0.2", 27 | "ts-loader": "^6.2.1", 28 | "tslib": "^1.10.0", 29 | "typescript": "^3.7.2", 30 | "url-loader": "^3.0.0", 31 | "webpack": "^4.41.5", 32 | "webpack-cli": "^3.3.10", 33 | "webpack-dev-server": "^3.10.1", 34 | "webpack-replace-loader": "^1.3.0" 35 | }, 36 | "dependencies": { 37 | "thresh-lib": "^1.3.55", 38 | "thresh-theme-provider": "^1.0.5" 39 | } 40 | } -------------------------------------------------------------------------------- /example/js/src/assets/icon_dealing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/js/src/assets/icon_dealing.png -------------------------------------------------------------------------------- /example/js/src/assets/icon_fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/js/src/assets/icon_fail.png -------------------------------------------------------------------------------- /example/js/src/assets/icon_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/js/src/assets/icon_success.png -------------------------------------------------------------------------------- /example/js/src/assets/test_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/js/src/assets/test_image.png -------------------------------------------------------------------------------- /example/js/src/images.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.svg' 2 | declare module '*.png' 3 | declare module '*.jpg' 4 | declare module '*.jpeg' 5 | declare module '*.gif' 6 | declare module '*.bmp' 7 | declare module '*.tiff' 8 | -------------------------------------------------------------------------------- /example/js/src/index.ts: -------------------------------------------------------------------------------- 1 | import Thresh, { ui } from 'thresh-lib' 2 | import threshThemeProvider from 'thresh-theme-provider' 3 | import { widgetList, apiList, extraPages } from './config' 4 | import HomePage from './pages/homePage' 5 | import PreDialog from './pages/preDialog' 6 | 7 | // 注册默认页面 8 | Thresh.registerPage('preDialog', () => PreDialog, { isDefault: true }) 9 | Thresh.registerPage('homePage', () => HomePage, { isDefault: false }) 10 | // 注册其他页面 11 | widgetList.concat(apiList, extraPages).forEach(({ pageName, pageBuilder, useInject }) => { 12 | Thresh.registerPage(pageName, pageBuilder) 13 | if (useInject) { 14 | Thresh.injectRoute({ pageName }) 15 | } 16 | }) 17 | 18 | Thresh.useProviders({ 19 | propsProvider: [threshThemeProvider] 20 | }) 21 | 22 | // flutter 环境准备就绪 23 | Thresh.ready = () => { 24 | // threshThemeProvider.loadAndUse('testTheme') 25 | // 设置 appBar 高度 26 | // appBar 默认高度 56 27 | ui.setAppBarHeight(ui.rpx(88)) 28 | // 运行程序 29 | Thresh.runApp() 30 | } 31 | -------------------------------------------------------------------------------- /example/js/src/pages/apis/ThemeProviderActions.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { 2 | Widget, 3 | basicWidgets, 4 | ui, 5 | Util, 6 | } from 'thresh-lib' 7 | import { Colors } from '../../config' 8 | 9 | const { 10 | Page, 11 | AppBar, 12 | Container, 13 | Text, 14 | } = basicWidgets 15 | 16 | export default class ThemeProviderActions extends Widget { 17 | state = { 18 | themeKey: 'base_common_btn_main' 19 | } 20 | 21 | widgetDidMount () { 22 | setTimeout(() => { 23 | this.setState({ 24 | themeKey: 'base_common_btn_border' 25 | }) 26 | }, 2000) 27 | } 28 | 29 | render () { 30 | return ( 31 | } 33 | backgroundColor={Colors.Pagebg} 34 | > 35 | 36 | 12345 37 | 38 | 39 | 40 | 41 | ) 42 | } 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/js/src/pages/apis/ToastActions.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets, ui } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | 6 | const { 7 | Page, 8 | AppBar, 9 | Container, 10 | Button, 11 | Text, 12 | Icon 13 | } = basicWidgets 14 | 15 | function buttonStyles () { 16 | return { 17 | width: 200, 18 | padding: 10, 19 | borderRadius: 5, 20 | backgroundColor: Colors.Primary 21 | } 22 | } 23 | 24 | export default class ToastActions extends Thresh.Widget { 25 | showAutoHideToast () { 26 | Thresh.showToast( 27 | 28 | 29 | 这是一个自定义 toast 30 | 31 | ) 32 | } 33 | 34 | render () { 35 | return ( 36 | 40 | } 41 | > 42 | 43 | <Box> 44 | <Button {...buttonStyles()} onTap={() => { this.showAutoHideToast() }}> 45 | <Text color={Colors.White}>显示 3s 后自动消失提示框</Text> 46 | </Button> 47 | </Box> 48 | 49 | <Title title="更多使用方式" /> 50 | <Box> 51 | <Text>你可以通过设置 Thresh.showToast() 的配置项,实现不会自动消失、通过代码控制消失的 toast.</Text> 52 | </Box> 53 | </Page> 54 | ) 55 | } 56 | } -------------------------------------------------------------------------------- /example/js/src/pages/basic/ButtonDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | 6 | const { Page, AppBar, Container, Button, Text } = basicWidgets 7 | 8 | export default class ButtonDemo extends Thresh.Widget <any, any> { 9 | state = { 10 | count: 0 11 | } 12 | buttonStyles = { 13 | width: 100, 14 | padding: 10, 15 | borderRadius: 5, 16 | backgroundColor: Colors.Primary 17 | } 18 | render () { 19 | return ( 20 | <Page 21 | backgroundColor={Colors.Pagebg} 22 | appBar={ 23 | <AppBar title="Button 按钮组件" /> 24 | } 25 | > 26 | <Title title={'点击按钮计数: ' + this.state.count} /> 27 | <Box> 28 | <Container width={Box.width} row justifyContent="spaceAround"> 29 | <Button {...this.buttonStyles} onTap={() => { this.setState({count: this.state.count-1}) }}> 30 | <Text color={Colors.White}>点击-1</Text> 31 | </Button> 32 | <Button {...this.buttonStyles} onTap={() => { this.setState({count: this.state.count+1}) }}> 33 | <Text color={Colors.White}>点击+1</Text> 34 | </Button> 35 | </Container> 36 | </Box> 37 | </Page> 38 | ) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/CheckboxDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | 6 | const { Page, AppBar, Checkbox, Text } = basicWidgets 7 | 8 | export default class CheckboxDemo extends Thresh.Widget <any, any> { 9 | state = { 10 | value: [] 11 | } 12 | 13 | radioList = [ 'apple', 'banana', 'orange', 'pear', 'mango' ] 14 | 15 | onChange (item: string, e: any) { 16 | const { value } = this.state 17 | const selected = e.value 18 | if (selected) value.push(item) 19 | else value.splice(value.indexOf(item), 1) 20 | this.setState() 21 | } 22 | 23 | render () { 24 | return ( 25 | <Page 26 | backgroundColor={Colors.Pagebg} 27 | appBar={ 28 | <AppBar title="Checkbox 多选框组件" /> 29 | } 30 | > 31 | <Title title={this.state.value.length ? ('当前选中: ' + this.state.value.join(', ')) : '当前未选中'} /> 32 | <Box> 33 | {this.radioList.map(item => ( 34 | <Checkbox height={30} value={this.state.value.indexOf(item) > -1} activeColor={Colors.Primary} onChange={this.onChange.bind(this, item)}> 35 | <Text>{item}</Text> 36 | </Checkbox> 37 | ))} 38 | </Box> 39 | </Page> 40 | ) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/ImageDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets, Util } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | import localImage from '../../assets/test_image.png' 6 | 7 | const { Page, AppBar, ScrollView, Image } = basicWidgets 8 | 9 | export default class ImageDemo extends Thresh.Widget <any, any> { 10 | render () { 11 | return ( 12 | <Page 13 | backgroundColor={Colors.Pagebg} 14 | appBar={ 15 | <AppBar title="Image 图片组件" /> 16 | } 17 | > 18 | <ScrollView> 19 | <Title title="本地图片" /> 20 | <Box> 21 | <Image src={localImage} /> 22 | </Box> 23 | 24 | <Title title="网络图片" /> 25 | <Box> 26 | <Image src="http://dmimg.5054399.com/allimg/pkm/pk/22.jpg" /> 27 | </Box> 28 | 29 | <Title title="带占位图的网络图片" /> 30 | <Box> 31 | <Image placeholder={localImage} src="https://upload-images.jianshu.io/upload_images/4741933-c8d3183c55365626.jpeg" fadeIn /> 32 | </Box> 33 | </ScrollView> 34 | </Page> 35 | ) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/InputDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets, Util } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | import { Input } from 'thresh-lib/src/core/basicWidget' 6 | 7 | const { Page, AppBar, Container } = basicWidgets 8 | 9 | export default class InputDemo extends Thresh.Widget <any, any> { 10 | render () { 11 | return ( 12 | <Page 13 | backgroundColor={Colors.Pagebg} 14 | appBar={ 15 | <AppBar title="Input 输入框组件" /> 16 | } 17 | > 18 | <InputDemoBody /> 19 | </Page> 20 | ) 21 | } 22 | } 23 | 24 | class InputDemoBody extends Thresh.Widget { 25 | $input: Input 26 | 27 | state = { 28 | value: '' 29 | } 30 | 31 | widgetDidMount () { 32 | setTimeout(() => { 33 | this.$input.focus() 34 | 35 | setTimeout(() => { 36 | this.$input.blur() 37 | }, 3000) 38 | }, 3000) 39 | } 40 | 41 | render () { 42 | return ( 43 | <Container> 44 | <Title title={this.state.value ? (`当前输入内容${this.state.value.length}: ` + this.state.value) : '当前未输入内容'} /> 45 | <Box> 46 | <Input 47 | ref={e => this.$input = e as Input} 48 | padding={10} 49 | backgroundColor={Colors.Pagebg} 50 | value={this.state.value} 51 | placeholder="请输入内容" 52 | // textStyle={{ 53 | // size: 10 54 | // }} 55 | // maxLength={10} 56 | // maxLines={5} 57 | returnActionType="done" 58 | onSubmitted={({ value }) =>{ 59 | Util.log('onSubmitted', value) 60 | }} 61 | onFocus={({ value }) =>{ 62 | Util.log('onFocus', value) 63 | }} 64 | onBlur={({ value }) =>{ 65 | Util.log('onBlur', value) 66 | }} 67 | onChange={({ value }) => { 68 | Util.log('onChange', value) 69 | this.setState({ value }) 70 | }} 71 | /> 72 | </Box> 73 | </Container> 74 | ) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/NativeViewDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { 2 | Widget, 3 | basicWidgets, 4 | ui 5 | } from 'thresh-lib' 6 | import Box from '../../widgets/Box' 7 | import { Colors } from '../../config' 8 | import { NativeView } from 'thresh-lib/src/core/basicWidget' 9 | 10 | const { 11 | Page, 12 | AppBar, 13 | Text, 14 | } = basicWidgets 15 | 16 | export default class NativeViewDemo extends Widget <any, any> { 17 | render () { 18 | return ( 19 | <Page 20 | appBar={<AppBar title="NativeView 原生视图组件" titleColor={Colors.White} backgroundColor={Colors.Primary} />} 21 | backgroundColor={Colors.Primary} 22 | > 23 | <Box> 24 | <NativeView 25 | gesture={'HorizontalDrag'} 26 | type={"thresh/native_text_view"} params={{ "text": "我是NativeTextView,测试" }} width={ui.screenWidth} height={ui.rpx(100)} backgroundColor={0xffFFFBF9} /> 27 | </Box> 28 | </Page> 29 | ) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/PageAppBar.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Box from '../../widgets/Box' 4 | import Center from '../../widgets/Center' 5 | 6 | const { Page, AppBar, Container, Text, Icon } = basicWidgets 7 | 8 | export default class PageAppBar extends Thresh.Widget <any, any> { 9 | widgetDidMount () { 10 | Thresh.pageDidShow() 11 | } 12 | render () { 13 | return ( 14 | <Page 15 | backgroundColor={Colors.Primary} 16 | appBar={ 17 | <AppBar 18 | title="自定义 AppBar" 19 | titleColor={Colors.White} 20 | titleSize={18} 21 | backgroundColor={Colors.Primary} 22 | leading={ 23 | <Center> 24 | <Center width={30} height={30} borderRadius={15} backgroundColor={Colors.White} onTap={() => { Thresh.popPage() }}> 25 | <Icon type="arrow_back" color={Colors.Primary} /> 26 | </Center> 27 | </Center> 28 | } 29 | buttons={[ 30 | <Text color={Colors.White} size={14} onTap={() => { Thresh.popPage() }}>返回</Text>, 31 | <Center width={30} height={30} borderRadius={15} margin={{ left: 10, right: 10 }} onTap={() => { Thresh.popPage() }}> 32 | <Icon type="bookmark" color={Colors.White} size={18} /> 33 | </Center> 34 | ]} 35 | /> 36 | } 37 | > 38 | <Box> 39 | <Text color={Colors.Darkgray}> 40 | 本页面的根容器为 Page 组件。 41 | </Text> 42 | </Box> 43 | <Box> 44 | <Text color={Colors.Darkgray}> 45 | 通过自定义 AppBar 组件的标题、返回按钮和右侧按钮列表,实现了点击返回按钮和右侧按钮都可以返回到上级页面的功能。 46 | </Text> 47 | </Box> 48 | </Page> 49 | ) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/QrImageDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | 6 | const { Page, AppBar, QrImage } = basicWidgets 7 | 8 | export default class QrImageDemo extends Thresh.Widget <any, any> { 9 | render () { 10 | return ( 11 | <Page 12 | backgroundColor={Colors.Pagebg} 13 | appBar={ 14 | <AppBar title="QrImage 二维码组件" /> 15 | } 16 | > 17 | <Title title="二维码" /> 18 | <Box> 19 | <QrImage text="http://dmimg.5054399.com/allimg/pkm/pk/22.jpg" 20 | backgroundColor={0xffFFFBF9} 21 | foregroundColor={0xff333333} 22 | /> 23 | </Box> 24 | <Box> 25 | <QrImage text="http://dmimg.5054399.com/allimg/pkm/pk/22.jpg" 26 | backgroundColor={0xffFFFBF9} 27 | foregroundColor={0xff333333} 28 | embeddedImageUrl="http://dmimg.5054399.com/allimg/pkm/pk/22.jpg" 29 | embeddedImageHeight={25} 30 | embeddedImageWidth={25} 31 | /> 32 | </Box> 33 | </Page> 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/RadioDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | 6 | const { Page, AppBar, Radio, Text } = basicWidgets 7 | 8 | export default class RadioDemo extends Thresh.Widget <any, any> { 9 | state = { 10 | value: void 0 11 | } 12 | 13 | radioList = [ 'apple', 'banana', 'orange', 'pear', 'mango' ] 14 | 15 | render () { 16 | return ( 17 | <Page 18 | backgroundColor={Colors.Pagebg} 19 | appBar={ 20 | <AppBar title="Radio 单选框组件" /> 21 | } 22 | > 23 | <Title title={this.state.value ? ('当前选中: ' + this.state.value) : '当前未选中'} /> 24 | <Box> 25 | {this.radioList.map(item => ( 26 | <Radio height={30} value={item} groupValue={this.state.value} activeColor={Colors.Primary} onChange={({ value }) => { this.setState({ value }) }}> 27 | <Text>{item}</Text> 28 | </Radio> 29 | ))} 30 | </Box> 31 | </Page> 32 | ) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/RefreshDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | import Center from '../../widgets/Center' 6 | 7 | const { Page, AppBar, Refresh } = basicWidgets 8 | 9 | export default class RefreshDemo extends Thresh.Widget <any, any> { 10 | render () { 11 | return ( 12 | <Page 13 | backgroundColor={Colors.Pagebg} 14 | appBar={ 15 | <AppBar title="Refresh 属性指示器组件" /> 16 | } 17 | > 18 | <Title title="默认样式" /> 19 | <Box> 20 | <Center width={Box.width}> 21 | <Refresh /> 22 | </Center> 23 | </Box> 24 | 25 | <Title title="修改主色" /> 26 | <Box> 27 | <Center width={Box.width}> 28 | <Refresh color={Colors.Red} /> 29 | </Center> 30 | </Box> 31 | 32 | <Title title="添加辅色" /> 33 | <Box> 34 | <Center width={Box.width}> 35 | <Refresh color={Colors.Red} secondColor={Colors.Pagebg} /> 36 | </Center> 37 | </Box> 38 | 39 | <Title title="改变大小" /> 40 | <Box> 41 | <Center width={Box.width}> 42 | <Refresh size={40} /> 43 | </Center> 44 | </Box> 45 | 46 | <Title title="改变粗细" /> 47 | <Box> 48 | <Center width={Box.width}> 49 | <Refresh strokeWidth={2} /> 50 | </Center> 51 | </Box> 52 | </Page> 53 | ) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/ScrollViewDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { 2 | Widget, 3 | ui, 4 | basicWidgets 5 | } from 'thresh-lib' 6 | import Box from '../../widgets/Box' 7 | import Title from '../../widgets/Title' 8 | import { Colors } from '../../config' 9 | import { NativeView } from 'thresh-lib/src/core/basicWidget' 10 | 11 | const { 12 | Page, 13 | AppBar, 14 | ScrollView, 15 | Container, 16 | Text, 17 | } = basicWidgets 18 | 19 | export default class ScrollViewDemo extends Widget <any, any> { 20 | 21 | renderContent () { 22 | return (new Array(20)).fill(1).map((_, index) => ( 23 | <NativeView 24 | gesture={['HorizontalDrag']} 25 | type={"thresh/native_text_view"} params={{ "text": "我是NativeTextView,测试" }} width={ui.screenWidth} height={ui.rpx(300)} backgroundColor={0xffFFFBF9} /> 26 | )) 27 | } 28 | 29 | $ref 30 | 31 | render () { 32 | return ( 33 | <Page 34 | appBar={<AppBar title="ScrollView 滚动组件" />} 35 | backgroundColor={Colors.Pagebg} 36 | > 37 | <Title title="竖向滚动" /> 38 | <Box contentWidth={300}> 39 | <Container width={300} height={ui.screenHeight / 3}> 40 | <ScrollView ref={e => this.$ref = e}> 41 | {this.renderContent()} 42 | </ScrollView> 43 | </Container> 44 | </Box> 45 | 46 | <Title title="横向滚动" /> 47 | <Box> 48 | <Container width={Box.width} height={30}> 49 | <ScrollView direction="horizontal"> 50 | <Container row> 51 | {this.renderContent()} 52 | </Container> 53 | </ScrollView> 54 | </Container> 55 | </Box> 56 | </Page> 57 | ) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/SwiperViewDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { 2 | ui, 3 | basicWidgets 4 | } from 'thresh-lib' 5 | import Box from '../../widgets/Box' 6 | import Title from '../../widgets/Title' 7 | import { Colors } from '../../config' 8 | import Center from '../../widgets/Center' 9 | 10 | const { 11 | Page, 12 | AppBar, 13 | SwiperView, 14 | Text, 15 | } = basicWidgets 16 | 17 | export default class SwiperViewDemo extends Thresh.Widget <any, any> { 18 | 19 | renderContent () { 20 | return (new Array(20)).fill(1).map((item, index) => ( 21 | <Center backgroundColor={Colors.Primary} margin={5}> 22 | <Text color={Colors.White} weight="bolder">{index}</Text> 23 | </Center> 24 | )) 25 | } 26 | 27 | render () { 28 | return ( 29 | <Page 30 | appBar={<AppBar title="SwiperView 滑动组件" />} 31 | backgroundColor={Colors.Pagebg} 32 | > 33 | <Title title="横向滑动" /> 34 | <Box> 35 | <SwiperView width={Box.width} height={ui.screenHeight / 4} viewportFraction={0.9}> 36 | {this.renderContent()} 37 | </SwiperView> 38 | </Box> 39 | 40 | <Title title="竖向滑动" /> 41 | <Box> 42 | <SwiperView width={Box.width} height={ui.screenHeight / 4} row={false}> 43 | {this.renderContent()} 44 | </SwiperView> 45 | </Box> 46 | </Page> 47 | ) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/SwitchDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | 6 | const { Page, AppBar, Switch } = basicWidgets 7 | 8 | export default class SwitchDemo extends Thresh.Widget <any, any> { 9 | state = { 10 | value: true 11 | } 12 | render () { 13 | return ( 14 | <Page 15 | backgroundColor={Colors.Pagebg} 16 | appBar={ 17 | <AppBar title="Switch 开关组件" /> 18 | } 19 | > 20 | <Title title={this.state.value ? '当前开关打开' : '当前开关关闭'} /> 21 | <Box> 22 | <Switch value={this.state.value} activeColor={0xFFFA871E} onChange={({ value }) => { this.setState({ value }) }} /> 23 | </Box> 24 | </Page> 25 | ) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/js/src/pages/basic/TextDemo.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../../config' 3 | import Title from '../../widgets/Title' 4 | import Box from '../../widgets/Box' 5 | import { Container } from 'thresh-lib/src/core/basicWidget' 6 | 7 | const { Page, AppBar, ScrollView, Text } = basicWidgets 8 | 9 | export default class TextDemo extends Thresh.Widget<any, any> { 10 | widgetDidMount() { 11 | Thresh.pageDidShow() 12 | } 13 | render() { 14 | return ( 15 | <Page 16 | backgroundColor={Colors.Pagebg} 17 | appBar={ 18 | <AppBar title="Text 文本组件" /> 19 | } 20 | > 21 | <ScrollView> 22 | <Title title="普通文本" /> 23 | <Box> 24 | <Text color={Colors.Primary} size={20} weight="bolder">这是一段普通文本,可以设置文本颜色和字号、字重。</Text> 25 | </Box> 26 | 27 | <Container alignItems={'baseline'}> 28 | <Text >1111111</Text> 29 | </Container> 30 | 31 | <Title title="富文本" /> 32 | <Box> 33 | <Text 34 | richText={[ 35 | { text: '这是富文本的红色文字,', color: 0xffff0000 }, 36 | { text: '这是富文本的绿色加粗文字,', color: 0xff00ff00, weight: 'bolder' }, 37 | { text: '这是富文本的蓝色加粗加大文字。', color: 0xff0000ff, weight: 'bolder', size: 20 }, 38 | ]} 39 | > 40 | 这是一段富文本, 41 | </Text> 42 | </Box> 43 | 44 | <Box> 45 | <Container height={50} border={{ color: Colors.Primary }} justifyContent="center" alignItems="center"> 46 | <Text 47 | border={{ color: Colors.Red }} 48 | // backgroundColor={Colors.Primary} 49 | // padding={5} 50 | > 51 | HFJKHDSJFHJSDHFJKD 52 | </Text> 53 | </Container> 54 | </Box> 55 | </ScrollView> 56 | </Page> 57 | ) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /example/js/src/pages/examples/iconViewer.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { 2 | Widget, 3 | Util, 4 | ui, 5 | basicWidgets 6 | } from 'thresh-lib' 7 | import Center from '../../widgets/Center' 8 | import { IconType } from 'thresh-lib/src/types/widget' 9 | 10 | const { 11 | Page, 12 | AppBar, 13 | ScrollView, 14 | Container, 15 | Text, 16 | Icon, 17 | } = basicWidgets 18 | 19 | export default class IconViewer extends Widget <any, any> { 20 | icons: IconType[] = ['loading', 'apps', 'arrow_back', 'arrow_back_ios', 'arrow_downward', 'arrow_drop_down', 'arrow_drop_up', 'arrow_forward', 'arrow_forward_ios', 'arrow_left', 'arrow_right', 'arrow_upward', 'check', 'check_circle', 'check_circle_outline', 'add', 'add_circle', 'add_circle_outline', 'close', 'cancel', 'create', 'chevron_left', 'chevron_right', 'aexpand_lesspps', 'expand_more', 'refresh', 'fullscreen', 'fullscreen_exit', 'more_horiz', 'more_vert', 'unfold_less', 'unfold_more', 'control_point', 'crop', 'adjust', 'camera', 'camera_alt', 'image', 'broken_image', 'phone_iphone', 'phone_android', 'watch', 'tv', 'headset', 'computer', 'cloud_done', 'cloud_download', 'cloud_upload', 'cloud_off', 'folder', 'title', 'insert_link', 'insert_chart', 'format_quote', 'format_list_bulleted', 'format_list_numbered', 'attach_file', 'attach_money', 'access_alarms', 'account_box', 'account_circle', 'bookmark', 'bookmark_border', 'fingerprint', 'gif', 'home', 'info', 'info_outline'] 21 | 22 | render () { 23 | return ( 24 | <Page 25 | appBar={<AppBar title="图标示例" />} 26 | > 27 | <ScrollView padding={{ bottom: ui.bottomBarHeight }}> 28 | <Text margin={ui.rpx(20)}>Tip: Loading 图标不支持修改颜色!</Text> 29 | <Container 30 | row 31 | wrap 32 | width={ui.screenWidth} 33 | > 34 | { 35 | this.icons.map(icon => ( 36 | <Center padding={ui.rpx(20)} width={ui.screenWidth / 3}> 37 | <Icon type={icon} size={ui.rpx(40)} /> 38 | <Text size={ui.rpx(20)} margin={{ top: ui.rpx(10) }}>{icon}</Text> 39 | </Center> 40 | )) 41 | } 42 | </Container> 43 | </ScrollView> 44 | </Page> 45 | ) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /example/js/src/pages/examples/imageViewer.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { 2 | Widget, 3 | basicWidgets, 4 | Util, 5 | ui 6 | } from 'thresh-lib' 7 | import Center from '../../widgets/Center' 8 | import BannerImage1 from '../../assets/test_image.png' 9 | import BannerImage2 from '../../assets/icon_dealing.png' 10 | import BannerImage3 from '../../assets/icon_success.png' 11 | 12 | const { 13 | Page, 14 | AppBar, 15 | SwiperView, 16 | Button, 17 | Image 18 | } = basicWidgets 19 | 20 | export default class ImageViewer extends Widget <any, any> { 21 | $swiper 22 | 23 | bindSwiperView (ref) { 24 | this.$swiper = ref 25 | } 26 | render () { 27 | const swiperViewHeight = ui.screenHeight - ui.appbarHeight - ui.statusBarHeight 28 | return ( 29 | <Page 30 | appBar={<AppBar title="图片浏览器" backgroundColor={0xff000000} titleColor={0xffffffff} statusTextLight />} 31 | backgroundColor={0xff000000} 32 | > 33 | <SwiperView 34 | row={false} 35 | ref={this.bindSwiperView.bind(this)} 36 | width={ui.screenWidth} 37 | height={swiperViewHeight} 38 | backgroundColor={0xff000000} 39 | initIndex={0} 40 | onChange={({ index }) => { Util.log(index) }} 41 | > 42 | <Center onTap={() => { 43 | setTimeout(() => { 44 | this.$swiper.swipeTo(2) 45 | }, 2000) 46 | }}> 47 | <Image src={BannerImage1} /> 48 | </Center> 49 | <Center> 50 | <Image src={BannerImage2} /> 51 | </Center> 52 | <Center> 53 | <Image src={BannerImage3} /> 54 | </Center> 55 | </SwiperView> 56 | </Page> 57 | ) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /example/js/src/pages/examples/timer.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { 2 | Widget, 3 | Util, 4 | basicWidgets 5 | } from 'thresh-lib' 6 | 7 | const { 8 | Page, 9 | AppBar, 10 | Text 11 | } = basicWidgets 12 | 13 | export default class TimerDemo extends Widget <any, any> { 14 | state = { 15 | timeoutUpdated: false, 16 | intervalCount: 0 17 | } 18 | 19 | timeout 20 | interval 21 | 22 | constructor (props) { 23 | super(props) 24 | this.timeout = setTimeout(() => { 25 | this.setState({ 26 | timeoutUpdated: true 27 | }) 28 | }, 5000) 29 | this.interval = setInterval(() => { 30 | if (this.state.intervalCount >= 10) { 31 | clearInterval(this.interval) 32 | return 33 | } 34 | this.setState({ 35 | intervalCount: this.state.intervalCount + 1 36 | }) 37 | }, 1000) 38 | } 39 | 40 | widgetDidUnmount () { 41 | clearTimeout(this.timeout) 42 | clearInterval(this.interval) 43 | } 44 | 45 | render () { 46 | return ( 47 | <Page 48 | appBar={<AppBar title="Timer" />} 49 | > 50 | <TimerItem text={`普通定时器-5秒更新: ${ this.state.timeoutUpdated ? '已更新' : '未更新' }`} /> 51 | <TimerItem text={`循环定时器-10秒停止: ${ this.state.intervalCount } 秒`} /> 52 | </Page> 53 | ) 54 | } 55 | } 56 | 57 | class TimerItem extends Widget <any, any> { 58 | render () { 59 | return ( 60 | <Text margin={20}> 61 | {this.props.text} 62 | </Text> 63 | ) 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /example/js/src/widgets/Box.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { ui, basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../config' 3 | 4 | const MARGIN = 10 5 | const { Container } = basicWidgets 6 | 7 | interface IBox { 8 | contentWidth?: number, 9 | onTap?: Function, 10 | children?: any 11 | } 12 | 13 | export default class Box extends Thresh.Widget <IBox, any> { 14 | static get width(): number { return ui.screenWidth - 2 * MARGIN } 15 | 16 | render () { 17 | return ( 18 | <Container 19 | margin={{ top: MARGIN/2, bottom: MARGIN/2, left: MARGIN, right: MARGIN }} 20 | boxShadow={{ color: 0x20649ef4, offsetX: 3, offsetY: 3, blur: 5 }} 21 | borderRadius={5} 22 | onTap={this.props.onTap && this.props.onTap.bind(this)} 23 | > 24 | <Container 25 | width={this.props.contentWidth ? this.props.contentWidth + 40 : Box.width} 26 | backgroundColor={Colors.White} 27 | borderRadius={5} 28 | padding={20} 29 | > 30 | {this.props.children} 31 | </Container> 32 | </Container> 33 | ) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/js/src/widgets/Center.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | 3 | const { Container } = basicWidgets 4 | 5 | export default class Center extends Thresh.Widget <any, any> { 6 | render () { 7 | const { children, ...props } = this.props 8 | return ( 9 | <Container 10 | justifyContent="center" 11 | alignItems="center" 12 | {...props} 13 | > 14 | {children} 15 | </Container> 16 | ) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/js/src/widgets/Loading.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets, ui } from 'thresh-lib' 2 | import Center from './Center' 3 | 4 | const { Text, Icon } = basicWidgets 5 | 6 | interface ShowLoadingParams { 7 | message?: string, 8 | overTime?: number 9 | } 10 | 11 | export default class Loading { 12 | /** 13 | * 14 | * @param message loading提示信息 15 | * @param overTime loading超时自动关闭的时间,默认 10000ms,设为 0 则不会主动关闭 16 | */ 17 | static show (params: ShowLoadingParams = {}) { 18 | const { message = '', overTime = 10000 } = params 19 | Loading.index++ 20 | const name = Loading.showName 21 | Thresh.showToast(Loading.render(message), { 22 | name, 23 | stayTime: 0, 24 | position: { left: 0, top: 0 } 25 | }) 26 | if (overTime) { 27 | const id = setTimeout(() => { 28 | Loading.hide() 29 | }, overTime) 30 | Loading.timers[name] = id 31 | } 32 | } 33 | static hide () { 34 | const name = Loading.showName 35 | Thresh.hideToast(name) 36 | const id = Loading.timers[name] 37 | if (id) { 38 | clearTimeout(id) 39 | delete Loading.timers[name] 40 | } 41 | Loading.index-- 42 | } 43 | static hideAll () { 44 | while (Loading.index) { 45 | Loading.hide() 46 | } 47 | } 48 | 49 | private static index = 0 50 | private static get showName () { 51 | return `loading#${Loading.index}` 52 | } 53 | private static timers = {} 54 | private static render (message?: string) { 55 | return ( 56 | <Center backgroundColor={0x90000000} width={ui.screenWidth} height={ui.screenHeight}> 57 | <Center backgroundColor={0xffffffff} borderRadius={ui.rpx(8)} padding={ui.rpx(40)}> 58 | <Icon type="loading" size={ui.rpx(40)} /> 59 | { 60 | message && 61 | <Text margin={{top: ui.rpx(20)}} color={0xff000000}>{message}</Text> 62 | } 63 | </Center> 64 | </Center> 65 | ) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /example/js/src/widgets/Title.tsx: -------------------------------------------------------------------------------- 1 | import Thresh, { basicWidgets } from 'thresh-lib' 2 | import { Colors } from '../config' 3 | 4 | interface ITitle { 5 | title: string 6 | } 7 | 8 | const { Text } = basicWidgets 9 | 10 | export default class Title extends Thresh.Widget <ITitle, any> { 11 | render () { 12 | return ( 13 | <Text 14 | margin={{ left: 10, top: 10, bottom: 5 }} 15 | padding={{ left: 10 }} 16 | border={{ width: 5, color: Colors.Primary, side: [ 'left' ]}} 17 | color={Colors.Primary} 18 | > 19 | {this.props.title} 20 | </Text> 21 | ) 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /example/js/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true, 4 | "jsx": "react", 5 | "jsxFactory": "Thresh.createElement", 6 | "lib": [ "es5", "es6" ], 7 | "target": "es5", 8 | }, 9 | "include": [ "src" ] 10 | } -------------------------------------------------------------------------------- /example/js/webpack/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | server: { 3 | host: '0.0.0.0', 4 | // 远程调试时如果本地图片未显示,可以通过修改该字段为你的网络ip后,重新启动服务,本地图片即可显示 5 | // imageProxyHost: '10.190.22.92', 6 | port: 12345, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /example/js/webpack/loader/image-loader.js: -------------------------------------------------------------------------------- 1 | const os = require('os') 2 | const path = require('path') 3 | const { readFileSync } = require('fs') 4 | const loaderUtils = require('loader-utils') 5 | 6 | const rootPath = path.resolve(__dirname, '../../') 7 | const networkInterfaces = os.networkInterfaces() 8 | let internalIp = '127.0.0.1' 9 | if (networkInterfaces && networkInterfaces.en0) { 10 | for (let i in networkInterfaces.en0) { 11 | const interface = networkInterfaces.en0[i] 12 | if (interface.family === 'IPv6') continue 13 | internalIp = interface.address 14 | } 15 | } 16 | 17 | module.exports = function() { 18 | const loaderOptions = loaderUtils.getOptions(this) 19 | const devMode = loaderOptions.localImageUseHttpRequestEnvs.indexOf(process.env.NODE_ENV) > -1 20 | const imagePath = this.resource 21 | 22 | let src = imagePath.split(path.join('/', 'src'))[1] 23 | if (!src) throw new Error('Static assets must include by "src" folder.') 24 | if (!devMode) { 25 | this.emitFile(src, readFileSync(imagePath)) 26 | } else { 27 | src = imagePath.split(rootPath)[1] 28 | } 29 | 30 | return `export default '${ 31 | !devMode 32 | ? src 33 | : `http://${loaderOptions.imageHost || internalIp}:${loaderOptions.port || '12345'}${src}` 34 | }'` 35 | } 36 | -------------------------------------------------------------------------------- /example/js/webpack/loader/try-catch-loader/index.js: -------------------------------------------------------------------------------- 1 | const babel = require('@babel/core') 2 | const loaderUtils = require("loader-utils") 3 | const tryCatchWrapper = require('./plugin').default 4 | 5 | module.exports = function (source, inputMap) { 6 | let fileName = '' 7 | if (this.resource.indexOf('/node_modules') > -1) { 8 | fileName = this.resource.split('/node_modules')[1] 9 | } else { 10 | fileName = this.resource.split('/src')[1] 11 | } 12 | const loaderOptions = loaderUtils.getOptions(this) 13 | const transOpts = { 14 | plugins: [ 15 | [ 16 | tryCatchWrapper, 17 | { 18 | reportError: loaderOptions.reporter, 19 | rethrow: loaderOptions.rethrow, 20 | noCatchFuncNames: loaderOptions.noCatchFuncNames || [], 21 | fileName 22 | } 23 | ] 24 | ] 25 | } 26 | try { 27 | const result = babel.transform(source, transOpts) 28 | this.callback(null, result.code, result.map) 29 | } catch (e) { 30 | throw e 31 | } 32 | } -------------------------------------------------------------------------------- /example/lib/assets/icon_back_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/lib/assets/icon_back_black.png -------------------------------------------------------------------------------- /example/lib/assets/icon_back_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/lib/assets/icon_back_white.png -------------------------------------------------------------------------------- /example/lib/assets/on_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/example/lib/assets/on_error.png -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/rendering.dart'; 4 | import 'package:flutter/services.dart'; 5 | import 'package:flutter/widgets.dart'; 6 | 7 | import 'thresh.dart' as thresh; 8 | 9 | // 本地调试入口 10 | void main() async { 11 | WidgetsFlutterBinding.ensureInitialized(); 12 | window.onSemanticsEnabledChanged = () {}; 13 | RendererBinding.instance.setSemanticsEnabled(false); 14 | if (window.defaultRouteName.isNotEmpty 15 | && window.defaultRouteName.startsWith('thresh/thresh-page')) { 16 | thresh.initPlugin(window.defaultRouteName); 17 | return; 18 | } 19 | // 默认测试页面 20 | thresh.main(); 21 | 22 | MethodChannel('io.manbang.frontend/method_channel') 23 | .setMethodCallHandler((call) async { 24 | switch (call.method) { 25 | case 'setInitRoute': 26 | print("setInitRoute==>" + call.arguments); 27 | thresh.initPlugin(call.arguments); 28 | break; 29 | } 30 | }); 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: thresh_example 2 | description: Demonstrates how to use the thresh plugin. 3 | 4 | version: 0.0.1 5 | 6 | environment: 7 | sdk: ">=2.10.0 <3.0.0" 8 | flutter: ">=2.2.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | thresh: 19 | path: ../ 20 | 21 | # For information on the generic Dart part of this file, see the 22 | # following page: https://dart.dev/tools/pub/pubspec 23 | 24 | # The following section is specific to Flutter. 25 | flutter: 26 | 27 | # The following line ensures that the Material Icons font is 28 | # included with your application, so that you can use the icons in 29 | # the material Icons class. 30 | uses-material-design: true 31 | 32 | # To add assets to your application, add an assets section, like this: 33 | # assets: 34 | # - images/a_dot_burr.jpeg 35 | # - images/a_dot_ham.jpeg 36 | 37 | # An image asset can refer to one or more resolution-specific "variants", see 38 | # https://flutter.dev/assets-and-images/#resolution-aware. 39 | 40 | # For details regarding adding assets from package dependencies, see 41 | # https://flutter.dev/assets-and-images/#from-packages 42 | 43 | # To add custom fonts to your application, add a fonts section here, 44 | # in this "flutter" section. Each entry in this list should have a 45 | # "family" key with the font family name, and a "fonts" key with a 46 | # list giving the asset and other descriptors for the font. For 47 | # example: 48 | # fonts: 49 | # - family: Schyler 50 | # fonts: 51 | # - asset: fonts/Schyler-Regular.ttf 52 | # - asset: fonts/Schyler-Italic.ttf 53 | # style: italic 54 | # - family: Trajan Pro 55 | # fonts: 56 | # - asset: fonts/TrajanPro.ttf 57 | # - asset: fonts/TrajanPro_Bold.ttf 58 | # weight: 700 59 | # 60 | # For details regarding fonts from package dependencies, 61 | # see https://flutter.dev/custom-fonts/#from-packages 62 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | void main() { 11 | testWidgets('Verify Platform version', (WidgetTester tester) async { 12 | // Build our app and trigger a frame. 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /images/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image1.png -------------------------------------------------------------------------------- /images/image10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image10.png -------------------------------------------------------------------------------- /images/image11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image11.png -------------------------------------------------------------------------------- /images/image12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image12.png -------------------------------------------------------------------------------- /images/image13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image13.png -------------------------------------------------------------------------------- /images/image14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image14.png -------------------------------------------------------------------------------- /images/image15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image15.png -------------------------------------------------------------------------------- /images/image16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image16.png -------------------------------------------------------------------------------- /images/image17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image17.png -------------------------------------------------------------------------------- /images/image18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image18.png -------------------------------------------------------------------------------- /images/image19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image19.png -------------------------------------------------------------------------------- /images/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image2.png -------------------------------------------------------------------------------- /images/image20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image20.png -------------------------------------------------------------------------------- /images/image21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image21.png -------------------------------------------------------------------------------- /images/image22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image22.png -------------------------------------------------------------------------------- /images/image23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image23.png -------------------------------------------------------------------------------- /images/image24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image24.png -------------------------------------------------------------------------------- /images/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image3.png -------------------------------------------------------------------------------- /images/image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image4.png -------------------------------------------------------------------------------- /images/image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image5.png -------------------------------------------------------------------------------- /images/image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image6.png -------------------------------------------------------------------------------- /images/image7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image7.png -------------------------------------------------------------------------------- /images/image8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image8.png -------------------------------------------------------------------------------- /images/image9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/image9.png -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/logo.png -------------------------------------------------------------------------------- /images/qrcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/images/qrcode.jpg -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ymm-tech/thresh/b4629deea4325ac4fc8506eb022f6a7fc5d09c96/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/Interface/ThreshDataLoader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | typedef NS_ENUM(NSInteger, ThreshLoadType) { 28 | LoadWithURL, 29 | LoadWithCustomized 30 | }; 31 | 32 | @protocol ThreshDataLoader <NSObject> 33 | 34 | @optional 35 | // 加载选项,默认走自定义方式,通过 getJSDataWithModuleName:callback: 获取 36 | - (ThreshLoadType)loadType; 37 | // 通过远程地址加载时可手动传地址,默认本机地址 38 | - (NSString *)serverAddress; 39 | // 选择自定义数据获取方式 40 | - (void)getJSDataWithModuleName:(NSString *)moduleName callback:(void (^)(NSData *data))callback; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ios/Classes/Interface/ThreshInfoExport.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | typedef NS_ENUM(NSInteger, ThreshLifeCycle) { 30 | ThreshPageInit = 1, 31 | ThreshBeforeLoadBundle, 32 | ThreshAfterLoadBundle, 33 | ThreshBeforeEvalJS, 34 | ThreshAfterEvalJS, 35 | ThreshPageDidLoad, 36 | ThreshPageDidShow, 37 | ThreshFlutterFirstFrame, 38 | }; 39 | 40 | typedef NS_ENUM(NSInteger, ThreshExceptionType) { 41 | ThreshExceptionJS, 42 | }; 43 | 44 | @protocol ThreshInfoExport <NSObject> 45 | 46 | @optional 47 | 48 | // 不同状态及扩展字段 49 | - (void)lifeCycle:(ThreshLifeCycle)lifeCycle ext:(NSDictionary *)ext; 50 | // 异常信息 51 | - (void)exceptionType:(ThreshExceptionType)exceptionType msg:(NSString *)msg; 52 | 53 | @end 54 | 55 | NS_ASSUME_NONNULL_END 56 | -------------------------------------------------------------------------------- /ios/Classes/Interface/ThreshLogger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | typedef NS_ENUM(NSInteger, ThreshLogLevel) { 30 | ThreshLogDebug = 1, 31 | ThreshLogInfo = 2, 32 | ThreshLogWarn = 3, 33 | ThreshLogError = 4, 34 | ThreshLogFatal = 5, 35 | }; 36 | 37 | @protocol ThreshLogger <NSObject> 38 | 39 | @optional 40 | // log等级及信息 41 | - (void)log:(ThreshLogLevel)level msg:(NSString *)msg; 42 | 43 | @end 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /ios/Classes/Interface/ThreshNativeBridge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | #import "ThreshDef.h" 27 | 28 | NS_ASSUME_NONNULL_BEGIN 29 | 30 | @protocol ThreshNativeBridge <NSObject> 31 | 32 | @optional 33 | - (void)performBridge:(NSDictionary *)bridgeInfo callBack:(ThreshBridgeCallBack)callBack; 34 | 35 | - (void)transferThreshData:(id)data; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /ios/Classes/Interface/ThreshNativePlatformView.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @protocol ThreshNativePlatformView <NSObject> 30 | 31 | /** 32 | * { <#viewId#>: <#className#>, ... } 33 | * viewId string flutter和native双方约定的自定义视图id 34 | * className string 自定义视图的className 35 | */ 36 | @property (nonatomic, strong) NSDictionary *platformViewConfig; 37 | 38 | - (void)invokeInstanceMethodWithArgs:(NSDictionary *)args; 39 | 40 | @end 41 | 42 | NS_ASSUME_NONNULL_END 43 | -------------------------------------------------------------------------------- /ios/Classes/Interface/ThreshOptions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @protocol ThreshDefaultViewOptions <NSObject> 30 | // 加载重试 31 | - (void)triggerRetry:(void (^)(void))retry; 32 | 33 | @end 34 | 35 | @protocol ThreshOptions <NSObject, ThreshDefaultViewOptions> 36 | 37 | @optional 38 | // 提供容器缺省页 39 | - (UIView<ThreshDefaultViewOptions> *)defaultViewForContainer; 40 | // 是否需要splash 默认 false 41 | @property (nonatomic, assign) BOOL needDefaultSplashScreenView; 42 | // 自定义splashView 43 | @property (nonatomic, strong) UIView *splashScreenView; 44 | // 页面是否透明 默认 不透明 45 | @property (nonatomic, assign) BOOL opaque; 46 | 47 | @end 48 | 49 | NS_ASSUME_NONNULL_END 50 | -------------------------------------------------------------------------------- /ios/Classes/Interface/ThreshRouterParams.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @protocol ThreshRouterParams <NSObject> 30 | 31 | @optional 32 | @property (nonatomic, strong) NSString *pageName; 33 | @property (nonatomic, strong) NSString *moduleName; 34 | @property (nonatomic, strong) NSString *referPageName; 35 | @property (nonatomic, strong) NSString *routerString; 36 | @property (nonatomic, strong) NSString *entrypoint; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /ios/Classes/Thresh.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #ifndef Thresh_h 26 | #define Thresh_h 27 | 28 | #import "ThreshAppDelegate.h" 29 | #import "ThreshViewController.h" 30 | #import "ThreshPlatformViewFactory.h" 31 | 32 | #endif /* Thresh_h */ 33 | -------------------------------------------------------------------------------- /ios/Classes/ThreshAppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | #import "ThreshLogger.h" 27 | #import "ThreshNativeBridge.h" 28 | #import "ThreshDataLoader.h" 29 | #import <Flutter/Flutter.h> 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | @interface ThreshAppDelegate : NSObject 34 | 35 | + (instancetype)sharedInstance; 36 | 37 | - (void)startThreshWithLogger:(id<ThreshLogger>)logger engineGroup:(FlutterEngineGroup *)engineGroup; 38 | 39 | @property (nonatomic, strong, readonly) id<ThreshLogger> logger; 40 | 41 | @property (nonatomic, strong, readonly) FlutterEngineGroup *engineGroup; 42 | 43 | @end 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /ios/Classes/ThreshAppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import "ThreshAppDelegate.h" 26 | 27 | @interface ThreshAppDelegate () 28 | 29 | @property (nonatomic, strong) id<ThreshDataLoader> loader; 30 | 31 | @property (nonatomic, strong) id<ThreshLogger> logger; 32 | 33 | @property (nonatomic, strong) id<ThreshNativeBridge> nativeBridge; 34 | 35 | @property (nonatomic, strong) FlutterEngineGroup *engineGroup; 36 | 37 | @end 38 | 39 | @implementation ThreshAppDelegate 40 | 41 | + (instancetype)sharedInstance { 42 | 43 | static ThreshAppDelegate *instance = nil; 44 | static dispatch_once_t onceToken; 45 | dispatch_once(&onceToken, ^{ 46 | instance = [ThreshAppDelegate new]; 47 | }); 48 | return instance; 49 | } 50 | 51 | - (void)startThreshWithLogger:(id<ThreshLogger>)logger engineGroup:(nonnull FlutterEngineGroup *)engineGroup { 52 | if (logger) { 53 | _logger = logger; 54 | } 55 | if (engineGroup) { 56 | _engineGroup = engineGroup; 57 | } 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /ios/Classes/ThreshPlugin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Flutter/Flutter.h> 26 | 27 | @interface ThreshPlugin : NSObject<FlutterPlugin> 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /ios/Classes/ThreshPlugin.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import "ThreshPlugin.h" 26 | 27 | @interface ThreshPlugin () 28 | 29 | @end 30 | 31 | @implementation ThreshPlugin 32 | 33 | + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {} 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ios/Classes/platformView/ThreshPlatformViewFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | #import <Flutter/Flutter.h> 27 | #import "ThreshPlatformViewProtocol.h" 28 | 29 | NS_ASSUME_NONNULL_BEGIN 30 | 31 | @interface ThreshPlatformViewFactory : NSObject <FlutterPlatformViewFactory> 32 | 33 | - (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar objClassName:(NSString *)objClassName; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /ios/Classes/platformView/ThreshPlatformViewProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @protocol ThreshPlatformViewProtocol <NSObject> 30 | 31 | - (instancetype)initWithFrame:(CGRect)frame 32 | viewIdentifier:(int64_t)viewId 33 | arguments:(id _Nullable)args 34 | registrar:(NSObject<FlutterPluginRegistrar> *)registrar; 35 | 36 | @end 37 | 38 | NS_ASSUME_NONNULL_END 39 | -------------------------------------------------------------------------------- /ios/Classes/runtime/dartModule/ThreshPlatformUniqueChannelKeyGenerator.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @interface ThreshPlatformUniqueChannelKeyGenerator : NSObject 30 | 31 | - (instancetype)initWithPageName:(NSString *)pageName moduleName:(NSString *)moduleName channelName:(NSString *)channelName; 32 | 33 | - (NSString *)uniqueChannelID; 34 | 35 | - (NSString *)getChannelName; 36 | 37 | @end 38 | 39 | NS_ASSUME_NONNULL_END 40 | -------------------------------------------------------------------------------- /ios/Classes/runtime/jsCore/ThreshJSCoreDef.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #ifndef ThreshJSCoreDef_h 26 | #define ThreshJSCoreDef_h 27 | 28 | typedef void(^ThreshJSLoaderResponse)(NSData *response, NSError *err); 29 | 30 | typedef void(^ThreshJSInvokeMethodResponse)(NSDictionary *params, NSError *err); 31 | 32 | typedef void(^ThreshJSCompleteResponse)(void); 33 | 34 | #endif /* ThreshJSCoreDef_h */ 35 | -------------------------------------------------------------------------------- /ios/Classes/runtime/jsCore/ThreshJSLoader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | #import "ThreshJSCoreDef.h" 27 | 28 | @class ThreshJSLoaderOptions; 29 | 30 | extern NSString *getRemoteSourceFailNotification; 31 | extern NSString *getRemoteSourceSuccessNotification; 32 | 33 | 34 | @interface ThreshJSLoader : NSObject 35 | 36 | + (ThreshJSLoader *)sharedLoader; 37 | 38 | - (void)loadJSWithAddress:(NSString *)address response:(ThreshJSLoaderResponse)response; 39 | 40 | @end 41 | 42 | -------------------------------------------------------------------------------- /ios/Classes/runtime/jsModule/ThreshJSChannelManager.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | /** 26 | * 管理 jsCoreChannel 27 | * 按照js包拆分纬度对channel进行管理 28 | */ 29 | 30 | #import <Foundation/Foundation.h> 31 | #import "ThreshJSCoreChannel.h" 32 | #import "ThreshProtocol.h" 33 | 34 | NS_ASSUME_NONNULL_BEGIN 35 | 36 | @interface ThreshJSChannelManager : NSObject 37 | 38 | + (ThreshJSChannelManager *)sharedMgr; 39 | 40 | - (BOOL)loadedWithModule:(NSString *)moduleName; 41 | 42 | - (void)haveLoadedWithModule:(NSString *)moduleName; 43 | 44 | - (ThreshJSCoreChannel *)channelWithModule:(NSString *)moduleName; 45 | 46 | - (void)removeChannelWithModule:(NSString *)moduleName; 47 | 48 | @end 49 | 50 | NS_ASSUME_NONNULL_END 51 | -------------------------------------------------------------------------------- /ios/Classes/runtime/jsModule/ThreshJSTimerManager.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | typedef void(^timerFire)(NSString *timerId); 30 | 31 | @interface ThreshJSTimerManager : NSObject 32 | 33 | + (void)operateTimer:(NSDictionary *)args block:(timerFire)block; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /ios/Classes/util/NSTimer+Thresh.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | 27 | NS_ASSUME_NONNULL_BEGIN 28 | 29 | @interface NSTimer (Thresh) 30 | 31 | + (NSTimer *)thresh_scheduledTimerWithTimeInterval:(NSTimeInterval)interval 32 | repeats:(BOOL)repeats 33 | block:(void (^)(NSTimer *timer))block; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /ios/Classes/util/NSTimer+Thresh.m: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2021 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import "NSTimer+Thresh.h" 26 | 27 | @implementation NSTimer (Thresh) 28 | 29 | + (NSTimer *)thresh_scheduledTimerWithTimeInterval:(NSTimeInterval)interval 30 | repeats:(BOOL)repeats 31 | block:(void (^)(NSTimer *))block { 32 | return [self scheduledTimerWithTimeInterval:interval 33 | target:self 34 | selector:@selector(thresh_blockInvoke:) 35 | userInfo:[block copy] 36 | repeats:repeats]; 37 | } 38 | 39 | + (void)thresh_blockInvoke:(NSTimer *)timer { 40 | void(^block)(NSTimer *timer) = timer.userInfo; 41 | if (block) { 42 | block(timer); 43 | } 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /ios/Classes/util/ThreshLogHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ 24 | 25 | #import <Foundation/Foundation.h> 26 | #import "ThreshLogger.h" 27 | 28 | #define ThreshDebug(...) ThreshLog(ThreshLogDebug, __VA_ARGS__) 29 | #define ThreshInfo(...) ThreshLog(ThreshLogInfo, __VA_ARGS__) 30 | #define ThreshWarn(...) ThreshLog(ThreshLogWarn, __VA_ARGS__) 31 | #define ThreshError(...) ThreshLog(ThreshLogError, __VA_ARGS__) 32 | #define ThreshFatal(...) ThreshLog(ThreshLogFatal, __VA_ARGS__) 33 | 34 | #define ThreshLog(level, ...) [ThreshLogHandler log:level msg:[NSString stringWithFormat:__VA_ARGS__, nil] function:__FUNCTION__] 35 | 36 | @interface ThreshLogHandler : NSObject 37 | 38 | + (void)log:(ThreshLogLevel)level msg:(NSString *)msg function:(const char *)func; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ios/thresh.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'thresh' 6 | s.version = '0.0.1' 7 | s.summary = 'A new Flutter plugin.' 8 | s.description = <<-DESC 9 | A new Flutter plugin. 10 | DESC 11 | s.homepage = 'https://github.com/ymm-tech/thresh' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Your Company' => 'email@example.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | s.dependency 'AFNetworking', '4.0.1' 19 | 20 | s.ios.deployment_target = '8.0' 21 | end 22 | 23 | -------------------------------------------------------------------------------- /js-core/LICENSE: -------------------------------------------------------------------------------- 1 | /** 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 ManBang Group 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | */ -------------------------------------------------------------------------------- /js-core/README.md: -------------------------------------------------------------------------------- 1 | # Thresh 2 | 3 | > What is Thresh? 4 | > A dynamic flutter framework. 5 | 6 | [如何使用 Thresh 进行动态 flutter 项目的开发?](https://wiki.amh-group.com/pages/viewpage.action?pageId=60425354) -------------------------------------------------------------------------------- /js-core/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "thresh-lib", 3 | "version": "1.3.33", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/node": { 8 | "version": "13.7.7", 9 | "resolved": "http://npm.ymmoa.com/@types%2fnode/-/node-13.7.7.tgz", 10 | "integrity": "sha1-FijmRhuozJtTGW3+rux7B/pu6pk=", 11 | "dev": true 12 | }, 13 | "typescript": { 14 | "version": "4.1.3", 15 | "resolved": "http://npm.amh-group.com/typescript/-/typescript-4.1.3.tgz", 16 | "integrity": "sha1-UZ1YK9lMugz4k0x9joRn5HP1O7c=", 17 | "dev": true 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /js-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "thresh-lib", 3 | "version": "1.3.55", 4 | "description": "Front-end framework for Thresh", 5 | "main": "index.ts", 6 | "author": "weishun.xu", 7 | "license": "MIT", 8 | "files": [ 9 | "index.ts", 10 | "src/**/*" 11 | ], 12 | "devDependencies": { 13 | "@types/node": "^13.1.1", 14 | "typescript": "^4.1.3" 15 | }, 16 | "scripts": {} 17 | } -------------------------------------------------------------------------------- /js-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react", 4 | "jsxFactory": "Thresh.createElement", 5 | "lib": [ "es5", "es6", "es2017", "dom" ], 6 | "target": "es5" 7 | }, 8 | "exclude": [ "node_modules/**/*" ] 9 | } -------------------------------------------------------------------------------- /js-core/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@types/node@^13.1.1": 6 | version "13.13.34" 7 | resolved "http://npm.amh-group.com/@types%2fnode/-/node-13.13.34.tgz#c9300a1b6560d90817fb2bba650e250116a575f9" 8 | integrity sha1-yTAKG2Vg2QgX+yu6ZQ4lARaldfk= 9 | 10 | typescript@^4.1.3: 11 | version "4.1.3" 12 | resolved "http://npm.amh-group.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7" 13 | integrity sha1-UZ1YK9lMugz4k0x9joRn5HP1O7c= 14 | -------------------------------------------------------------------------------- /lib/basic/bus.dart: -------------------------------------------------------------------------------- 1 | /// MIT License 2 | /// 3 | /// Copyright (c) 2020 ManBang Group 4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 5 | /// of this software and associated documentation files (the "Software"), to deal 6 | /// in the Software without restriction, including without limitation the rights 7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | /// copies of the Software, and to permit persons to whom the Software is 9 | /// furnished to do so, subject to the following conditions: 10 | /// 11 | /// The above copyright notice and this permission notice shall be included in all 12 | /// copies or substantial portions of the Software. 13 | /// 14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | /// SOFTWARE. 21 | 22 | class _Bus { 23 | Map<String, Function> pool = {}; 24 | int busId = 0; 25 | 26 | dynamic register(Function callback, [String name]) { 27 | dynamic busName = name ?? (++busId).toString(); 28 | if (!has(busName)) { 29 | pool[busName] = callback; 30 | return busName; 31 | } 32 | } 33 | 34 | fire(String name, {dynamic args}) { 35 | if (!has(name)) return; 36 | Function cb = pool[name]; 37 | if (args == null) 38 | cb(); 39 | else 40 | cb(args); 41 | } 42 | 43 | has(String name) { 44 | return !!(name != null && pool[name] != null); 45 | } 46 | 47 | remove(String name) { 48 | if (!has(name)) return; 49 | pool.remove(name); 50 | } 51 | } 52 | 53 | _Bus bus = _Bus(); 54 | -------------------------------------------------------------------------------- /lib/basic/device_info.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'dart:io'; 3 | 4 | import 'package:device_info/device_info.dart'; 5 | 6 | class Device { 7 | 8 | static AndroidDeviceInfo androidDeviceInfo; 9 | 10 | static IosDeviceInfo iosDeviceInfo; 11 | 12 | static initDeviceInfo() async { 13 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); 14 | if(Platform.isAndroid){ 15 | androidDeviceInfo = await deviceInfo.androidInfo; 16 | }else if(Platform.isIOS){ 17 | iosDeviceInfo = await deviceInfo.iosInfo; 18 | } 19 | } 20 | 21 | static bool isAndroidQ(){ 22 | if(Platform.isAndroid && Device.androidDeviceInfo != null && Device.androidDeviceInfo.version != null){ 23 | return Device.androidDeviceInfo.version.sdkInt > 28; 24 | } 25 | return false; 26 | } 27 | } -------------------------------------------------------------------------------- /lib/framework/channel/bridge.dart: -------------------------------------------------------------------------------- 1 | /// MIT License 2 | /// 3 | /// Copyright (c) 2020 ManBang Group 4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 5 | /// of this software and associated documentation files (the "Software"), to deal 6 | /// in the Software without restriction, including without limitation the rights 7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | /// copies of the Software, and to permit persons to whom the Software is 9 | /// furnished to do so, subject to the following conditions: 10 | /// 11 | /// The above copyright notice and this permission notice shall be included in all 12 | /// copies or substantial portions of the Software. 13 | /// 14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | /// SOFTWARE. 21 | 22 | import 'dart:convert'; 23 | import 'package:thresh/basic/util.dart'; 24 | import 'package:thresh/framework/core/dynamic_app.dart'; 25 | import 'package:thresh/framework/channel/basic.dart'; 26 | 27 | /// 注册渲染相关 channel 方法 28 | void registerBridgeChannelMethods () { 29 | DynamicChannel.register({ 30 | 'bridgeRequest': (params) async { 31 | String methodId = Util.getString(params['methodId']); 32 | Map<String, dynamic> request = jsonDecode(params['request']); 33 | Map<String, dynamic> res = await Util.request(request['params']); 34 | dynamicApp?.call( 35 | method: ChannelMethod.bridgeResponse, 36 | params: { 37 | 'methodId': methodId, 38 | 'response': res 39 | } 40 | ); 41 | }, 42 | }); 43 | } 44 | -------------------------------------------------------------------------------- /lib/framework/channel/dev.dart: -------------------------------------------------------------------------------- 1 | /// MIT License 2 | /// 3 | /// Copyright (c) 2020 ManBang Group 4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 5 | /// of this software and associated documentation files (the "Software"), to deal 6 | /// in the Software without restriction, including without limitation the rights 7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | /// copies of the Software, and to permit persons to whom the Software is 9 | /// furnished to do so, subject to the following conditions: 10 | /// 11 | /// The above copyright notice and this permission notice shall be included in all 12 | /// copies or substantial portions of the Software. 13 | /// 14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | /// SOFTWARE. 21 | 22 | import 'package:thresh/basic/util.dart'; 23 | import 'package:thresh/framework/channel/basic.dart'; 24 | import 'package:thresh/devtools/dev_tools.dart'; 25 | 26 | /// 注册渲染相关 channel 方法 27 | void registerDevtoolsChannelMethods () { 28 | DynamicChannel.register({ 29 | 'devtools': (params) { 30 | String type = Util.getString(params['type']); 31 | String title = Util.getString(params['title']); 32 | String content = Util.getString(params['content']); 33 | if (type == null) return; 34 | InfoType infoType = InfoType.getType(type); 35 | if (infoType == null) return; 36 | devtools.insert(infoType, DevInfo( 37 | title: title, 38 | content: content 39 | )); 40 | }, 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /lib/thresh.dart: -------------------------------------------------------------------------------- 1 | /// MIT License 2 | /// 3 | /// Copyright (c) 2020 ManBang Group 4 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 5 | /// of this software and associated documentation files (the "Software"), to deal 6 | /// in the Software without restriction, including without limitation the rights 7 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | /// copies of the Software, and to permit persons to whom the Software is 9 | /// furnished to do so, subject to the following conditions: 10 | /// 11 | /// The above copyright notice and this permission notice shall be included in all 12 | /// copies or substantial portions of the Software. 13 | /// 14 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | /// SOFTWARE. 21 | 22 | library thresh; 23 | 24 | export 'framework/main.dart'; 25 | --------------------------------------------------------------------------------