diff --git a/.github/workflows/publish_app_dev.yaml b/.github/workflows/publish_app_dev.yaml index 803bba23..1433c2d6 100644 --- a/.github/workflows/publish_app_dev.yaml +++ b/.github/workflows/publish_app_dev.yaml @@ -7,6 +7,7 @@ on: - 'dev' jobs: + # 打包Android、iOS、Mac build-mac-ios-android: runs-on: macos-latest @@ -14,12 +15,12 @@ jobs: contents: write steps: - #签出代码 - - uses: actions/checkout@v3 + # 签出代码 + - uses: actions/checkout@v4 with: ref: dev - #APK签名设置 + # APK签名设置 - name: Download Android keystore id: android_keystore uses: timheuer/base64-to-file@v1.2 @@ -33,27 +34,39 @@ jobs: echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> simple_live_app/android/key.properties echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> simple_live_app/android/key.properties - #设置JAVA环境 - - uses: actions/setup-java@v3 + # 设置JAVA环境 + - uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: "12.x" - cache: 'gradle' + java-version: "17" + cache: "gradle" - #设置Flutter + # 设置Flutter - name: Flutter action uses: subosito/flutter-action@v2 with: - flutter-version: '3.19.x' + flutter-version: '3.22.x' cache: true - #更新Flutter的packages + # 打开MAC Desktop支持 + - name: Enable Flutter Desktop + run: flutter config --enable-macos-desktop + + # 更新Flutter的packages - name: Restore packages run: | cd simple_live_app flutter pub get - #打包APK + # 安装appdmg npm install -g appdmg + - name: Install appdmg + run: npm install -g appdmg + + # 设置flutter_distributor环境 + - name: Install flutter_distributor + run: dart pub global activate flutter_distributor + + # 打包APK - name: Build APK run: | cd simple_live_app @@ -61,14 +74,43 @@ jobs: #上传Artifacts - name: Upload APK to Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: app-release.apk + name: android path: | simple_live_app/build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk simple_live_app/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk simple_live_app/build/app/outputs/flutter-apk/app-x86_64-release.apk + # TV APK签名设置 + - name: Download Android TV keystore + id: android_tv_keystore + uses: timheuer/base64-to-file@v1.2 + with: + fileName: keystore_tv.jks + encodedString: ${{ secrets.TV_KEYSTORE_BASE64 }} + - name: Create key.properties + run: | + echo "storeFile=${{ steps.android_tv_keystore.outputs.filePath }}" > simple_live_tv_app/android/key.properties + echo "storePassword=${{ secrets.TV_STORE_PASSWORD }}" >> simple_live_tv_app/android/key.properties + echo "keyPassword=${{ secrets.TV_KEY_PASSWORD }}" >> simple_live_tv_app/android/key.properties + echo "keyAlias=${{ secrets.TV_KEY_ALIAS }}" >> simple_live_tv_app/android/key.properties + + #打包 Android TV APK + - name: Build TV APK + run: | + cd simple_live_tv_app + flutter build apk --release --split-per-abi + #上传TV APK至Artifacts + - name: Upload TV APK to Artifacts + uses: actions/upload-artifact@v4 + with: + name: android_tv + path: | + simple_live_tv_app/build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk + simple_live_tv_app/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk + simple_live_tv_app/build/app/outputs/flutter-apk/app-x86_64-release.apk + #打包iOS - name: Build IPA run: | @@ -85,13 +127,117 @@ jobs: zip -q -r ios_no_sign.ipa Payload cd ../../.. - #上传IPA至Artifacts + # 上传IPA至Artifacts - name: Upload IPA to Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: ios_no_sign.ipa + name: ios path: | simple_live_app/build/ios/iphoneos/ios_no_sign.ipa + # 打包MAC + - name: Build MacOS + run: | + cd simple_live_app + flutter_distributor package --platform macos --targets dmg,zip --skip-clean + + # 上传MAC至Artifacts + - name: Upload MacOS to Artifacts + uses: actions/upload-artifact@v4 + with: + name: mac + path: | + simple_live_app/build/dist/*/*.dmg + simple_live_app/build/dist/*/*.zip #完成 - run: echo "🍏 This job's status is ${{ job.status }}." + + # 打包Linux + build-linux: + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + # 签出代码 + - uses: actions/checkout@v4 + with: + ref: dev + # 设置Flutter环境 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.22.x" + cache: true + # 安装依赖 + - name: Update apt-get + run: sudo apt-get update + - name: Install Dependencies + run: sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libmpv-dev mpv + # 打开Linux Desktop支持 + - name: Enable Flutter Desktop + run: flutter config --enable-linux-desktop + # 更新Flutter的packages + - name: Restore Packages + run: | + cd simple_live_app + flutter pub get + # 设置flutter_distributor环境 + - name: Install flutter_distributor + run: dart pub global activate flutter_distributor + # build Linux ZIP\DMG + - name: Build Linux + run: | + cd simple_live_app + flutter_distributor package --platform linux --targets deb,zip --skip-clean + # 上传Linux包至Artifacts + - name: Upload Linux APP to Artifacts + uses: actions/upload-artifact@v4 + with: + name: linux + path: | + simple_live_app/build/dist/*/*.deb + simple_live_app/build/dist/*/*.zip + + #完成 + - run: echo "🍏 Linux job's status is ${{ job.status }}." + + # 打包Windows + build-windows: + runs-on: windows-latest + permissions: + contents: write + steps: + # 签出代码 + - uses: actions/checkout@v4 + with: + ref: dev + # 设置Flutter环境 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.22.x" + cache: true + - name: Enable Flutter Desktop + run: flutter config --enable-windows-desktop + - name: Restore Packages + run: | + cd simple_live_app + flutter pub get + # 设置flutter_distributor环境 + - name: Install flutter_distributor + run: dart pub global activate flutter_distributor + # build Windows ZIP\MSIX + - name: Build Windows + run: | + cd simple_live_app + flutter_distributor package --platform windows --targets msix,zip --skip-clean + # 上传Windows至Artifacts + - name: Upload Windows APP to Artifacts + uses: actions/upload-artifact@v4 + with: + name: windows + path: | + simple_live_app/build/dist/*/*.msix + simple_live_app/build/dist/*/*.zip + #完成 + - run: echo "🍏 Windows job's status is ${{ job.status }}." diff --git a/.github/workflows/publish_app_release.yml b/.github/workflows/publish_app_release.yml index a6dc1d12..166c04ca 100644 --- a/.github/workflows/publish_app_release.yml +++ b/.github/workflows/publish_app_release.yml @@ -3,7 +3,7 @@ name: app-build-action on: push: tags: - - "*" + - "v*" jobs: build-mac-ios-android: runs-on: macos-latest @@ -11,9 +11,10 @@ jobs: contents: write steps: #签出代码 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: master + #APK签名设置 - name: Download Android keystore id: android_keystore @@ -27,42 +28,61 @@ jobs: echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> simple_live_app/android/key.properties echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> simple_live_app/android/key.properties echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> simple_live_app/android/key.properties + #设置JAVA环境 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: "12.x" + java-version: "17" cache: 'gradle' + #设置Flutter - name: Flutter action uses: subosito/flutter-action@v2 with: - flutter-version: '3.19.x' + flutter-version: '3.22.x' cache: true + + # 打开MAC Desktop支持 + - name: Enable Flutter Desktop + run: flutter config --enable-macos-desktop + #更新Flutter的packages - name: Restore packages run: | cd simple_live_app flutter pub get + + # 安装appdmg npm install -g appdmg + - name: Install appdmg + run: npm install -g appdmg + + # 设置flutter_distributor环境 + - name: Install flutter_distributor + run: dart pub global activate flutter_distributor + #打包APK - name: Build APK run: | cd simple_live_app flutter build apk --release --split-per-abi + #上传APK至Artifacts - name: Upload APK to Artifacts uses: actions/upload-artifact@v3 with: - name: app-release.apk + name: android path: | simple_live_app/build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk simple_live_app/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk simple_live_app/build/app/outputs/flutter-apk/app-x86_64-release.apk + #打包iOS - name: Build IPA run: | cd simple_live_app flutter build ios --release --no-codesign + #创建未签名ipa - name: Create IPA run: | @@ -72,13 +92,30 @@ jobs: cd build/ios/iphoneos/ zip -q -r ios_no_sign.ipa Payload cd ../../.. + #上传IPA至Artifacts - name: Upload IPA to Artifacts uses: actions/upload-artifact@v3 with: - name: ios_no_sign.ipa + name: ios path: | simple_live_app/build/ios/iphoneos/ios_no_sign.ipa + + # 打包MAC + - name: Build MacOS + run: | + cd simple_live_app + flutter_distributor package --platform macos --targets dmg,zip --skip-clean + + # 上传MAC至Artifacts + - name: Upload MacOS to Artifacts + uses: actions/upload-artifact@v4 + with: + name: mac + path: | + simple_live_app/build/dist/*/*.dmg + simple_live_app/build/dist/*/*.zip + #读取版本信息 - name: Read version id: version @@ -89,16 +126,158 @@ jobs: run: echo "${{ fromJson(steps.version.outputs.content).version }}" - name: Echo version content run: echo "${{ fromJson(steps.version.outputs.content).version_desc }}" + + #上传至Release + - name: Upload Release + uses: softprops/action-gh-release@v1 + with: + name: "${{ fromJson(steps.version.outputs.content).version }}" + body: "${{ fromJson(steps.version.outputs.content).version_desc }}" + prerelease: ${{ fromJson(steps.version.outputs.content).prerelease }} + token: ${{ secrets.TOKEN }} + files: | + simple_live_app/build/app/outputs/flutter-apk/app-x86_64-release.apk + simple_live_app/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk + simple_live_app/build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk + simple_live_app/build/ios/iphoneos/ios_no_sign.ipa + simple_live_app/build/dist/*/*.dmg + simple_live_app/build/dist/*/*.zip + #完成 + - run: echo "🍏 This job's status is ${{ job.status }}." + + # 打包Linux + build-linux: + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + # 签出代码 + - uses: actions/checkout@v4 + with: + ref: dev + # 设置Flutter环境 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.22.x" + cache: true + # 安装依赖 + - name: Update apt-get + run: sudo apt-get update + - name: Install Dependencies + run: sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libmpv-dev mpv + # 打开Linux Desktop支持 + - name: Enable Flutter Desktop + run: flutter config --enable-linux-desktop + # 更新Flutter的packages + - name: Restore Packages + run: | + cd simple_live_app + flutter pub get + # 设置flutter_distributor环境 + - name: Install flutter_distributor + run: dart pub global activate flutter_distributor + # build Linux ZIP\DMG + - name: Build Linux + run: | + cd simple_live_app + flutter_distributor package --platform linux --targets deb,zip --skip-clean + # 上传Linux包至Artifacts + - name: Upload Linux APP to Artifacts + uses: actions/upload-artifact@v4 + with: + name: linux + path: | + simple_live_app/build/dist/*/*.deb + simple_live_app/build/dist/*/*.zip + + # 读取版本信息 + - name: Read version + id: version + uses: juliangruber/read-file-action@v1 + with: + path: assets/app_version.json + - name: Echo version + run: echo "${{ fromJson(steps.version.outputs.content).version }}" + - name: Echo version content + run: echo "${{ fromJson(steps.version.outputs.content).version_desc }}" + + #上传至Release + - name: Upload Release + uses: softprops/action-gh-release@v1 + with: + name: "${{ fromJson(steps.version.outputs.content).version }}" + body: "${{ fromJson(steps.version.outputs.content).version_desc }}" + prerelease: ${{ fromJson(steps.version.outputs.content).prerelease }} + token: ${{ secrets.TOKEN }} + files: | + simple_live_app/build/dist/*/*.deb + simple_live_app/build/dist/*/*.zip + #完成 + - run: echo "🍏 Linux job's status is ${{ job.status }}." + + # 打包Windows + build-windows: + runs-on: windows-latest + permissions: + contents: write + steps: + # 签出代码 + - uses: actions/checkout@v4 + with: + ref: dev + # 设置Flutter环境 + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.22.x" + cache: true + - name: Enable Flutter Desktop + run: flutter config --enable-windows-desktop + - name: Restore Packages + run: | + cd simple_live_app + flutter pub get + # 设置flutter_distributor环境 + - name: Install flutter_distributor + run: dart pub global activate flutter_distributor + # build Windows ZIP\MSIX + - name: Build Windows + run: | + cd simple_live_app + flutter_distributor package --platform windows --targets msix,zip --skip-clean + + # 上传Windows至Artifacts + - name: Upload Windows APP to Artifacts + uses: actions/upload-artifact@v4 + with: + name: windows + path: | + simple_live_app/build/dist/*/*.msix + simple_live_app/build/dist/*/*.zip + + # 读取版本信息 + - name: Read version + id: version + uses: juliangruber/read-file-action@v1 + with: + path: assets/app_version.json + - name: Echo version + run: echo "${{ fromJson(steps.version.outputs.content).version }}" + - name: Echo version content + run: echo "${{ fromJson(steps.version.outputs.content).version_desc }}" + #上传至Release - name: Upload Release - uses: ncipollo/release-action@v1 + uses: softprops/action-gh-release@v1 with: - allowUpdates: true - artifactErrorsFailBuild: true - artifacts: "simple_live_app/build/app/outputs/flutter-apk/app-x86_64-release.apk,simple_live_app/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk,simple_live_app/build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk,simple_live_app/build/ios/iphoneos/ios_no_sign.ipa" name: "${{ fromJson(steps.version.outputs.content).version }}" body: "${{ fromJson(steps.version.outputs.content).version_desc }}" prerelease: ${{ fromJson(steps.version.outputs.content).prerelease }} token: ${{ secrets.TOKEN }} + files: | + simple_live_app/build/dist/*/*.msix + simple_live_app/build/dist/*/*.zip + #完成 - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file + - run: echo "🍏 Windows job's status is ${{ job.status }}." diff --git a/.github/workflows/publish_tv_app_release.yaml b/.github/workflows/publish_tv_app_release.yaml new file mode 100644 index 00000000..cdd394d3 --- /dev/null +++ b/.github/workflows/publish_tv_app_release.yaml @@ -0,0 +1,93 @@ +name: app-build-action +#推送Tag时触发 +on: + push: + tags: + - "tv_*" +jobs: + build-tv: + runs-on: macos-latest + permissions: + contents: write + steps: + #签出代码 + - uses: actions/checkout@v4 + with: + ref: master + + #APK签名设置 + - name: Download Android keystore + id: android_tv_keystore + uses: timheuer/base64-to-file@v1.2 + with: + fileName: keystore.jks + encodedString: ${{ secrets.TV_KEYSTORE_BASE64 }} + - name: Create key.properties + run: | + echo "storeFile=${{ steps.android_tv_keystore.outputs.filePath }}" > simple_live_tv_app/android/key.properties + echo "storePassword=${{ secrets.TV_STORE_PASSWORD }}" >> simple_live_tv_app/android/key.properties + echo "keyPassword=${{ secrets.TV_KEY_PASSWORD }}" >> simple_live_tv_app/android/key.properties + echo "keyAlias=${{ secrets.TV_KEY_ALIAS }}" >> simple_live_tv_app/android/key.properties + + # 设置JAVA环境 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: "17" + cache: "gradle" + + #设置Flutter + - name: Flutter action + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.22.x' + cache: true + + #更新Flutter的packages + - name: Restore packages + run: | + cd simple_live_tv_app + flutter pub get + + #打包APK + - name: Build APK + run: | + cd simple_live_tv_app + flutter build apk --release --split-per-abi + + #上传APK至Artifacts + - name: Upload APK to Artifacts + uses: actions/upload-artifact@v3 + with: + name: android_tv + path: | + simple_live_tv_app/build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk + simple_live_tv_app/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk + simple_live_tv_app/build/app/outputs/flutter-apk/app-x86_64-release.apk + + #读取版本信息 + - name: Read version + id: version + uses: juliangruber/read-file-action@v1 + with: + path: assets/tv_app_version.json + - name: Echo version + run: echo "${{ fromJson(steps.version.outputs.content).version }}" + - name: Echo version content + run: echo "${{ fromJson(steps.version.outputs.content).version_desc }}" + + #上传至Release + - name: Upload Release + uses: softprops/action-gh-release@v1 + with: + name: "${{ fromJson(steps.version.outputs.content).version }}" + body: "# Android TV \n${{ fromJson(steps.version.outputs.content).version_desc }}" + prerelease: ${{ fromJson(steps.version.outputs.content).prerelease }} + token: ${{ secrets.TOKEN }} + files: | + simple_live_tv_app/build/app/outputs/flutter-apk/app-x86_64-release.apk + simple_live_tv_app/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk + simple_live_tv_app/build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk + + #完成 + - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file diff --git a/assets/app_version.json b/assets/app_version.json index 8b5cdec8..68643e01 100644 --- a/assets/app_version.json +++ b/assets/app_version.json @@ -1,7 +1,7 @@ { - "version": "1.5.3", - "version_num": 10503, - "version_desc": "- 修复虎牙播放中断问题 #339 @lemonfog\n- 支持多端数据同步\n- Linux使用mimalloc防止内存泄漏 #328 @madoka773", + "version": "1.6.0", + "version_num": 10600, + "version_desc": "- 修复MacOS打开同步失败 #351\n- 修复Windows返回时亮度调节至最高 #332\n- 修复虎牙分类加载失败 #366\n- 修复虎牙无法播放问题 #409\n- 修复链接跳转时虚拟导航条显示错误 #373\n- 修复播放器锁定时依旧触发长按事件\n- 支持调整弹幕字重 #372\n- 支持日志记录\n- 支持抖音手机端分享链接解析 #376\n- 支持复制直播间链接\n- 支持滑动删除历史记录 #231\n- 支持自定义视频输出驱动\n- PC页面增加刷新按钮\n- 优化桌面小窗播放\n- 优化关注列表加载\n- 优化直播间加载错误的处理\n- 统一全平台图标,安卓支持主题图标 #140 #112\n- 尝试使用WebView实现抖音搜索 #379", "prerelease":false, "download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases" } \ No newline at end of file diff --git a/assets/tv_app_version.json b/assets/tv_app_version.json index 15ad5f6b..6edbdec2 100644 --- a/assets/tv_app_version.json +++ b/assets/tv_app_version.json @@ -1,7 +1,7 @@ { - "version": "1.0.3", - "version_num": 10003, - "version_desc": "- 修复虎牙播放中断问题\n- 优化使用体验", - "prerelease":false, + "version": "1.0.8", + "version_num": 10008, + "version_desc": "- 修复虎牙播放问题\n- TV增加Banner图标\n- 优化使用体验", + "prerelease":true, "download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases" } \ No newline at end of file diff --git a/simple_live_app/.metadata b/simple_live_app/.metadata index 19d78370..aa80d568 100644 --- a/simple_live_app/.metadata +++ b/simple_live_app/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled. version: - revision: 7048ed95a5ad3e43d697e0c397464193991fc230 + revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 channel: stable project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - base_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - - platform: android - create_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - base_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - - platform: ios - create_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - base_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 - platform: linux - create_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - base_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - - platform: macos - create_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - base_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - - platform: web - create_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - base_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - - platform: windows - create_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 - base_revision: 7048ed95a5ad3e43d697e0c397464193991fc230 + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 # User provided section diff --git a/simple_live_app/android/app/src/main/AndroidManifest.xml b/simple_live_app/android/app/src/main/AndroidManifest.xml index b5e628e9..764bcdda 100644 --- a/simple_live_app/android/app/src/main/AndroidManifest.xml +++ b/simple_live_app/android/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ android:label="Simple Live" android:name="${applicationName}" android:icon="@mipmap/ic_launcher" + android:roundIcon="@mipmap/ic_launcher_round" android:networkSecurityConfig="@xml/network_security_config" android:usesCleartextTraffic="true"> + + + + + + \ No newline at end of file diff --git a/simple_live_app/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/simple_live_app/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..0be1e914 --- /dev/null +++ b/simple_live_app/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index 202541bc..00000000 Binary files a/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 00000000..a16309a5 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..31956ca3 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 00000000..89712599 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-ldpi/ic_launcher.png b/simple_live_app/android/app/src/main/res/mipmap-ldpi/ic_launcher.png deleted file mode 100644 index 4cc13567..00000000 Binary files a/simple_live_app/android/app/src/main/res/mipmap-ldpi/ic_launcher.png and /dev/null differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index f445a06c..00000000 Binary files a/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 00000000..b574906e Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..f83e52f3 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 00000000..0f7b500c Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 2cfc9289..00000000 Binary files a/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 00000000..dbb714f8 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..b4343fc1 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..f25399ac Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 04a5d928..00000000 Binary files a/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 00000000..111d393c Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..6ea46587 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..248ebca3 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index e8c084f0..00000000 Binary files a/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 00000000..278312b9 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..6f376b95 Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ diff --git a/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..f178fa9b Binary files /dev/null and b/simple_live_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/simple_live_app/android/app/src/main/res/values/ic_launcher_background.xml b/simple_live_app/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 00000000..c5d5899f --- /dev/null +++ b/simple_live_app/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/simple_live_app/assets/logo.png b/simple_live_app/assets/logo.png new file mode 100644 index 00000000..7dee286b Binary files /dev/null and b/simple_live_app/assets/logo.png differ diff --git a/simple_live_app/assets/logo_400.png b/simple_live_app/assets/logo_400.png new file mode 100644 index 00000000..39d333bd Binary files /dev/null and b/simple_live_app/assets/logo_400.png differ diff --git a/simple_live_app/assets/logo_circle.png b/simple_live_app/assets/logo_circle.png new file mode 100644 index 00000000..67146d33 Binary files /dev/null and b/simple_live_app/assets/logo_circle.png differ diff --git a/simple_live_app/distribute_options.yaml b/simple_live_app/distribute_options.yaml new file mode 100644 index 00000000..c06aab1c --- /dev/null +++ b/simple_live_app/distribute_options.yaml @@ -0,0 +1 @@ +output: build/dist/ \ No newline at end of file diff --git a/simple_live_app/lib/app/app_style.dart b/simple_live_app/lib/app/app_style.dart index 04715224..58862914 100644 --- a/simple_live_app/lib/app/app_style.dart +++ b/simple_live_app/lib/app/app_style.dart @@ -20,6 +20,7 @@ class AppStyle { static ThemeData lightTheme = ThemeData( colorScheme: AppColors.lightColorScheme, useMaterial3: true, + visualDensity: VisualDensity.standard, appBarTheme: AppBarTheme( //elevation: 0, centerTitle: true, @@ -57,6 +58,7 @@ class AppStyle { static ThemeData darkTheme = ThemeData.dark().copyWith( colorScheme: AppColors.darkColorScheme, + visualDensity: VisualDensity.standard, appBarTheme: AppBarTheme( //elevation: 0, diff --git a/simple_live_app/lib/app/controller/app_settings_controller.dart b/simple_live_app/lib/app/controller/app_settings_controller.dart index d9a10ebb..2b8dfe3e 100644 --- a/simple_live_app/lib/app/controller/app_settings_controller.dart +++ b/simple_live_app/lib/app/controller/app_settings_controller.dart @@ -1,4 +1,7 @@ +import 'dart:io'; + import 'package:simple_live_app/app/constant.dart'; +import 'package:simple_live_app/app/log.dart'; import 'package:simple_live_app/app/sites.dart'; import 'package:simple_live_app/services/local_storage_service.dart'; @@ -38,6 +41,8 @@ class AppSettingsController extends GetxController { .getValue(LocalStorageService.kDanmuTopMargin, 0.0); danmuBottomMargin.value = LocalStorageService.instance .getValue(LocalStorageService.kDanmuBottomMargin, 0.0); + danmuFontWeight.value = LocalStorageService.instance.getValue( + LocalStorageService.kDanmuFontWeight, FontWeight.normal.index); hardwareDecode.value = LocalStorageService.instance .getValue(LocalStorageService.kHardwareDecode, true); @@ -83,6 +88,10 @@ class AppSettingsController extends GetxController { 0, ); + playerVolume.value = LocalStorageService.instance.getValue( + LocalStorageService.kPlayerVolume, + 100.0, + ); pipHideDanmu.value = LocalStorageService.instance .getValue(LocalStorageService.kPIPHideDanmu, true); @@ -98,6 +107,25 @@ class AppSettingsController extends GetxController { playerBufferSize.value = LocalStorageService.instance .getValue(LocalStorageService.kPlayerBufferSize, 32); + logEnable.value = LocalStorageService.instance + .getValue(LocalStorageService.kLogEnable, false); + if (logEnable.value) { + Log.initWriter(); + } + + customPlayerOutput.value = LocalStorageService.instance + .getValue(LocalStorageService.kCustomPlayerOutput, false); + + videoOutputDriver.value = LocalStorageService.instance.getValue( + LocalStorageService.kVideoOutputDriver, + Platform.isAndroid ? "gpu" : "libmpv", + ); + + videoHardwareDecoder.value = LocalStorageService.instance.getValue( + LocalStorageService.kVideoHardwareDecoder, + Platform.isAndroid ? "auto-safe" : "auto", + ); + initSiteSort(); initHomeSort(); super.onInit(); @@ -255,6 +283,13 @@ class AppSettingsController extends GetxController { .setValue(LocalStorageService.kDanmuStrokeWidth, e); } + var danmuFontWeight = FontWeight.normal.index.obs; + void setDanmuFontWeight(int e) { + danmuFontWeight.value = e; + LocalStorageService.instance + .setValue(LocalStorageService.kDanmuFontWeight, e); + } + var qualityLevel = 1.obs; void setQualityLevel(int level) { qualityLevel.value = level; @@ -360,6 +395,15 @@ class AppSettingsController extends GetxController { ); } + Rx playerVolume = 100.0.obs; + void setPlayerVolume(double value) { + playerVolume.value = value; + LocalStorageService.instance.setValue( + LocalStorageService.kPlayerVolume, + value, + ); + } + var pipHideDanmu = true.obs; void setPIPHideDanmu(bool e) { pipHideDanmu.value = e; @@ -398,4 +442,31 @@ class AppSettingsController extends GetxController { LocalStorageService.instance .setValue(LocalStorageService.kBilibiliLoginTip, e); } + + var logEnable = false.obs; + void setLogEnable(bool e) { + logEnable.value = e; + LocalStorageService.instance.setValue(LocalStorageService.kLogEnable, e); + } + + var customPlayerOutput = false.obs; + void setCustomPlayerOutput(bool e) { + customPlayerOutput.value = e; + LocalStorageService.instance + .setValue(LocalStorageService.kCustomPlayerOutput, e); + } + + var videoOutputDriver = "".obs; + void setVideoOutputDriver(String e) { + videoOutputDriver.value = e; + LocalStorageService.instance + .setValue(LocalStorageService.kVideoOutputDriver, e); + } + + var videoHardwareDecoder = "".obs; + void setVideoHardwareDecoder(String e) { + videoHardwareDecoder.value = e; + LocalStorageService.instance + .setValue(LocalStorageService.kVideoHardwareDecoder, e); + } } diff --git a/simple_live_app/lib/app/log.dart b/simple_live_app/lib/app/log.dart index b2b61160..6d54dd87 100644 --- a/simple_live_app/lib/app/log.dart +++ b/simple_live_app/lib/app/log.dart @@ -1,9 +1,30 @@ +import 'dart:io'; + +import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:simple_live_app/app/utils.dart'; class Log { + static LogFileWriter? logFileWriter; + static void initWriter() { + logFileWriter = LogFileWriter(); + } + + static void disposeWriter() { + logFileWriter?.close(); + logFileWriter = null; + } + + static void writeLog(content, [Level level = Level.info]) { + logFileWriter + ?.write("[${level.name.toUpperCase()}] $_currentTime:$content"); + } + static RxList debugLogs = [].obs; static void addDebugLog(String content, Color? color) { @@ -33,33 +54,104 @@ class Log { ), ); - static void d(String message) { + static void d(String message, [bool writeFile = true]) { addDebugLog(message, Colors.orange); logger.d("${DateTime.now().toString()}\n$message"); + if (writeFile) { + writeLog(message, Level.debug); + } } - static void i(String message) { + static void i(String message, [bool writeFile = true]) { addDebugLog(message, Colors.blue); logger.i("${DateTime.now().toString()}\n$message"); + if (writeFile) { + logFileWriter?.write("[INFO] $_currentTime:$message"); + writeLog(message, Level.info); + } } - static void e(String message, StackTrace stackTrace) { + static void e(String message, StackTrace stackTrace, + [bool writeFile = true]) { addDebugLog('$message\r\n\r\n$stackTrace', Colors.red); logger.e("${DateTime.now().toString()}\n$message", stackTrace: stackTrace); + if (writeFile) { + writeLog("$message\n$stackTrace", Level.error); + } } - static void w(String message) { + static void w(String message, [bool writeFile = true]) { addDebugLog(message, Colors.pink); logger.w("${DateTime.now().toString()}\n$message"); + if (writeFile) { + writeLog(message, Level.warning); + } } - static void logPrint(dynamic obj) { + static void logPrint(dynamic obj, [bool writeFile = true]) { addDebugLog(obj.toString(), Colors.red); + if (writeFile) { + writeLog(obj, Level.info); + } //logger.e(obj.toString(), obj, obj?.stackTrace); if (kDebugMode) { print(obj); } } + + static String get _currentTime => Utils.timeFormat.format(DateTime.now()); +} + +class LogFileWriter { + late String fileName; + LogFileWriter() { + var dt = DateFormat("yyyy-MM-dd HH-mm-ss").format(DateTime.now()); + fileName = "$dt.log"; + initFile(); + } + IOSink? fileWriter; + void initFile() async { + var supportDir = await getApplicationSupportDirectory(); + var logDir = Directory("${supportDir.path}/log"); + if (!await logDir.exists()) { + await logDir.create(); + } + var logFile = File("${logDir.path}/$fileName"); + fileWriter = logFile.openWrite(mode: FileMode.append); + writeSystemInfo(); + } + + void write(String content) { + fileWriter?.write(content); + fileWriter?.write("\r\n"); + } + + Future close() async { + await fileWriter?.close(); + } + + void writeSystemInfo() async { + DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); + write("System Info:"); + write("Current Time: ${DateTime.now()}"); + write("Platform: ${Platform.operatingSystem}"); + write("Version: ${Platform.operatingSystemVersion}"); + write("Local: ${Platform.localeName}"); + write( + "App Version: ${Utils.packageInfo.version}+${Utils.packageInfo.buildNumber}"); + if (Platform.isAndroid) { + write((await deviceInfo.androidInfo).data.toString()); + } else if (Platform.isIOS) { + write((await deviceInfo.iosInfo).data.toString()); + } else if (Platform.isLinux) { + write((await deviceInfo.linuxInfo).data.toString()); + } else if (Platform.isMacOS) { + write((await deviceInfo.macOsInfo).data.toString()); + } else if (Platform.isWindows) { + write((await deviceInfo.windowsInfo).data.toString()); + } + write("End System Info"); + } } class DebugLogModel { diff --git a/simple_live_app/lib/app/utils.dart b/simple_live_app/lib/app/utils.dart index 6730adfb..10305dc3 100644 --- a/simple_live_app/lib/app/utils.dart +++ b/simple_live_app/lib/app/utils.dart @@ -19,6 +19,7 @@ class Utils { static late PackageInfo packageInfo; static DateFormat dateFormat = DateFormat("MM-dd HH:mm"); static DateFormat dateFormatWithYear = DateFormat("yyyy-MM-dd HH:mm"); + static DateFormat timeFormat = DateFormat("HH:mm:ss"); /// 处理时间 static String parseTime(DateTime? dt) { @@ -520,10 +521,25 @@ class Utils { } static bool isRegexFormat(String keyword) { - return keyword.startsWith('/') && keyword.endsWith('/') && keyword.length > 2; + return keyword.startsWith('/') && + keyword.endsWith('/') && + keyword.length > 2; } static String removeRegexFormat(String keyword) { return keyword.substring(1, keyword.length - 1); } + + static String parseFileSize(int size) { + if (size < 1024) { + return "$size B"; + } + if (size < 1024 * 1024) { + return "${(size / 1024).toStringAsFixed(2)} KB"; + } + if (size < 1024 * 1024 * 1024) { + return "${(size / 1024 / 1024).toStringAsFixed(2)} MB"; + } + return "${(size / 1024 / 1024 / 1024).toStringAsFixed(2)} GB"; + } } diff --git a/simple_live_app/lib/app/utils/listen_fourth_button.dart b/simple_live_app/lib/app/utils/listen_fourth_button.dart new file mode 100644 index 00000000..a979a74a --- /dev/null +++ b/simple_live_app/lib/app/utils/listen_fourth_button.dart @@ -0,0 +1,35 @@ +import 'package:flutter/gestures.dart'; + +/// 鼠标侧键点击手势识别器 +/// - https://github.com/flutter/flutter/issues/115641 +/// - https://github.com/witnet/my-wit-wallet/pull/261 +class FourthButtonTapGestureRecognizer extends BaseTapGestureRecognizer { + GestureTapDownCallback? onTapDown; + + @override + void handleTapDown({required PointerDownEvent down}) { + final TapDownDetails details = TapDownDetails( + globalPosition: down.position, + localPosition: down.localPosition, + kind: getKindForPointer(down.pointer), + ); + switch (down.buttons) { + case 8: + if (onTapDown != null) { + invokeCallback('onTapDown', () => onTapDown!(details)); + } + break; + default: + } + } + + @override + void handleTapCancel( + {required PointerDownEvent down, + PointerCancelEvent? cancel, + required String reason}) {} + + @override + void handleTapUp( + {required PointerDownEvent down, required PointerUpEvent up}) {} +} diff --git a/simple_live_app/lib/main.dart b/simple_live_app/lib/main.dart index 8e3e81cc..f43dc245 100644 --- a/simple_live_app/lib/main.dart +++ b/simple_live_app/lib/main.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -10,10 +11,12 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:logger/logger.dart'; import 'package:media_kit/media_kit.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:simple_live_app/app/app_style.dart'; import 'package:simple_live_app/app/controller/app_settings_controller.dart'; import 'package:simple_live_app/app/log.dart'; import 'package:simple_live_app/app/utils.dart'; +import 'package:simple_live_app/app/utils/listen_fourth_button.dart'; import 'package:simple_live_app/models/db/follow_user.dart'; import 'package:simple_live_app/models/db/history.dart'; import 'package:simple_live_app/modules/other/debug_log_page.dart'; @@ -25,12 +28,21 @@ import 'package:simple_live_app/services/local_storage_service.dart'; import 'package:simple_live_app/services/sync_service.dart'; import 'package:simple_live_app/widgets/status/app_loadding_widget.dart'; import 'package:simple_live_core/simple_live_core.dart'; +import 'package:window_manager/window_manager.dart'; + +import 'package:path/path.dart' as p; import 'package:dynamic_color/dynamic_color.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); + await migrateData(); + await initWindow(); MediaKit.ensureInitialized(); - await Hive.initFlutter(); + await Hive.initFlutter( + (!Platform.isAndroid && !Platform.isIOS) + ? (await getApplicationSupportDirectory()).path + : null, + ); //初始化服务 await initServices(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); @@ -41,13 +53,90 @@ void main() async { systemNavigationBarColor: Colors.transparent, ); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); - runApp(const MyApp()); } +/// 将Hive数据迁移到Application Support +Future migrateData() async { + if (Platform.isAndroid || Platform.isIOS) { + return; + } + var hiveFileList = [ + "followuser", + //旧版本写错成hostiry了 + "hostiry", + "localstorage", + "danmushield", + ]; + try { + var newDir = await getApplicationSupportDirectory(); + var hiveFile = File(p.join(newDir.path, "followuser.hive")); + if (await hiveFile.exists()) { + return; + } + + var oldDir = await getApplicationDocumentsDirectory(); + for (var element in hiveFileList) { + var oldFile = File(p.join(oldDir.path, "$element.hive")); + if (await oldFile.exists()) { + var fileName = "$element.hive"; + if (element == "hostiry") { + fileName = "history.hive"; + } + await oldFile.copy(p.join(newDir.path, fileName)); + await oldFile.delete(); + } + var lockFile = File(p.join(oldDir.path, "$element.lock")); + if (await lockFile.exists()) { + await lockFile.delete(); + } + } + } catch (e) { + Log.logPrint(e); + } +} + +Future initWindow() async { + if (!(Platform.isMacOS || Platform.isWindows || Platform.isLinux)) { + return; + } + await windowManager.ensureInitialized(); + WindowOptions windowOptions = const WindowOptions( + minimumSize: Size(280, 280), + center: true, + title: "Simple Live", + ); + windowManager.waitUntilReadyToShow(windowOptions, () async { + await windowManager.show(); + await windowManager.focus(); + }); +} + Future initServices() async { + Hive.registerAdapter(FollowUserAdapter()); + Hive.registerAdapter(HistoryAdapter()); + + //包信息 + Utils.packageInfo = await PackageInfo.fromPlatform(); + //本地存储 + Log.d("Init LocalStorage Service"); + await Get.put(LocalStorageService()).init(); + await Get.put(DBService()).init(); + //初始化设置控制器 + Get.put(AppSettingsController()); + + Get.put(BiliBiliAccountService()); + + Get.put(SyncService()); + + initCoreLog(); +} + +void initCoreLog() { //日志信息 - CoreLog.enableLog = !kReleaseMode; + CoreLog.enableLog = + !kReleaseMode || AppSettingsController.instance.logEnable.value; + CoreLog.requestLogType = RequestLogType.short; CoreLog.onPrintLog = (level, msg) { switch (level) { case Level.debug: @@ -66,22 +155,6 @@ Future initServices() async { Log.logPrint(msg); } }; - - Hive.registerAdapter(FollowUserAdapter()); - Hive.registerAdapter(HistoryAdapter()); - - //包信息 - Utils.packageInfo = await PackageInfo.fromPlatform(); - //本地存储 - Log.d("Init LocalStorage Service"); - await Get.put(LocalStorageService()).init(); - await Get.put(DBService()).init(); - //初始化设置控制器 - Get.put(AppSettingsController()); - - Get.put(BiliBiliAccountService()); - - Get.put(SyncService()); } class MyApp extends StatelessWidget { @@ -89,9 +162,8 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - bool isDynamicColor = Get.find().isDynamic.value; - Color styleColor = - Color(Get.find().styleColor.value); + bool isDynamicColor = AppSettingsController.instance.isDynamic.value; + Color styleColor = Color(AppSettingsController.instance.styleColor.value); return DynamicColorBuilder( builder: ((ColorScheme? lightDynamic, ColorScheme? darkDynamic) { ColorScheme? lightColorScheme; @@ -125,6 +197,7 @@ class MyApp extends StatelessWidget { supportedLocales: const [Locale("zh", "CN")], logWriterCallback: (text, {bool? isError}) { Log.addDebugLog(text, (isError ?? false) ? Colors.red : Colors.grey); + Log.writeLog(text, (isError ?? false) ? Level.error : Level.info); }, //debugShowCheckedModeBanner: false, navigatorObservers: [FlutterSmartDialog.observer], @@ -132,12 +205,51 @@ class MyApp extends StatelessWidget { loadingBuilder: ((msg) => const AppLoaddingWidget()), //字体大小不跟随系统变化 builder: (context, child) => MediaQuery( - data: MediaQuery.of(context).copyWith( - textScaler: const TextScaler.linear(1.0), - ), + data: MediaQuery.of(context) + .copyWith(textScaler: const TextScaler.linear(1.0)), child: Stack( children: [ - child!, + //侧键返回 + RawGestureDetector( + excludeFromSemantics: true, + gestures: { + FourthButtonTapGestureRecognizer: + GestureRecognizerFactoryWithHandlers< + FourthButtonTapGestureRecognizer>( + () => FourthButtonTapGestureRecognizer(), + (FourthButtonTapGestureRecognizer instance) { + instance.onTapDown = (TapDownDetails details) async { + //如果处于全屏状态,退出全屏 + if (!Platform.isAndroid && !Platform.isIOS) { + if (await windowManager.isFullScreen()) { + await windowManager.setFullScreen(false); + return; + } + } + Get.back(); + }; + }, + ), + }, + child: KeyboardListener( + focusNode: FocusNode(), + onKeyEvent: (KeyEvent event) async { + if (event is KeyDownEvent && + event.logicalKey == LogicalKeyboardKey.escape) { + // ESC退出全屏 + // 如果处于全屏状态,退出全屏 + if (!Platform.isAndroid && !Platform.isIOS) { + if (await windowManager.isFullScreen()) { + await windowManager.setFullScreen(false); + return; + } + } + } + }, + child: child!, + ), + ), + //查看DEBUG日志按钮 //只在Debug、Profile模式显示 Visibility( diff --git a/simple_live_app/lib/modules/categoty_detail/category_detail_page.dart b/simple_live_app/lib/modules/categoty_detail/category_detail_page.dart index a19119b6..8aea5079 100644 --- a/simple_live_app/lib/modules/categoty_detail/category_detail_page.dart +++ b/simple_live_app/lib/modules/categoty_detail/category_detail_page.dart @@ -12,7 +12,7 @@ class CategoryDetailPage extends GetView { @override Widget build(BuildContext context) { - var c = MediaQuery.of(context).size.width ~/ 180; + var c = MediaQuery.of(context).size.width ~/ 200; if (c < 2) { c = 2; } diff --git a/simple_live_app/lib/modules/home/home_list_view.dart b/simple_live_app/lib/modules/home/home_list_view.dart index 283d1d8b..de2a18a8 100644 --- a/simple_live_app/lib/modules/home/home_list_view.dart +++ b/simple_live_app/lib/modules/home/home_list_view.dart @@ -13,7 +13,7 @@ class HomeListView extends StatelessWidget { HomeListController get controller => Get.find(tag: tag); @override Widget build(BuildContext context) { - var c = MediaQuery.of(context).size.width ~/ 180; + var c = MediaQuery.of(context).size.width ~/ 200; if (c < 2) { c = 2; } diff --git a/simple_live_app/lib/modules/live_room/live_room_controller.dart b/simple_live_app/lib/modules/live_room/live_room_controller.dart index 4a6cec6e..ea7e6621 100644 --- a/simple_live_app/lib/modules/live_room/live_room_controller.dart +++ b/simple_live_app/lib/modules/live_room/live_room_controller.dart @@ -98,6 +98,10 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { /// 是否处于后台 var isBackground = false; + /// 直播间加载失败 + var loadError = false.obs; + Error? error; + @override void onInit() { WidgetsBinding.instance.addObserver(this); @@ -272,9 +276,35 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { void loadData() async { try { SmartDialog.showLoading(msg: ""); - + loadError.value = false; addSysMsg("正在读取直播间信息"); detail.value = await site.liveSite.getRoomDetail(roomId: roomId); + + if (site.id == Constant.kDouyin) { + // 如果是抖音,且收藏的是Rid,需要转换roomID + if (detail.value!.roomId != roomId) { + var oldId = roomId; + rxRoomId.value = detail.value!.roomId; + if (followed.value) { + // 更新关注列表 + DBService.instance.deleteFollow("${site.id}_$oldId"); + DBService.instance.addFollow( + FollowUser( + id: "${site.id}_$roomId", + roomId: roomId, + siteId: site.id, + userName: detail.value!.userName, + face: detail.value!.userAvatar, + addTime: DateTime.now(), + ), + ); + } else { + followed.value = + DBService.instance.getFollowExist("${site.id}_$roomId"); + } + } + } + getSuperChatMessage(); addHistory(); @@ -290,7 +320,10 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { initDanmau(); liveDanmaku.start(detail.value?.danmakuData); } catch (e) { - SmartDialog.showToast(e.toString()); + Log.logPrint(e); + //SmartDialog.showToast(e.toString()); + loadError.value = true; + error = e as Error; } finally { SmartDialog.dismiss(status: SmartStatus.loading); } @@ -300,6 +333,7 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { void getPlayQualites() async { qualites.clear(); currentQuality = -1; + try { var playQualites = await site.liveSite.getPlayQualites(detail: detail.value!); @@ -333,7 +367,7 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { var qualityLevel = AppSettingsController.instance.qualityLevel.value; try { var connectivityResult = await (Connectivity().checkConnectivity()); - if (connectivityResult == ConnectivityResult.mobile) { + if (connectivityResult.first == ConnectivityResult.mobile) { qualityLevel = AppSettingsController.instance.qualityLevelCellular.value; } @@ -531,6 +565,14 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { Share.share(detail.value!.url); } + void copyUrl() { + if (detail.value == null) { + return; + } + Utils.copyToClipboard(detail.value!.url); + SmartDialog.showToast("已复制直播间链接"); + } + /// 底部打开播放器设置 void showDanmuSettingsSheet() { Utils.showBottomSheet( @@ -550,6 +592,38 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { ); } + void showVolumeSlider(BuildContext targetContext) { + SmartDialog.showAttach( + targetContext: targetContext, + alignment: Alignment.topCenter, + displayTime: const Duration(seconds: 3), + maskColor: const Color(0x00000000), + builder: (context) { + return Container( + decoration: BoxDecoration( + borderRadius: AppStyle.radius12, + color: Theme.of(context).cardColor, + ), + padding: AppStyle.edgeInsetsA4, + child: Obx( + () => SizedBox( + width: 200, + child: Slider( + min: 0, + max: 100, + value: AppSettingsController.instance.playerVolume.value, + onChanged: (newValue) { + player.setVolume(newValue); + AppSettingsController.instance.setPlayerVolume(newValue); + }, + ), + ), + ), + ); + }, + ); + } + void showQualitySheet() { Utils.showBottomSheet( title: "切换清晰度", @@ -891,6 +965,16 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver { loadData(); } + void copyErrorDetail() { + Utils.copyToClipboard('''直播平台:${rxSite.value.name} +房间号:${rxRoomId.value} +错误信息: +${error?.toString()} +---------------- +${error?.stackTrace}'''); + SmartDialog.showToast("已复制错误信息"); + } + @override void didChangeAppLifecycleState(AppLifecycleState state) { super.didChangeAppLifecycleState(state); diff --git a/simple_live_app/lib/modules/live_room/live_room_page.dart b/simple_live_app/lib/modules/live_room/live_room_page.dart index 6e808d24..e87e0151 100644 --- a/simple_live_app/lib/modules/live_room/live_room_page.dart +++ b/simple_live_app/lib/modules/live_room/live_room_page.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:floating/floating.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:lottie/lottie.dart'; import 'package:media_kit_video/media_kit_video.dart'; import 'package:remixicon/remixicon.dart'; import 'package:simple_live_app/app/app_style.dart'; @@ -29,6 +30,60 @@ class LiveRoomPage extends GetView { Widget build(BuildContext context) { final page = Obx( () { + if (controller.loadError.value) { + return Scaffold( + appBar: AppBar( + title: const Text("直播间加载失败"), + ), + body: Padding( + padding: AppStyle.edgeInsetsA12, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + LottieBuilder.asset( + 'assets/lotties/error.json', + height: 140, + repeat: false, + ), + const Text( + "直播间加载失败", + textAlign: TextAlign.center, + ), + AppStyle.vGap4, + Text( + controller.error?.toString() ?? "未知错误", + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle(fontSize: 12, color: Colors.grey), + ), + AppStyle.vGap4, + Text( + "${controller.rxSite.value.id} - ${controller.rxRoomId.value}", + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 12, color: Colors.grey), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton.icon( + onPressed: controller.copyErrorDetail, + icon: const Icon(Remix.file_copy_line), + label: const Text("复制信息"), + ), + TextButton.icon( + onPressed: controller.refreshRoom, + icon: const Icon(Remix.refresh_line), + label: const Text("刷新"), + ), + ], + ) + ], + ), + ), + ); + } if (controller.fullScreenState.value) { return PopScope( canPop: false, @@ -157,6 +212,14 @@ class LiveRoomPage extends GetView { icon: const Icon(Remix.share_line), label: const Text("分享"), ), + TextButton.icon( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 14), + ), + onPressed: controller.copyUrl, + icon: const Icon(Remix.file_copy_line), + label: const Text("复制链接"), + ), ], ), ), @@ -759,13 +822,22 @@ class LiveRoomPage extends GetView { ), ListTile( leading: const Icon(Icons.share_sharp), - title: const Text("分享链接"), + title: const Text("分享直播间"), trailing: const Icon(Icons.chevron_right), onTap: () { Get.back(); controller.share(); }, ), + ListTile( + leading: const Icon(Icons.copy), + title: const Text("复制链接"), + trailing: const Icon(Icons.chevron_right), + onTap: () { + Get.back(); + controller.copyUrl(); + }, + ), ListTile( leading: const Icon(Icons.open_in_new), title: const Text("APP中打开"), diff --git a/simple_live_app/lib/modules/live_room/player/player_controller.dart b/simple_live_app/lib/modules/live_room/player/player_controller.dart index a20fcf45..63b48fb1 100644 --- a/simple_live_app/lib/modules/live_room/player/player_controller.dart +++ b/simple_live_app/lib/modules/live_room/player/player_controller.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'dart:io'; - import 'package:auto_orientation/auto_orientation.dart'; import 'package:device_info_plus/device_info_plus.dart'; +import 'package:file_picker/file_picker.dart'; import 'package:floating/floating.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -20,6 +20,7 @@ import 'package:simple_live_app/app/custom_throttle.dart'; import 'package:simple_live_app/app/log.dart'; import 'package:simple_live_app/app/utils.dart'; import 'package:wakelock_plus/wakelock_plus.dart'; +import 'package:window_manager/window_manager.dart'; mixin PlayerMixin { GlobalKey globalPlayerKey = GlobalKey(); @@ -27,8 +28,11 @@ mixin PlayerMixin { /// 播放器实例 late final player = Player( - configuration: const PlayerConfiguration( + configuration: PlayerConfiguration( title: "Simple Live Player", + logLevel: AppSettingsController.instance.logEnable.value + ? MPVLogLevel.info + : MPVLogLevel.error, // bufferSize: // // media-kit #549 // AppSettingsController.instance.playerBufferSize.value * 1024 * 1024, @@ -38,19 +42,30 @@ mixin PlayerMixin { /// 视频控制器 late final videoController = VideoController( player, - configuration: AppSettingsController.instance.playerCompatMode.value - ? const VideoControllerConfiguration( - vo: 'mediacodec_embed', - hwdec: 'mediacodec', + configuration: AppSettingsController.instance.customPlayerOutput.value + ? VideoControllerConfiguration( + vo: AppSettingsController.instance.videoOutputDriver.value, + hwdec: AppSettingsController.instance.videoHardwareDecoder.value, ) - : VideoControllerConfiguration( - enableHardwareAcceleration: - AppSettingsController.instance.hardwareDecode.value, - androidAttachSurfaceAfterVideoParameters: false, - ), + : AppSettingsController.instance.playerCompatMode.value + ? const VideoControllerConfiguration( + vo: 'mediacodec_embed', + hwdec: 'mediacodec', + ) + : VideoControllerConfiguration( + enableHardwareAcceleration: + AppSettingsController.instance.hardwareDecode.value, + androidAttachSurfaceAfterVideoParameters: false, + ), ); } mixin PlayerStateMixin on PlayerMixin { + ///音量控制条计时器 + Timer? hidevolumeTimer; + + /// 是否进入桌面端小窗 + RxBool smallWindowState = false.obs; + /// 是否显示弹幕 RxBool showDanmakuState = false.obs; @@ -168,6 +183,8 @@ mixin PlayerDanmakuMixin on PlayerStateMixin { duration: AppSettingsController.instance.danmuSpeed.value, opacity: AppSettingsController.instance.danmuOpacity.value, strokeWidth: AppSettingsController.instance.danmuStrokeWidth.value, + fontWeight: FontWeight + .values[AppSettingsController.instance.danmuFontWeight.value], ), ); } @@ -197,7 +214,9 @@ mixin PlayerSystemMixin on PlayerMixin, PlayerStateMixin, PlayerDanmakuMixin { /// 初始化一些系统状态 void initSystem() async { - PerfectVolumeControl.hideUI = true; + if (Platform.isAndroid || Platform.isIOS) { + PerfectVolumeControl.hideUI = true; + } // 屏幕常亮 WakelockPlus.enable(); @@ -221,31 +240,83 @@ mixin PlayerSystemMixin on PlayerMixin, PlayerStateMixin, PlayerDanmakuMixin { ); await setPortraitOrientation(); - await screenBrightness.resetScreenBrightness(); + if (Platform.isAndroid || Platform.isIOS || Platform.isMacOS) { + // 亮度重置,桌面平台可能会报错,暂时不处理桌面平台的亮度 + try { + await screenBrightness.resetScreenBrightness(); + } catch (e) { + Log.logPrint(e); + } + } + await WakelockPlus.disable(); } /// 进入全屏 void enterFullScreen() { fullScreenState.value = true; - //全屏 - SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); - if (!isVertical.value) { - //横屏 - setLandscapeOrientation(); + if (Platform.isAndroid || Platform.isIOS) { + //全屏 + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); + if (!isVertical.value) { + //横屏 + setLandscapeOrientation(); + } + } else { + windowManager.setFullScreen(true); } //danmakuController?.clear(); } /// 退出全屏 void exitFull() { - SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge, - overlays: SystemUiOverlay.values); - setPortraitOrientation(); + if (Platform.isAndroid || Platform.isIOS) { + SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge, + overlays: SystemUiOverlay.values); + setPortraitOrientation(); + } else { + windowManager.setFullScreen(false); + } fullScreenState.value = false; + //danmakuController?.clear(); } + ///小窗模式() + void enterSmallWindow() { + if (!(Platform.isAndroid || Platform.isIOS)) { + fullScreenState.value = true; + smallWindowState.value = true; + windowManager.setTitleBarStyle(TitleBarStyle.hidden); + // 获取视频窗口大小 + var width = player.state.width ?? 16; + var height = player.state.height ?? 9; + + // 横屏还是竖屏 + if (height > width) { + var aspectRatio = width / height; + windowManager.setSize(Size(400, 400 / aspectRatio)); + } else { + var aspectRatio = height / width; + windowManager.setSize(Size(280 / aspectRatio, 280)); + } + + windowManager.setAlwaysOnTop(true); + } + } + + ///退出小窗模式() + void exitSmallWindow() { + if (!(Platform.isAndroid || Platform.isIOS)) { + fullScreenState.value = false; + smallWindowState.value = false; + windowManager.setTitleBarStyle(TitleBarStyle.normal); + windowManager.setSize(const Size(1280, 720)); + windowManager.setAlwaysOnTop(false); + windowManager.setAlignment(Alignment.center); + } + } + /// 设置横屏 Future setLandscapeOrientation() async { if (await beforeIOS16()) { @@ -282,7 +353,7 @@ mixin PlayerSystemMixin on PlayerMixin, PlayerStateMixin, PlayerDanmakuMixin { Future saveScreenshot() async { try { SmartDialog.showLoading(msg: "正在保存截图"); - //检查相册权限 + //检查相册权限,仅iOS需要 var permission = await Utils.checkPhotoPermission(); if (!permission) { SmartDialog.showToast("没有相册权限"); @@ -296,10 +367,28 @@ mixin PlayerSystemMixin on PlayerMixin, PlayerStateMixin, PlayerDanmakuMixin { SmartDialog.dismiss(status: SmartStatus.loading); return; } - await ImageGallerySaver.saveImage( - imageData, - ); - SmartDialog.showToast("已保存截图至相册"); + + if (Platform.isIOS || Platform.isAndroid) { + await ImageGallerySaver.saveImage( + imageData, + ); + SmartDialog.showToast("已保存截图至相册"); + } else { + //选择保存文件夹 + var path = await FilePicker.platform.saveFile( + allowedExtensions: ["jpg"], + type: FileType.image, + fileName: "${DateTime.now().millisecondsSinceEpoch}.jpg", + ); + if (path == null) { + SmartDialog.showToast("取消保存"); + SmartDialog.dismiss(status: SmartStatus.loading); + return; + } + var file = File(path); + await file.writeAsBytes(imageData); + SmartDialog.showToast("已保存截图至${file.path}"); + } } catch (e) { Log.logPrint(e); SmartDialog.showToast("截图失败"); @@ -362,6 +451,30 @@ mixin PlayerGestureControlMixin } } + //桌面端操控 + void onEnter(PointerEnterEvent event) { + if (!showControlsState.value) { + showControls(); + } + } + + void onExit(PointerExitEvent event) { + if (showControlsState.value) { + hideControls(); + } + } + + void onHover(PointerHoverEvent event, BuildContext context) { + final screenHeight = MediaQuery.of(context).size.height; + final targetPosition = screenHeight * 0.25; // 计算屏幕顶部25%的位置 + if (event.position.dy <= targetPosition || + event.position.dy >= targetPosition * 3) { + if (!showControlsState.value) { + showControls(); + } + } + } + /// 双击全屏/退出全屏 void onDoubleTap(TapDownDetails details) { if (lockControlsState.value) { @@ -401,8 +514,12 @@ mixin PlayerGestureControlMixin verticalDragging = true; showGestureTip.value = true; - _currentVolume = await PerfectVolumeControl.volume; - _currentBrightness = await screenBrightness.current; + if (Platform.isAndroid || Platform.isIOS) { + _currentVolume = await PerfectVolumeControl.volume; + } + if (Platform.isAndroid || Platform.isIOS || Platform.isMacOS) { + _currentBrightness = await screenBrightness.current; + } } /// 竖向手势更新 @@ -411,7 +528,9 @@ mixin PlayerGestureControlMixin return; } if (verticalDragging == false) return; - + if (!Platform.isAndroid && !Platform.isIOS) { + return; + } //String text = ""; //double value = 0.0; @@ -512,6 +631,8 @@ class PlayerController extends BaseController void onInit() { initSystem(); initStream(); + //设置音量 + player.setVolume(AppSettingsController.instance.playerVolume.value); super.onInit(); } @@ -524,6 +645,11 @@ class PlayerController extends BaseController void initStream() { _errorSubscription = player.stream.error.listen((event) { Log.d("播放器错误:$event"); + // 跳过无音频输出的错误 + // Could not open/initialize audio device -> no sound. + if (event.contains('no sound.')) { + return; + } //SmartDialog.showToast(event); mediaError(event); }); @@ -537,13 +663,13 @@ class PlayerController extends BaseController Log.d("播放器日志:$event"); }); _widthSubscription = player.stream.width.listen((event) { - Log.w( + Log.d( 'width:$event W:${(player.state.width)} H:${(player.state.height)}'); isVertical.value = (player.state.height ?? 9) > (player.state.width ?? 16); }); _heightSubscription = player.stream.height.listen((event) { - Log.w( + Log.d( 'height:$event W:${(player.state.width)} H:${(player.state.height)}'); isVertical.value = (player.state.height ?? 9) > (player.state.width ?? 16); @@ -657,6 +783,9 @@ class PlayerController extends BaseController @override void onClose() async { Log.w("播放器关闭"); + if (smallWindowState.value) { + exitSmallWindow(); + } disposeStream(); disposeDanmakuController(); await resetSystem(); diff --git a/simple_live_app/lib/modules/live_room/player/player_controls.dart b/simple_live_app/lib/modules/live_room/player/player_controls.dart index 2a0bf142..55bc7625 100644 --- a/simple_live_app/lib/modules/live_room/player/player_controls.dart +++ b/simple_live_app/lib/modules/live_room/player/player_controls.dart @@ -1,6 +1,7 @@ import 'dart:io'; - +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:media_kit_video/media_kit_video.dart'; import 'package:ns_danmaku/ns_danmaku.dart'; @@ -12,6 +13,7 @@ import 'package:simple_live_app/app/utils.dart'; import 'package:simple_live_app/modules/live_room/live_room_controller.dart'; import 'package:simple_live_app/modules/user/danmu_settings_page.dart'; import 'package:simple_live_app/widgets/follow_user_item.dart'; +import 'package:window_manager/window_manager.dart'; Widget playerControls( VideoState videoState, @@ -37,288 +39,334 @@ Widget buildFullControls( LiveRoomController controller, ) { var padding = MediaQuery.of(videoState.context).padding; + GlobalKey volumeButtonkey = GlobalKey(); + return DragToMoveArea( + child: Stack( + children: [ + Container(), + buildDanmuView(videoState, controller), - return Stack( - children: [ - Container(), - buildDanmuView(videoState, controller), - - Center( - child: // 中间 - StreamBuilder( - stream: videoState.widget.controller.player.stream.buffering, - initialData: videoState.widget.controller.player.state.buffering, - builder: (_, s) => Visibility( - visible: s.data ?? false, - child: const Center( - child: CircularProgressIndicator(), + Center( + child: // 中间 + StreamBuilder( + stream: videoState.widget.controller.player.stream.buffering, + initialData: videoState.widget.controller.player.state.buffering, + builder: (_, s) => Visibility( + visible: s.data ?? false, + child: const Center( + child: CircularProgressIndicator(), + ), ), ), ), - ), - Positioned.fill( - child: GestureDetector( - onTap: controller.onTap, - onDoubleTapDown: controller.onDoubleTap, - onLongPress: () { - showFollowUser(controller); - }, - onVerticalDragStart: controller.onVerticalDragStart, - onVerticalDragUpdate: controller.onVerticalDragUpdate, - onVerticalDragEnd: controller.onVerticalDragEnd, - child: Container( - width: double.infinity, - height: double.infinity, - color: Colors.transparent, + Positioned.fill( + child: GestureDetector( + onTap: controller.onTap, + onDoubleTapDown: controller.onDoubleTap, + onLongPress: () { + if (controller.lockControlsState.value) { + return; + } + showFollowUser(controller); + }, + onVerticalDragStart: controller.onVerticalDragStart, + onVerticalDragUpdate: controller.onVerticalDragUpdate, + onVerticalDragEnd: controller.onVerticalDragEnd, + child: MouseRegion( + onHover: (PointerHoverEvent event) { + controller.onHover(event, videoState.context); + }, + child: Container( + width: double.infinity, + height: double.infinity, + color: Colors.transparent, + // child: Visibility( + // //拖拽区域 + // visible: controller.smallWindowState.value, + // child: DragToMoveArea( + // child: Container( + // width: double.infinity, + // height: double.infinity, + // color: Colors.transparent, + // )), + // ), + ), + ), ), ), - ), - // 顶部 - Obx( - () => AnimatedPositioned( - left: 0, - right: 0, - top: (controller.showControlsState.value && - !controller.lockControlsState.value) - ? 0 - : -(48 + padding.top), - duration: const Duration(milliseconds: 200), - child: Container( - height: 48 + padding.top, - padding: EdgeInsets.only( - left: padding.left + 12, - right: padding.right + 12, - top: padding.top, - ), - decoration: const BoxDecoration( - gradient: LinearGradient( - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - colors: [ - Colors.transparent, - Colors.black87, - ], + // 顶部 + Obx( + () => AnimatedPositioned( + left: 0, + right: 0, + top: (controller.showControlsState.value && + !controller.lockControlsState.value) + ? 0 + : -(48 + padding.top), + duration: const Duration(milliseconds: 200), + child: Container( + height: 48 + padding.top, + padding: EdgeInsets.only( + left: padding.left + 12, + right: padding.right + 12, + top: padding.top, ), - ), - child: Row( - children: [ - IconButton( - onPressed: controller.exitFull, - icon: const Icon( - Icons.arrow_back, - color: Colors.white, - size: 24, - ), + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + colors: [ + Colors.transparent, + Colors.black87, + ], ), - AppStyle.hGap12, - Expanded( - child: Text( - "${controller.detail.value?.title} - ${controller.detail.value?.userName}", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(color: Colors.white, fontSize: 16), + ), + child: Row( + children: [ + IconButton( + onPressed: () { + if (controller.smallWindowState.value) { + controller.exitSmallWindow(); + } else { + controller.exitFull(); + } + }, + icon: const Icon( + Icons.arrow_back, + color: Colors.white, + size: 24, + ), ), - ), - AppStyle.hGap12, - IconButton( - onPressed: () { - controller.saveScreenshot(); - }, - icon: const Icon( - Icons.camera_alt_outlined, - color: Colors.white, - size: 24, + AppStyle.hGap12, + Expanded( + child: Text( + "${controller.detail.value?.title} - ${controller.detail.value?.userName}", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle(color: Colors.white, fontSize: 16), + ), ), - ), - IconButton( - onPressed: () { - showFollowUser(controller); - }, - icon: const Icon( - Remix.play_list_2_line, - color: Colors.white, - size: 24, + AppStyle.hGap12, + IconButton( + onPressed: () { + controller.saveScreenshot(); + }, + icon: const Icon( + Icons.camera_alt_outlined, + color: Colors.white, + size: 24, + ), ), - ), - Visibility( - visible: Platform.isAndroid, - child: IconButton( + IconButton( onPressed: () { - controller.enablePIP(); + showFollowUser(controller); }, icon: const Icon( - Icons.picture_in_picture, + Remix.play_list_2_line, color: Colors.white, size: 24, ), ), - ), - IconButton( - onPressed: () { - showPlayerSettings(controller); - }, - icon: const Icon( - Icons.more_horiz, - color: Colors.white, - size: 24, + Visibility( + visible: Platform.isAndroid, + child: IconButton( + onPressed: () { + controller.enablePIP(); + }, + icon: const Icon( + Icons.picture_in_picture, + color: Colors.white, + size: 24, + ), + ), + ), + IconButton( + onPressed: () { + showPlayerSettings(controller); + }, + icon: const Icon( + Icons.more_horiz, + color: Colors.white, + size: 24, + ), ), - ), - ], - ), - ), - ), - ), - // 底部 - Obx( - () => AnimatedPositioned( - left: 0, - right: 0, - bottom: (controller.showControlsState.value && - !controller.lockControlsState.value) - ? 0 - : -(80 + padding.bottom), - duration: const Duration(milliseconds: 200), - child: Container( - decoration: const BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Colors.transparent, - Colors.black87, ], ), ), - padding: EdgeInsets.only( - left: padding.left + 12, - right: padding.right + 12, - bottom: padding.bottom, - ), - child: Row( - children: [ - IconButton( - onPressed: () { - controller.refreshRoom(); - }, - icon: const Icon( - Remix.refresh_line, - color: Colors.white, - ), + ), + ), + // 底部 + Obx( + () => AnimatedPositioned( + left: 0, + right: 0, + bottom: (controller.showControlsState.value && + !controller.lockControlsState.value) + ? 0 + : -(80 + padding.bottom), + duration: const Duration(milliseconds: 200), + child: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.transparent, + Colors.black87, + ], ), - Offstage( - offstage: controller.showDanmakuState.value, - child: IconButton( - onPressed: () => controller.showDanmakuState.value = - !controller.showDanmakuState.value, - icon: const ImageIcon( - AssetImage('assets/icons/icon_danmaku_open.png'), - size: 24, + ), + padding: EdgeInsets.only( + left: padding.left + 12, + right: padding.right + 12, + bottom: padding.bottom, + ), + child: Row( + children: [ + IconButton( + onPressed: () { + controller.refreshRoom(); + }, + icon: const Icon( + Remix.refresh_line, color: Colors.white, ), ), - ), - Offstage( - offstage: !controller.showDanmakuState.value, - child: IconButton( - onPressed: () => controller.showDanmakuState.value = - !controller.showDanmakuState.value, + Offstage( + offstage: controller.showDanmakuState.value, + child: IconButton( + onPressed: () => controller.showDanmakuState.value = + !controller.showDanmakuState.value, + icon: const ImageIcon( + AssetImage('assets/icons/icon_danmaku_open.png'), + size: 24, + color: Colors.white, + ), + ), + ), + Offstage( + offstage: !controller.showDanmakuState.value, + child: IconButton( + onPressed: () => controller.showDanmakuState.value = + !controller.showDanmakuState.value, + icon: const ImageIcon( + AssetImage('assets/icons/icon_danmaku_close.png'), + size: 24, + color: Colors.white, + ), + ), + ), + IconButton( + onPressed: () { + showDanmakuSettings(controller); + }, icon: const ImageIcon( - AssetImage('assets/icons/icon_danmaku_close.png'), + AssetImage('assets/icons/icon_danmaku_setting.png'), size: 24, color: Colors.white, ), ), - ), - IconButton( - onPressed: () { - showDanmakuSettings(controller); - }, - icon: const ImageIcon( - AssetImage('assets/icons/icon_danmaku_setting.png'), - size: 24, - color: Colors.white, + const Expanded(child: Center()), + Visibility( + visible: !Platform.isAndroid && !Platform.isIOS, + child: IconButton( + key: volumeButtonkey, + onPressed: () { + controller + .showVolumeSlider(volumeButtonkey.currentContext!); + }, + icon: const Icon( + Icons.volume_down, + size: 24, + color: Colors.white, + ), + ), ), - ), - const Expanded(child: Center()), - TextButton( - onPressed: () { - showQualitesInfo(controller); - }, - child: Obx( - () => Text( - controller.currentQualityInfo.value, - style: const TextStyle(color: Colors.white, fontSize: 15), + TextButton( + onPressed: () { + showQualitesInfo(controller); + }, + child: Obx( + () => Text( + controller.currentQualityInfo.value, + style: + const TextStyle(color: Colors.white, fontSize: 15), + ), ), ), - ), - TextButton( - onPressed: () { - showLinesInfo(controller); - }, - child: Text( - controller.currentLineInfo.value, - style: const TextStyle(color: Colors.white, fontSize: 15), + TextButton( + onPressed: () { + showLinesInfo(controller); + }, + child: Text( + controller.currentLineInfo.value, + style: const TextStyle(color: Colors.white, fontSize: 15), + ), ), - ), - IconButton( - onPressed: () { - controller.exitFull(); - }, - icon: const Icon( - Remix.fullscreen_exit_fill, - color: Colors.white, + IconButton( + onPressed: () { + if (controller.smallWindowState.value) { + controller.exitSmallWindow(); + } else { + controller.exitFull(); + } + }, + icon: const Icon( + Remix.fullscreen_exit_fill, + color: Colors.white, + ), ), - ), - ], + ], + ), ), ), ), - ), - // 右侧锁定 - Obx( - () => AnimatedPositioned( - top: 0, - bottom: 0, - right: controller.showControlsState.value - ? padding.right + 12 - : -(64 + padding.right), - duration: const Duration(milliseconds: 200), - child: buildLockButton(controller), + // 右侧锁定 + Obx( + () => AnimatedPositioned( + top: 0, + bottom: 0, + right: controller.showControlsState.value + ? padding.right + 12 + : -(64 + padding.right), + duration: const Duration(milliseconds: 200), + child: buildLockButton(controller), + ), ), - ), - // 左侧锁定 - Obx( - () => AnimatedPositioned( - top: 0, - bottom: 0, - left: controller.showControlsState.value - ? padding.left + 12 - : -(64 + padding.right), - duration: const Duration(milliseconds: 200), - child: buildLockButton(controller), + // 左侧锁定 + Obx( + () => AnimatedPositioned( + top: 0, + bottom: 0, + left: controller.showControlsState.value + ? padding.left + 12 + : -(64 + padding.right), + duration: const Duration(milliseconds: 200), + child: buildLockButton(controller), + ), ), - ), - Obx( - () => Offstage( - offstage: !controller.showGestureTip.value, - child: Center( - child: Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.grey.shade900, - borderRadius: BorderRadius.circular(12), - ), - child: Text( - controller.gestureTipText.value, - style: const TextStyle(fontSize: 18, color: Colors.white), + Obx( + () => Offstage( + offstage: !controller.showGestureTip.value, + child: Center( + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey.shade900, + borderRadius: BorderRadius.circular(12), + ), + child: Text( + controller.gestureTipText.value, + style: const TextStyle(fontSize: 18, color: Colors.white), + ), ), ), ), ), - ), - ], + ], + ), ); } @@ -354,6 +402,7 @@ Widget buildControls( VideoState videoState, LiveRoomController controller, ) { + GlobalKey volumeButtonkey = GlobalKey(); return Stack( children: [ Container(), @@ -379,10 +428,13 @@ Widget buildControls( onVerticalDragUpdate: controller.onVerticalDragUpdate, onVerticalDragEnd: controller.onVerticalDragEnd, //onLongPress: controller.showDebugInfo, - child: Container( - width: double.infinity, - height: double.infinity, - color: Colors.transparent, + child: MouseRegion( + onEnter: controller.onEnter, + child: Container( + width: double.infinity, + height: double.infinity, + color: Colors.transparent, + ), ), ), ), @@ -449,6 +501,22 @@ Widget buildControls( ), ), const Expanded(child: Center()), + Visibility( + visible: !Platform.isAndroid && !Platform.isIOS, + child: IconButton( + key: volumeButtonkey, + onPressed: () { + controller.showVolumeSlider( + volumeButtonkey.currentContext!, + ); + }, + icon: const Icon( + Icons.volume_down, + size: 24, + color: Colors.white, + ), + ), + ), Offstage( offstage: isPortrait, child: TextButton( @@ -476,6 +544,19 @@ Widget buildControls( ), ), ), + Visibility( + visible: !Platform.isAndroid && !Platform.isIOS, + child: IconButton( + onPressed: () { + controller.enterSmallWindow(); + }, + icon: const Icon( + Icons.picture_in_picture, + color: Colors.white, + size: 24, + ), + ), + ), IconButton( onPressed: () { controller.enterFullScreen(); diff --git a/simple_live_app/lib/modules/search/douyin/douyin_search_controller.dart b/simple_live_app/lib/modules/search/douyin/douyin_search_controller.dart new file mode 100644 index 00000000..abdb9dd1 --- /dev/null +++ b/simple_live_app/lib/modules/search/douyin/douyin_search_controller.dart @@ -0,0 +1,77 @@ +import 'dart:io'; + +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:get/get.dart'; +import 'package:simple_live_app/app/controller/base_controller.dart'; +import 'package:simple_live_app/app/sites.dart'; +import 'package:simple_live_app/routes/app_navigation.dart'; +import 'package:simple_live_app/routes/route_path.dart'; +import 'package:simple_live_core/simple_live_core.dart'; +import 'package:url_launcher/url_launcher_string.dart'; + +class DouyinSearchController extends BaseController { + InAppWebViewController? webViewController; + + void onWebViewCreated(InAppWebViewController controller) { + webViewController = controller; + } + + RxList list = [].obs; + + String keyword = ""; + + /// 搜索模式,0=直播间,1=主播 + var searchMode = 0.obs; + final Site site; + DouyinSearchController( + this.site, + ); + + var searchUrl = "https://www.douyin.com/search/dnf?type=live"; + + void reloadWebView() { + if (keyword.isEmpty) { + return; + } + searchUrl = + "https://www.douyin.com/search/${Uri.encodeComponent(keyword)}?type=live"; + if (Platform.isAndroid || Platform.isIOS) { + webViewController!.loadUrl( + urlRequest: URLRequest( + url: Uri.parse(searchUrl), + ), + ); + } + } + + void onLoadStop(InAppWebViewController controller, Uri? uri) async { + pageLoadding.value = false; + } + + void onLoadStart(InAppWebViewController controller, Uri? uri) async { + pageLoadding.value = true; + } + + Future onCreateWindow(InAppWebViewController controller, + CreateWindowAction createWindowAction) async { + if (createWindowAction.request.url?.host == "live.douyin.com") { + { + var regExp = RegExp(r"live\.douyin\.com/([\d|\w]+)"); + var id = regExp + .firstMatch(createWindowAction.request.url.toString()) + ?.group(1) ?? + ""; + + AppNavigator.toLiveRoomDetail(site: site, roomId: id); + return false; + } + } + + return false; + } + + void openBrowser() { + launchUrlString(searchUrl); + Get.offAndToNamed(RoutePath.kTools); + } +} diff --git a/simple_live_app/lib/modules/search/douyin/douyin_search_view.dart b/simple_live_app/lib/modules/search/douyin/douyin_search_view.dart new file mode 100644 index 00000000..5953d4af --- /dev/null +++ b/simple_live_app/lib/modules/search/douyin/douyin_search_view.dart @@ -0,0 +1,92 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; + +import 'package:get/get.dart'; +import 'package:simple_live_app/app/app_style.dart'; +import 'package:simple_live_app/modules/search/douyin/douyin_search_controller.dart'; +import 'package:simple_live_app/routes/app_navigation.dart'; +import 'package:simple_live_app/widgets/keep_alive_wrapper.dart'; +import 'package:simple_live_app/widgets/status/app_loadding_widget.dart'; + +class DouyinSearchView extends StatelessWidget { + const DouyinSearchView({Key? key}) : super(key: key); + DouyinSearchController get controller => Get.find(); + + @override + Widget build(BuildContext context) { + var roomRowCount = MediaQuery.of(context).size.width ~/ 200; + if (roomRowCount < 2) roomRowCount = 2; + + var userRowCount = MediaQuery.of(context).size.width ~/ 500; + if (userRowCount < 1) userRowCount = 1; + return KeepAliveWrapper( + child: Stack( + children: [ + SizedBox( + width: double.infinity, + height: double.infinity, + child: Center( + child: Padding( + padding: AppStyle.edgeInsetsA12, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Text( + "暂不支持抖音搜索,请打开浏览器搜索,然后复制直播间链接进行解析", + textAlign: TextAlign.center, + ), + TextButton.icon( + onPressed: controller.openBrowser, + icon: const Icon(Icons.open_in_browser), + label: const Text("打开浏览器"), + ), + ], + ), + ), + ), + ), + if (Platform.isAndroid || Platform.isIOS) + InAppWebView( + onWebViewCreated: controller.onWebViewCreated, + onLoadStop: controller.onLoadStop, + onLoadStart: controller.onLoadStart, + initialOptions: InAppWebViewGroupOptions( + crossPlatform: InAppWebViewOptions( + useOnLoadResource: true, + userAgent: + "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/118.0.0.0", + useShouldOverrideUrlLoading: true, + ), + ), + onCreateWindow: controller.onCreateWindow, + shouldOverrideUrlLoading: + (webController, navigationAction) async { + var uri = navigationAction.request.url; + if (uri == null) { + return NavigationActionPolicy.ALLOW; + } + if (uri.host == "live.douyin.com") { + var regExp = RegExp(r"live\.douyin\.com/([\d|\w]+)"); + var id = regExp.firstMatch(uri.toString())?.group(1) ?? ""; + + AppNavigator.toLiveRoomDetail( + site: controller.site, roomId: id); + return NavigationActionPolicy.CANCEL; + } + return NavigationActionPolicy.ALLOW; + }, + ), + Obx( + () => Visibility( + visible: controller.pageLoadding.value, + child: const AppLoaddingWidget(), + ), + ), + ], + ), + ); + } +} diff --git a/simple_live_app/lib/modules/search/search_controller.dart b/simple_live_app/lib/modules/search/search_controller.dart index b55bd45c..3dca5b0e 100644 --- a/simple_live_app/lib/modules/search/search_controller.dart +++ b/simple_live_app/lib/modules/search/search_controller.dart @@ -3,7 +3,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:simple_live_app/app/constant.dart'; import 'package:simple_live_app/app/sites.dart'; +import 'package:simple_live_app/modules/search/douyin/douyin_search_controller.dart'; import 'package:simple_live_app/modules/search/search_list_controller.dart'; class AppSearchController extends GetxController @@ -23,6 +25,10 @@ class AppSearchController extends GetxController } index = currentIndex; + if (Sites.supportSites[index].id == Constant.kDouyin) { + return; + } + var controller = Get.find(tag: Sites.supportSites[index].id); @@ -41,10 +47,14 @@ class AppSearchController extends GetxController @override void onInit() { for (var site in Sites.supportSites) { - Get.put( - SearchListController(site), - tag: site.id, - ); + if (site.id == Constant.kDouyin) { + Get.put(DouyinSearchController(site)); + } else { + Get.put( + SearchListController(site), + tag: site.id, + ); + } } super.onInit(); @@ -55,14 +65,23 @@ class AppSearchController extends GetxController return; } for (var site in Sites.supportSites) { - var controller = Get.find(tag: site.id); - controller.clear(); - controller.keyword = searchController.text; - controller.searchMode.value = searchMode.value; + if (site.id == Constant.kDouyin) { + var controller = Get.find(); + controller.keyword = searchController.text; + controller.searchMode.value = searchMode.value; + controller.reloadWebView(); + } else { + var controller = Get.find(tag: site.id); + controller.clear(); + controller.keyword = searchController.text; + controller.searchMode.value = searchMode.value; + } + } + if (Sites.supportSites[index].id != Constant.kDouyin) { + var controller = + Get.find(tag: Sites.supportSites[index].id); + controller.refreshData(); } - var controller = - Get.find(tag: Sites.supportSites[index].id); - controller.refreshData(); } @override diff --git a/simple_live_app/lib/modules/search/search_list_view.dart b/simple_live_app/lib/modules/search/search_list_view.dart index d8c2fa40..9e78afe5 100644 --- a/simple_live_app/lib/modules/search/search_list_view.dart +++ b/simple_live_app/lib/modules/search/search_list_view.dart @@ -17,7 +17,7 @@ class SearchListView extends StatelessWidget { Get.find(tag: tag); @override Widget build(BuildContext context) { - var roomRowCount = MediaQuery.of(context).size.width ~/ 180; + var roomRowCount = MediaQuery.of(context).size.width ~/ 200; if (roomRowCount < 2) roomRowCount = 2; var userRowCount = MediaQuery.of(context).size.width ~/ 500; diff --git a/simple_live_app/lib/modules/search/search_page.dart b/simple_live_app/lib/modules/search/search_page.dart index 200794b8..0439e58e 100644 --- a/simple_live_app/lib/modules/search/search_page.dart +++ b/simple_live_app/lib/modules/search/search_page.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:simple_live_app/app/app_style.dart'; +import 'package:simple_live_app/app/constant.dart'; import 'package:simple_live_app/app/sites.dart'; +import 'package:simple_live_app/modules/search/douyin/douyin_search_view.dart'; import 'package:simple_live_app/modules/search/search_controller.dart'; import 'package:simple_live_app/modules/search/search_list_view.dart'; @@ -88,12 +90,15 @@ class SearchPage extends GetView { ), ), body: TabBarView( + physics: const NeverScrollableScrollPhysics(), controller: controller.tabController, children: Sites.supportSites .map( - (e) => SearchListView( - e.id, - ), + (e) => e.id == Constant.kDouyin + ? const DouyinSearchView() + : SearchListView( + e.id, + ), ) .toList(), ), diff --git a/simple_live_app/lib/modules/toolbox/toolbox_controller.dart b/simple_live_app/lib/modules/toolbox/toolbox_controller.dart index cf7815f2..5cf7135d 100644 --- a/simple_live_app/lib/modules/toolbox/toolbox_controller.dart +++ b/simple_live_app/lib/modules/toolbox/toolbox_controller.dart @@ -17,13 +17,20 @@ class ToolBoxController extends GetxController { SmartDialog.showToast("链接不能为空"); return; } + // 隐藏键盘 + FocusManager.instance.primaryFocus?.unfocus(); + var parseResult = await parse(e); if (parseResult.isEmpty && parseResult.first == "") { SmartDialog.showToast("无法解析此链接"); return; } - Site site = parseResult[1]; - AppNavigator.toLiveRoomDetail(site: site, roomId: parseResult.first); + + // 延迟200ms跳转,等待键盘隐藏 + Future.delayed(const Duration(milliseconds: 200), () { + Site site = parseResult[1]; + AppNavigator.toLiveRoomDetail(site: site, roomId: parseResult.first); + }); } void getPlayUrl(String e) async { @@ -133,6 +140,18 @@ class ToolBoxController extends GetxController { return [id, Sites.allSites[Constant.kDouyin]!]; } + if (url.contains("webcast.amemv.com")) { + var regExp = RegExp(r"reflow/(\d+)"); + id = regExp.firstMatch(url)?.group(1) ?? ""; + return [id, Sites.allSites[Constant.kDouyin]!]; + } + if (url.contains("v.douyin.com")) { + var regExp = RegExp(r"http.?://v.douyin.com/[\d\w]+/"); + var u = regExp.firstMatch(url)?.group(0) ?? ""; + var location = await getLocation(u); + return await parse(location); + } + return []; } diff --git a/simple_live_app/lib/modules/toolbox/toolbox_page.dart b/simple_live_app/lib/modules/toolbox/toolbox_page.dart index 20ffc8a6..5831ccd6 100644 --- a/simple_live_app/lib/modules/toolbox/toolbox_page.dart +++ b/simple_live_app/lib/modules/toolbox/toolbox_page.dart @@ -27,6 +27,7 @@ class ToolBoxPage extends GetView { minLines: 3, maxLines: 3, controller: controller.roomJumpToController, + textInputAction: TextInputAction.go, decoration: InputDecoration( border: const OutlineInputBorder(), hintText: "输入或粘贴哔哩哔哩直播/虎牙直播/斗鱼直播/抖音直播的链接", @@ -65,6 +66,7 @@ class ToolBoxPage extends GetView { minLines: 3, maxLines: 3, controller: controller.getUrlController, + textInputAction: TextInputAction.go, decoration: InputDecoration( border: const OutlineInputBorder(), hintText: "输入或粘贴哔哩哔哩直播/虎牙直播/斗鱼直播/抖音直播的链接", @@ -91,6 +93,22 @@ class ToolBoxPage extends GetView { ], ), ), + const Padding( + padding: AppStyle.edgeInsetsV12, + child: SelectableText('''支持以下类型的链接解析: +哔哩哔哩: +https://live.bilibili.com/xxxxx +https://b23.tv/xxxxx +虎牙直播: +https://www.huya.com/xxxxx +斗鱼直播: +https://www.douyu.com/xxxxx +抖音直播: +https://v.douyin.com/xxxxx +https://live.douyin.com/xxxxx +https://webcast.amemv.com/webcast/reflow/xxxxx +''', style: TextStyle(color: Colors.grey)), + ), ], ), ); diff --git a/simple_live_app/lib/modules/user/danmu_settings_page.dart b/simple_live_app/lib/modules/user/danmu_settings_page.dart index d4f8653d..4c41d760 100644 --- a/simple_live_app/lib/modules/user/danmu_settings_page.dart +++ b/simple_live_app/lib/modules/user/danmu_settings_page.dart @@ -133,6 +133,36 @@ class DanmuSettingsView extends GetView { ), ), AppStyle.divider, + Obx( + () => SettingsNumber( + title: "字体粗细", + value: controller.danmuFontWeight.value, + min: 0, + max: 8, + step: 1, + displayValue: [ + "极细", + "很细", + "细", + "正常", + "小粗", + "偏粗", + "粗", + "很粗", + "极粗" + ][controller.danmuFontWeight.value] + .toString(), + onChanged: (e) { + controller.setDanmuFontWeight(e); + updateDanmuOption( + danmakuController?.option.copyWith( + fontWeight: FontWeight.values[e], + ), + ); + }, + ), + ), + AppStyle.divider, Obx( () => SettingsNumber( title: "滚动速度", diff --git a/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart b/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart index 029264b5..942087ac 100644 --- a/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart +++ b/simple_live_app/lib/modules/user/follow_user/follow_user_controller.dart @@ -44,15 +44,22 @@ class FollowUserController extends BasePageController { super.onInit(); } + var updatedCount = 0; + var updating = false.obs; @override Future> getData(int page, int pageSize) { if (page > 1) { return Future.value([]); } var list = DBService.instance.getFollowList(); + updatedCount = 0; + updating.value = true; for (var item in list) { updateLiveStatus(item); } + if (list.isEmpty) { + updating.value = false; + } allList.assignAll(list); return Future.value(list); } @@ -79,10 +86,14 @@ class FollowUserController extends BasePageController { var site = Sites.allSites[item.siteId]!; item.liveStatus.value = (await site.liveSite.getLiveStatus(roomId: item.roomId)) ? 2 : 1; - - filterData(); } catch (e) { Log.logPrint(e); + } finally { + updatedCount++; + if (updatedCount >= list.length) { + filterData(); + updating.value = false; + } } } diff --git a/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart b/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart index 2537c5ec..35a8a477 100644 --- a/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart +++ b/simple_live_app/lib/modules/user/follow_user/follow_user_page.dart @@ -14,7 +14,7 @@ class FollowUserPage extends GetView { @override Widget build(BuildContext context) { - controller.filterMode.value=0; + controller.filterMode.value = 0; var count = MediaQuery.of(context).size.width ~/ 500; if (count < 1) count = 1; return Scaffold( @@ -88,34 +88,61 @@ class FollowUserPage extends GetView { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Padding( - padding: AppStyle.edgeInsetsA12.copyWith(top: 8, bottom: 8), - child: Obx( - () => Wrap( - spacing: 12, - children: [ - FilterButton( - text: "全部", - selected: controller.filterMode.value == 0, - onTap: () { - controller.setFilterMode(0); - }, + padding: AppStyle.edgeInsetsL8, + child: Row( + children: [ + Expanded( + child: Obx( + () => Wrap( + spacing: 12, + children: [ + FilterButton( + text: "全部", + selected: controller.filterMode.value == 0, + onTap: () { + controller.setFilterMode(0); + }, + ), + FilterButton( + text: "直播中", + selected: controller.filterMode.value == 1, + onTap: () { + controller.setFilterMode(1); + }, + ), + FilterButton( + text: "未开播", + selected: controller.filterMode.value == 2, + onTap: () { + controller.setFilterMode(2); + }, + ), + ], + ), ), - FilterButton( - text: "直播中", - selected: controller.filterMode.value == 1, - onTap: () { - controller.setFilterMode(1); - }, - ), - FilterButton( - text: "未开播", - selected: controller.filterMode.value == 2, - onTap: () { - controller.setFilterMode(2); - }, - ), - ], - ), + ), + Obx( + () => controller.updating.value + ? TextButton.icon( + onPressed: null, + icon: const SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + strokeWidth: 2, + ), + ), + label: const Text("更新状态中"), + ) + : TextButton.icon( + onPressed: () { + controller.refreshData(); + }, + icon: const Icon(Icons.refresh), + label: const Text("刷新"), + ), + ), + ], ), ), Expanded( @@ -124,6 +151,7 @@ class FollowUserPage extends GetView { crossAxisCount: count, pageController: controller, //firstRefresh: true, + showPCRefreshButton: false, itemBuilder: (_, i) { var item = controller.list[i]; var site = Sites.allSites[item.siteId]!; diff --git a/simple_live_app/lib/modules/user/history/history_controller.dart b/simple_live_app/lib/modules/user/history/history_controller.dart index cd47e9b0..7ed7ac8d 100644 --- a/simple_live_app/lib/modules/user/history/history_controller.dart +++ b/simple_live_app/lib/modules/user/history/history_controller.dart @@ -22,10 +22,6 @@ class HistoryController extends BasePageController { } void removeItem(History item) async { - var result = await Utils.showAlertDialog("确定要删除此记录吗?", title: "删除记录"); - if (!result) { - return; - } await DBService.instance.historyBox.delete(item.id); refreshData(); } diff --git a/simple_live_app/lib/modules/user/history/history_page.dart b/simple_live_app/lib/modules/user/history/history_page.dart index fbc1c80f..de96f7ef 100644 --- a/simple_live_app/lib/modules/user/history/history_page.dart +++ b/simple_live_app/lib/modules/user/history/history_page.dart @@ -34,46 +34,70 @@ class HistoryPage extends GetView { itemBuilder: (_, i) { var item = controller.list[i]; var site = Sites.allSites[item.siteId]!; - return ListTile( - leading: NetImage( - item.face, - width: 48, - height: 48, - borderRadius: 24, + return Dismissible( + key: ValueKey(item.id), + direction: DismissDirection.endToStart, + background: Container( + color: Colors.red, + padding: AppStyle.edgeInsetsA12, + alignment: Alignment.centerRight, + child: const Icon( + Icons.delete, + color: Colors.white, + ), ), - title: Text(item.userName), - subtitle: Row( - children: [ - Expanded( - child: Row( - children: [ - Image.asset( - site.logo, - width: 20, - ), - AppStyle.hGap4, - Text( - site.name, - style: const TextStyle( - fontSize: 12, - color: Colors.grey, - ), - ), - ], - ), - ), - Text( - Utils.parseTime(item.updateTime), - style: const TextStyle(fontSize: 12, color: Colors.grey), - ), - ], - ), - onTap: () { - AppNavigator.toLiveRoomDetail(site: site, roomId: item.roomId); + confirmDismiss: (direction) async { + return await Utils.showAlertDialog("确定要删除此记录吗?", title: "删除记录"); }, - onLongPress: () { + onDismissed: (_) { controller.removeItem(item); }, + child: ListTile( + leading: NetImage( + item.face, + width: 48, + height: 48, + borderRadius: 24, + ), + title: Text(item.userName), + subtitle: Row( + children: [ + Expanded( + child: Row( + children: [ + Image.asset( + site.logo, + width: 20, + ), + AppStyle.hGap4, + Text( + site.name, + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + ), + ), + ], + ), + ), + Text( + Utils.parseTime(item.updateTime), + style: const TextStyle(fontSize: 12, color: Colors.grey), + ), + ], + ), + onTap: () { + AppNavigator.toLiveRoomDetail(site: site, roomId: item.roomId); + }, + onLongPress: () async { + var result = + await Utils.showAlertDialog("确定要删除此记录吗?", title: "删除记录"); + if (!result) { + return; + } + controller.removeItem(item); + }, + ), ); }, ), diff --git a/simple_live_app/lib/modules/user/other/other_settings_controller.dart b/simple_live_app/lib/modules/user/other/other_settings_controller.dart new file mode 100644 index 00000000..12f99cab --- /dev/null +++ b/simple_live_app/lib/modules/user/other/other_settings_controller.dart @@ -0,0 +1,135 @@ +import 'dart:io'; + +import 'package:file_picker/file_picker.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:get/get.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:share_plus/share_plus.dart'; +import 'package:simple_live_app/app/controller/app_settings_controller.dart'; +import 'package:simple_live_app/app/controller/base_controller.dart'; +import 'package:simple_live_app/app/log.dart'; +import 'package:path/path.dart' as p; + +class OtherSettingsController extends BaseController { + RxList logFiles = [].obs; + + var videoOutputDrivers = { + "gpu": "gpu", + "gpu-next": "gpu-next", + "xv": "xv (X11 only)", + "x11": "x11 (X11 only)", + "vdpau": "vdpau (X11 only)", + "direct3d": "direct3d (Windows only)", + "sdl": "sdl", + "dmabuf-wayland": "dmabuf-wayland", + "vaapi": "vaapi", + "null": "null", + "libmpv": "libmpv", + "mediacodec_embed": "mediacodec_embed (Android only)", + }; + + var hardwareDecoder = { + "no": "no", + "auto": "auto", + "auto-safe": "auto-safe", + "yes": "yes", + "auto-copy": "auto-copy", + "d3d11va": "d3d11va", + "d3d11va-copy": "d3d11va-copy", + "videotoolbox": "videotoolbox", + "videotoolbox-copy": "videotoolbox-copy", + "vaapi": "vaapi", + "vaapi-copy": "vaapi-copy", + "nvdec": "nvdec", + "nvdec-copy": "nvdec-copy", + "drm": "drm", + "drm-copy": "drm-copy", + "vulkan": "vulkan", + "vulkan-copy": "vulkan-copy", + "dxva2": "dxva2", + "dxva2-copy": "dxva2-copy", + "vdpau": "vdpau", + "vdpau-copy": "vdpau-copy", + "mediacodec": "mediacodec", + "mediacodec-copy": "mediacodec-copy", + "cuda": "cuda", + "cuda-copy": "cuda-copy", + "crystalhd": "crystalhd", + "rkmpp": "rkmpp" + }; + + @override + void onInit() { + loadLogFiles(); + super.onInit(); + } + + void setLogEnable(e) { + AppSettingsController.instance.setLogEnable(e); + if (e) { + Log.initWriter(); + Future.delayed(const Duration(milliseconds: 100), () { + loadLogFiles(); + }); + } else { + Log.disposeWriter(); + } + } + + void loadLogFiles() async { + var supportDir = await getApplicationSupportDirectory(); + var logDir = Directory("${supportDir.path}/log"); + if (!await logDir.exists()) { + await logDir.create(); + } + logFiles.clear(); + await logDir.list().forEach((element) { + var file = element as File; + var name = p.basename(file.path); + var time = file.lastModifiedSync(); + var size = file.lengthSync(); + logFiles.add(LogFileModel(name, file.path, time, size)); + }); + //logFiles 名称倒序 + logFiles.sort((a, b) => b.time.compareTo(a.time)); + } + + void cleanLog() async { + if (AppSettingsController.instance.logEnable.value) { + SmartDialog.showToast("请先关闭日志记录"); + return; + } + + var supportDir = await getApplicationSupportDirectory(); + var logDir = Directory("${supportDir.path}/log"); + if (await logDir.exists()) { + await logDir.delete(recursive: true); + } + loadLogFiles(); + } + + void shareLogFile(LogFileModel item) { + Share.shareXFiles([XFile(item.path)]); + } + + void saveLogFile(LogFileModel item) async { + var filePath = await FilePicker.platform.saveFile( + allowedExtensions: ['log'], + type: FileType.custom, + fileName: item.name, + ); + if (filePath != null) { + var file = File(item.path); + await file.copy(filePath); + SmartDialog.showToast("保存成功"); + } + } +} + +class LogFileModel { + late String name; + late String path; + late DateTime time; + late int size; + LogFileModel(this.name, this.path, this.time, this.size); +} diff --git a/simple_live_app/lib/modules/user/other/other_settings_page.dart b/simple_live_app/lib/modules/user/other/other_settings_page.dart new file mode 100644 index 00000000..e334e1db --- /dev/null +++ b/simple_live_app/lib/modules/user/other/other_settings_page.dart @@ -0,0 +1,178 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:simple_live_app/app/app_style.dart'; +import 'package:simple_live_app/app/controller/app_settings_controller.dart'; +import 'package:simple_live_app/app/utils.dart'; +import 'package:simple_live_app/modules/user/other/other_settings_controller.dart'; +import 'package:simple_live_app/widgets/settings/settings_card.dart'; +import 'package:simple_live_app/widgets/settings/settings_menu.dart'; +import 'package:simple_live_app/widgets/settings/settings_switch.dart'; +import 'package:url_launcher/url_launcher_string.dart'; + +class OtherSettingsPage extends GetView { + const OtherSettingsPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("其他设置"), + ), + body: ListView( + padding: AppStyle.edgeInsetsA12, + children: [ + Padding( + padding: AppStyle.edgeInsetsH12, + child: Text( + "播放器高级设置", + style: Get.textTheme.titleSmall, + ), + ), + Padding( + padding: AppStyle.edgeInsetsA12.copyWith(top: 0), + child: Text.rich( + TextSpan( + text: "请勿随意修改以下设置,除非你知道自己在做什么。\n在修改以下设置前,你应该先查阅", + children: [ + WidgetSpan( + child: GestureDetector( + onTap: () { + launchUrlString( + "https://mpv.io/manual/stable/#video-output-drivers"); + }, + child: const Text( + "MPV的文档", + style: TextStyle( + color: Colors.blue, + fontSize: 12, + decoration: TextDecoration.underline, + ), + ), + ), + ), + ], + ), + style: const TextStyle(fontSize: 12, color: Colors.grey), + ), + ), + SettingsCard( + child: Column( + children: [ + Obx( + () => SettingsSwitch( + value: + AppSettingsController.instance.customPlayerOutput.value, + title: "自定义输出驱动与硬件加速", + onChanged: (e) { + AppSettingsController.instance.setCustomPlayerOutput(e); + }, + ), + ), + AppStyle.divider, + Obx( + () => SettingsMenu( + title: "视频输出驱动(--vo)", + value: + AppSettingsController.instance.videoOutputDriver.value, + valueMap: controller.videoOutputDrivers, + onChanged: (e) { + AppSettingsController.instance.setVideoOutputDriver(e); + }, + ), + ), + AppStyle.divider, + Obx( + () => SettingsMenu( + title: "硬件解码器(--hwdec)", + value: AppSettingsController + .instance.videoHardwareDecoder.value, + valueMap: controller.hardwareDecoder, + onChanged: (e) { + AppSettingsController.instance.setVideoHardwareDecoder(e); + }, + ), + ), + ], + ), + ), + Padding( + padding: AppStyle.edgeInsetsA12.copyWith(top: 24), + child: Text( + "日志记录", + style: Get.textTheme.titleSmall, + ), + ), + SettingsCard( + child: Column( + children: [ + Obx( + () => SettingsSwitch( + value: AppSettingsController.instance.logEnable.value, + title: "开启日志记录", + subtitle: "开启后将记录调试日志,可以将日志文件提供给开发者用于排查问题", + onChanged: controller.setLogEnable, + ), + ), + ], + ), + ), + ListTile( + contentPadding: AppStyle.edgeInsetsL12, + visualDensity: VisualDensity.compact, + title: Text( + "日志列表", + style: Get.textTheme.titleSmall, + ), + trailing: TextButton.icon( + onPressed: () { + controller.cleanLog(); + }, + label: const Text("清空日志"), + icon: const Icon(Icons.clear_all), + ), + ), + SettingsCard( + child: SizedBox( + height: 300, + child: Obx( + () => ListView.separated( + itemCount: controller.logFiles.length, + separatorBuilder: (context, index) => AppStyle.divider, + itemBuilder: (context, index) { + var item = controller.logFiles[index]; + return ListTile( + visualDensity: VisualDensity.compact, + contentPadding: AppStyle.edgeInsetsL12.copyWith(right: 4), + title: Text(item.name), + subtitle: Text(Utils.parseFileSize(item.size)), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (!Platform.isLinux) + IconButton( + onPressed: () { + controller.shareLogFile(item); + }, + icon: const Icon(Icons.share), + ), + IconButton( + onPressed: () { + controller.saveLogFile(item); + }, + icon: const Icon(Icons.save), + ), + ], + ), + ); + }, + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/simple_live_app/lib/modules/user/user_page.dart b/simple_live_app/lib/modules/user/user_page.dart index 5b12c3c6..9d8ef331 100644 --- a/simple_live_app/lib/modules/user/user_page.dart +++ b/simple_live_app/lib/modules/user/user_page.dart @@ -182,6 +182,17 @@ class UserPage extends StatelessWidget { Get.toNamed(RoutePath.kSettingsAutoExit); }, ), + ListTile( + leading: const Icon(Remix.apps_line), + title: const Text("其他设置"), + trailing: const Icon( + Icons.chevron_right, + color: Colors.grey, + ), + onTap: () { + Get.toNamed(RoutePath.kSettingsOther); + }, + ), ], ), Divider( diff --git a/simple_live_app/lib/requests/custom_log_interceptor.dart b/simple_live_app/lib/requests/custom_log_interceptor.dart index ed2f8df5..0da6a2bd 100644 --- a/simple_live_app/lib/requests/custom_log_interceptor.dart +++ b/simple_live_app/lib/requests/custom_log_interceptor.dart @@ -1,5 +1,7 @@ import 'package:dio/dio.dart'; +import 'package:flutter/foundation.dart'; import 'package:simple_live_app/app/log.dart'; +import 'package:simple_live_core/simple_live_core.dart'; class CustomLogInterceptor extends Interceptor { @override @@ -13,7 +15,8 @@ class CustomLogInterceptor extends Interceptor { void onError(DioException err, ErrorInterceptorHandler handler) { var time = DateTime.now().millisecondsSinceEpoch - err.requestOptions.extra["ts"]; - Log.e('''【HTTP请求错误-${err.type}】 耗时:${time}ms + if (!kReleaseMode) { + Log.e('''【HTTP请求错误-${err.type}】 耗时:${time}ms ${err.message} Request Method:${err.requestOptions.method} @@ -24,6 +27,20 @@ Request Data:${err.requestOptions.data} Request Headers:${err.requestOptions.headers} Response Headers:${err.response?.headers.map} Response Data:${err.response?.data}''', err.stackTrace); + } else { + CoreLog.e('''[HTTP Error] [${err.type}] [Time:${time}ms] +${err.message} + +Request Method:${err.requestOptions.method} +Response Code:${err.response?.statusCode} +Request URL:${err.requestOptions.uri} +Request Query:${err.requestOptions.queryParameters} +Request Data:${err.requestOptions.data} +Request Headers:${_maskHeader(err.requestOptions.headers)} +Response Headers:${err.response?.headers.map} +Response Data:${err.response?.data}''', err.stackTrace); + } + super.onError(err, handler); } @@ -31,8 +48,9 @@ Response Data:${err.response?.data}''', err.stackTrace); void onResponse(Response response, ResponseInterceptorHandler handler) { var time = DateTime.now().millisecondsSinceEpoch - response.requestOptions.extra["ts"]; - Log.i( - '''【HTTP请求响应】 耗时:${time}ms + if (!kReleaseMode) { + Log.i( + '''【HTTP请求响应】 耗时:${time}ms Request Method:${response.requestOptions.method} Request Code:${response.statusCode} Request URL:${response.requestOptions.uri} @@ -41,7 +59,26 @@ Request Data:${response.requestOptions.data} Request Headers:${response.requestOptions.headers} Response Headers:${response.headers.map} Response Data:${response.data}''', - ); + ); + } else { + CoreLog.i( + "[HTTP Response] [time:${time}ms] [${response.statusCode}] ${response.requestOptions.uri}", + ); + } super.onResponse(response, handler); } + + // Header脱敏 + String _maskHeader(Map header) { + var result = {}; + header.forEach((key, value) { + var k = key.toLowerCase(); + if (k == "cookie" || k == "authorization") { + result[key] = "******"; + } else { + result[key] = value; + } + }); + return result.toString(); + } } diff --git a/simple_live_app/lib/routes/app_pages.dart b/simple_live_app/lib/routes/app_pages.dart index 265fa473..665df838 100644 --- a/simple_live_app/lib/routes/app_pages.dart +++ b/simple_live_app/lib/routes/app_pages.dart @@ -33,6 +33,8 @@ import 'package:simple_live_app/modules/user/history/history_controller.dart'; import 'package:simple_live_app/modules/user/history/history_page.dart'; import 'package:simple_live_app/modules/user/indexed_settings/indexed_settings_controller.dart'; import 'package:simple_live_app/modules/user/indexed_settings/indexed_settings_page.dart'; +import 'package:simple_live_app/modules/user/other/other_settings_controller.dart'; +import 'package:simple_live_app/modules/user/other/other_settings_page.dart'; import 'package:simple_live_app/modules/user/play_settings_page.dart'; import '../modules/indexed/indexed_page.dart'; @@ -192,5 +194,13 @@ class AppPages { ), ], ), + //其他设置 + GetPage( + name: RoutePath.kSettingsOther, + page: () => const OtherSettingsPage(), + bindings: [ + BindingsBuilder.put(() => OtherSettingsController()), + ], + ), ]; } diff --git a/simple_live_app/lib/routes/route_path.dart b/simple_live_app/lib/routes/route_path.dart index eed29559..5a06d958 100644 --- a/simple_live_app/lib/routes/route_path.dart +++ b/simple_live_app/lib/routes/route_path.dart @@ -24,6 +24,9 @@ class RoutePath { /// 弹幕关键词屏蔽 static const kSettingsDanmuShield = "/settings/danmu/shield"; + /// 其他设置 + static const kSettingsOther = "/settings/other"; + /// 赞助 static const kSponsor = "/sponsor"; diff --git a/simple_live_app/lib/services/bilibili_account_service.dart b/simple_live_app/lib/services/bilibili_account_service.dart index 5277f6d9..cf0f7d46 100644 --- a/simple_live_app/lib/services/bilibili_account_service.dart +++ b/simple_live_app/lib/services/bilibili_account_service.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -73,7 +75,10 @@ class BiliBiliAccountService extends GetxService { LocalStorageService.instance .setValue(LocalStorageService.kBilibiliCookie, ""); logined.value = false; - CookieManager cookieManager = CookieManager.instance(); - await cookieManager.deleteAllCookies(); + + if (Platform.isAndroid || Platform.isIOS) { + CookieManager cookieManager = CookieManager.instance(); + await cookieManager.deleteAllCookies(); + } } } diff --git a/simple_live_app/lib/services/db_service.dart b/simple_live_app/lib/services/db_service.dart index da04b380..05ddf2f2 100644 --- a/simple_live_app/lib/services/db_service.dart +++ b/simple_live_app/lib/services/db_service.dart @@ -9,7 +9,7 @@ class DBService extends GetxService { late Box followBox; Future init() async { - historyBox = await Hive.openBox("Hostiry"); + historyBox = await Hive.openBox("History"); followBox = await Hive.openBox("FollowUser"); } diff --git a/simple_live_app/lib/services/local_storage_service.dart b/simple_live_app/lib/services/local_storage_service.dart index 759f536d..0f5404b2 100644 --- a/simple_live_app/lib/services/local_storage_service.dart +++ b/simple_live_app/lib/services/local_storage_service.dart @@ -59,6 +59,9 @@ class LocalStorageService extends GetxService { /// 弹幕开启 static const String kDanmuEnable = "DanmuEnable"; + /// 弹幕字重 + static const String kDanmuFontWeight = "DanmuFontWeight"; + /// 硬件解码 static const String kHardwareDecode = "HardwareDecode"; @@ -99,6 +102,9 @@ class LocalStorageService extends GetxService { /// 自动全屏 static const String kAutoFullScreen = "AutoFullScreen"; + /// 播放器音量 + static const String kPlayerVolume = "PlayerVolume"; + /// 小窗隐藏弹幕 static const String kPIPHideDanmu = "PIPHideDanmu"; @@ -114,6 +120,18 @@ class LocalStorageService extends GetxService { /// 提示哔哩哔哩登录 static const String kBilibiliLoginTip = "BilibiliLoginTip"; + /// 日志记录 + static const String kLogEnable = "LogEnable"; + + /// 开启自定义播放器视频输出 + static const String kCustomPlayerOutput = "CustomPlayerOutput"; + + /// 视频输出驱动 + static const String kVideoOutputDriver = "VideoOutputDriver"; + + /// 视频硬件解码器 + static const String kVideoHardwareDecoder = "VideoHardwareDecoder"; + late Box settingsBox; late Box shieldBox; diff --git a/simple_live_app/lib/widgets/page_grid_view.dart b/simple_live_app/lib/widgets/page_grid_view.dart index 4e677eea..c52544f9 100644 --- a/simple_live_app/lib/widgets/page_grid_view.dart +++ b/simple_live_app/lib/widgets/page_grid_view.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:simple_live_app/app/controller/base_controller.dart'; import 'package:simple_live_app/widgets/status/app_empty_widget.dart'; @@ -16,6 +18,7 @@ class PageGridView extends StatelessWidget { final bool showPageLoadding; final double crossAxisSpacing, mainAxisSpacing; final int crossAxisCount; + final bool showPCRefreshButton; const PageGridView({ required this.itemBuilder, required this.pageController, @@ -25,6 +28,7 @@ class PageGridView extends StatelessWidget { this.onLoginSuccess, this.crossAxisSpacing = 0.0, this.mainAxisSpacing = 0.0, + this.showPCRefreshButton = true, required this.crossAxisCount, Key? key, }) : super(key: key); @@ -55,6 +59,52 @@ class PageGridView extends StatelessWidget { mainAxisSpacing: mainAxisSpacing, ), ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: // 加载更多按钮 + Visibility( + visible: (Platform.isWindows || + Platform.isLinux || + Platform.isMacOS) && + pageController.canLoadMore.value && + !pageController.pageLoadding.value && + !pageController.pageEmpty.value, + child: Center( + child: TextButton( + onPressed: pageController.loadData, + child: const Text("加载更多"), + ), + ), + ), + ), + Positioned( + bottom: 12, + right: 12, + child: // 加载更多按钮 + Visibility( + visible: (Platform.isWindows || + Platform.isLinux || + Platform.isMacOS) && + pageController.canLoadMore.value && + !pageController.pageLoadding.value && + !pageController.pageEmpty.value && + showPCRefreshButton, + child: Center( + child: IconButton( + style: IconButton.styleFrom( + backgroundColor: Get.theme.cardColor.withOpacity(.8), + elevation: 4, + ), + onPressed: () { + pageController.refreshData(); + }, + icon: const Icon(Icons.refresh), + ), + ), + ), + ), Offstage( offstage: !pageController.pageEmpty.value, child: AppEmptyWidget( diff --git a/simple_live_app/lib/widgets/page_list_view.dart b/simple_live_app/lib/widgets/page_list_view.dart index fa0df9c5..8f944061 100644 --- a/simple_live_app/lib/widgets/page_list_view.dart +++ b/simple_live_app/lib/widgets/page_list_view.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:simple_live_app/app/controller/base_controller.dart'; import 'package:simple_live_app/widgets/status/app_empty_widget.dart'; @@ -17,12 +19,14 @@ class PageListView extends StatelessWidget { final bool firstRefresh; final Function()? onLoginSuccess; final bool showPageLoadding; + final bool showPCRefreshButton; const PageListView({ required this.itemBuilder, required this.pageController, this.padding, this.firstRefresh = false, this.showPageLoadding = false, + this.showPCRefreshButton = true, this.separatorBuilder, this.onLoginSuccess, Key? key, @@ -53,6 +57,52 @@ class PageListView extends StatelessWidget { separatorBuilder ?? (context, i) => const SizedBox(), ), ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: // 加载更多按钮 + Visibility( + visible: (Platform.isWindows || + Platform.isLinux || + Platform.isMacOS) && + pageController.canLoadMore.value && + !pageController.pageLoadding.value && + !pageController.pageEmpty.value, + child: Center( + child: TextButton( + onPressed: pageController.loadData, + child: const Text("加载更多"), + ), + ), + ), + ), + Positioned( + bottom: 12, + right: 12, + child: // 加载更多按钮 + Visibility( + visible: (Platform.isWindows || + Platform.isLinux || + Platform.isMacOS) && + pageController.canLoadMore.value && + !pageController.pageLoadding.value && + !pageController.pageEmpty.value && + showPCRefreshButton, + child: Center( + child: IconButton( + style: IconButton.styleFrom( + backgroundColor: Get.theme.cardColor.withOpacity(.8), + elevation: 4, + ), + onPressed: () { + pageController.refreshData(); + }, + icon: const Icon(Icons.refresh), + ), + ), + ), + ), Offstage( offstage: !pageController.pageEmpty.value, child: AppEmptyWidget( diff --git a/simple_live_app/lib/widgets/settings/settings_menu.dart b/simple_live_app/lib/widgets/settings/settings_menu.dart index 2a4c57ee..c548bb98 100644 --- a/simple_live_app/lib/widgets/settings/settings_menu.dart +++ b/simple_live_app/lib/widgets/settings/settings_menu.dart @@ -64,24 +64,26 @@ class SettingsMenu extends StatelessWidget { useSafeArea: true, //useSafeArea似乎无效 builder: (_) => SafeArea( top: false, - child: Column( - mainAxisSize: MainAxisSize.min, - children: valueMap.keys - .map( - (e) => RadioListTile( - value: e, - groupValue: value, - title: Text( - (valueMap[e]?.tr) ?? "???", - style: Get.textTheme.bodyMedium, + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: valueMap.keys + .map( + (e) => RadioListTile( + value: e, + groupValue: value, + title: Text( + (valueMap[e]?.tr) ?? "???", + style: Get.textTheme.bodyMedium, + ), + onChanged: (e) { + Get.back(); + onChanged?.call(e as T); + }, ), - onChanged: (e) { - Get.back(); - onChanged?.call(e as T); - }, - ), - ) - .toList(), + ) + .toList(), + ), ), ), ); diff --git a/simple_live_app/lib/widgets/settings/settings_number.dart b/simple_live_app/lib/widgets/settings/settings_number.dart index b2bca216..da4643ff 100644 --- a/simple_live_app/lib/widgets/settings/settings_number.dart +++ b/simple_live_app/lib/widgets/settings/settings_number.dart @@ -10,6 +10,7 @@ class SettingsNumber extends StatelessWidget { final int step; final int min; final int max; + final String? displayValue; final Function(int)? onChanged; const SettingsNumber( {required this.title, @@ -20,6 +21,7 @@ class SettingsNumber extends StatelessWidget { this.step = 1, this.min = 0, this.unit = '', + this.displayValue, Key? key}) : super(key: key); @@ -68,7 +70,7 @@ class SettingsNumber extends StatelessWidget { ), ), Text( - "$value$unit", + displayValue ?? "$value$unit", textAlign: TextAlign.center, style: Theme.of(context) .textTheme diff --git a/simple_live_app/lib/widgets/settings/settings_switch.dart b/simple_live_app/lib/widgets/settings/settings_switch.dart index 9f411bc8..78f641bf 100644 --- a/simple_live_app/lib/widgets/settings/settings_switch.dart +++ b/simple_live_app/lib/widgets/settings/settings_switch.dart @@ -24,7 +24,7 @@ class SettingsSwitch extends StatelessWidget { shape: RoundedRectangleBorder( borderRadius: AppStyle.radius8, ), - trackOutlineColor: const MaterialStatePropertyAll(Colors.transparent), + trackOutlineColor: const WidgetStatePropertyAll(Colors.transparent), //visualDensity: VisualDensity.compact, contentPadding: AppStyle.edgeInsetsL16.copyWith(right: 8), subtitle: subtitle != null diff --git a/simple_live_app/linux/.gitignore b/simple_live_app/linux/.gitignore new file mode 100644 index 00000000..d3896c98 --- /dev/null +++ b/simple_live_app/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/simple_live_app/linux/CMakeLists.txt b/simple_live_app/linux/CMakeLists.txt new file mode 100644 index 00000000..7e845055 --- /dev/null +++ b/simple_live_app/linux/CMakeLists.txt @@ -0,0 +1,140 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "simple_live_app") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.xycz.simple_live_app") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + +target_link_libraries(${BINARY_NAME} PRIVATE ${MIMALLOC_LIB}) + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/simple_live_app/linux/flutter/CMakeLists.txt b/simple_live_app/linux/flutter/CMakeLists.txt new file mode 100644 index 00000000..d5bd0164 --- /dev/null +++ b/simple_live_app/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/simple_live_app/linux/flutter/generated_plugin_registrant.cc b/simple_live_app/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..a8fa64c7 --- /dev/null +++ b/simple_live_app/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,35 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include +#include +#include + +void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) dynamic_color_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); + dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); + g_autoptr(FlPluginRegistrar) media_kit_libs_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitLibsLinuxPlugin"); + media_kit_libs_linux_plugin_register_with_registrar(media_kit_libs_linux_registrar); + g_autoptr(FlPluginRegistrar) media_kit_video_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitVideoPlugin"); + media_kit_video_plugin_register_with_registrar(media_kit_video_registrar); + g_autoptr(FlPluginRegistrar) screen_retriever_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); + screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); + g_autoptr(FlPluginRegistrar) window_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); + window_manager_plugin_register_with_registrar(window_manager_registrar); +} diff --git a/simple_live_app/linux/flutter/generated_plugin_registrant.h b/simple_live_app/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..e0f0a47b --- /dev/null +++ b/simple_live_app/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/simple_live_app/linux/flutter/generated_plugins.cmake b/simple_live_app/linux/flutter/generated_plugins.cmake new file mode 100644 index 00000000..b0e847d2 --- /dev/null +++ b/simple_live_app/linux/flutter/generated_plugins.cmake @@ -0,0 +1,30 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + dynamic_color + media_kit_libs_linux + media_kit_video + screen_retriever + url_launcher_linux + window_manager +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + media_kit_native_event_loop +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/simple_live_app/linux/main.cc b/simple_live_app/linux/main.cc new file mode 100644 index 00000000..e7c5c543 --- /dev/null +++ b/simple_live_app/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/simple_live_app/linux/my_application.cc b/simple_live_app/linux/my_application.cc new file mode 100644 index 00000000..3e19a893 --- /dev/null +++ b/simple_live_app/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "simple_live_app"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "simple_live_app"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/simple_live_app/linux/my_application.h b/simple_live_app/linux/my_application.h new file mode 100644 index 00000000..72271d5e --- /dev/null +++ b/simple_live_app/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/simple_live_app/linux/packaging/deb/make_config.yaml b/simple_live_app/linux/packaging/deb/make_config.yaml new file mode 100644 index 00000000..9d779393 --- /dev/null +++ b/simple_live_app/linux/packaging/deb/make_config.yaml @@ -0,0 +1,20 @@ +display_name: Simple-Live +package_name: simple-live +maintainer: + name: xiaoyaocz + email: xiaoyaocz@52uwp.com +priority: optional +section: x11 +installed_size: 24400 +essential: false +icon: assets/logo.png + +keywords: + - Simple Live + +generic_name: Simple-Live + +categories: + - Media + +startup_notify: true diff --git a/simple_live_app/macos/.gitignore b/simple_live_app/macos/.gitignore new file mode 100644 index 00000000..746adbb6 --- /dev/null +++ b/simple_live_app/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/simple_live_app/macos/Flutter/Flutter-Debug.xcconfig b/simple_live_app/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 00000000..4b81f9b2 --- /dev/null +++ b/simple_live_app/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/simple_live_app/macos/Flutter/Flutter-Release.xcconfig b/simple_live_app/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 00000000..5caa9d15 --- /dev/null +++ b/simple_live_app/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/simple_live_app/macos/Flutter/GeneratedPluginRegistrant.swift b/simple_live_app/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 00000000..e08e1637 --- /dev/null +++ b/simple_live_app/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,38 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import connectivity_plus +import device_info_plus +import dynamic_color +import media_kit_libs_macos_video +import media_kit_video +import network_info_plus +import package_info_plus +import path_provider_foundation +import screen_brightness_macos +import screen_retriever +import share_plus +import url_launcher_macos +import wakelock_plus +import window_manager + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) + DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) + DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) + MediaKitLibsMacosVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosVideoPlugin")) + MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin")) + NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + ScreenBrightnessMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenBrightnessMacosPlugin")) + ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) + SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) + WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) +} diff --git a/simple_live_app/macos/Podfile b/simple_live_app/macos/Podfile new file mode 100644 index 00000000..c795730d --- /dev/null +++ b/simple_live_app/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/simple_live_app/macos/Podfile.lock b/simple_live_app/macos/Podfile.lock new file mode 100644 index 00000000..9784e9cf --- /dev/null +++ b/simple_live_app/macos/Podfile.lock @@ -0,0 +1,89 @@ +PODS: + - device_info_plus (0.0.1): + - FlutterMacOS + - FlutterMacOS (1.0.0) + - media_kit_libs_macos_video (1.0.4): + - FlutterMacOS + - media_kit_native_event_loop (1.0.0): + - FlutterMacOS + - media_kit_video (0.0.1): + - FlutterMacOS + - package_info_plus (0.0.1): + - FlutterMacOS + - path_provider_foundation (0.0.1): + - Flutter + - FlutterMacOS + - screen_brightness_macos (0.1.0): + - FlutterMacOS + - screen_retriever (0.0.1): + - FlutterMacOS + - share_plus (0.0.1): + - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS + - wakelock_plus (0.0.1): + - FlutterMacOS + - window_manager (0.2.0): + - FlutterMacOS + +DEPENDENCIES: + - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) + - FlutterMacOS (from `Flutter/ephemeral`) + - media_kit_libs_macos_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos`) + - media_kit_native_event_loop (from `Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos`) + - media_kit_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos`) + - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) + - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) + - screen_brightness_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos`) + - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) + - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) + - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) + +EXTERNAL SOURCES: + device_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos + FlutterMacOS: + :path: Flutter/ephemeral + media_kit_libs_macos_video: + :path: Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos + media_kit_native_event_loop: + :path: Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos + media_kit_video: + :path: Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos + package_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos + path_provider_foundation: + :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin + screen_brightness_macos: + :path: Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos + screen_retriever: + :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos + share_plus: + :path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + wakelock_plus: + :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos + window_manager: + :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos + +SPEC CHECKSUMS: + device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f + FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82 + media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5 + media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5 + package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce + path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + screen_brightness_macos: 2d6d3af2165592d9a55ffcd95b7550970e41ebda + screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 + share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 + url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 + window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 + +PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 + +COCOAPODS: 1.11.3 diff --git a/simple_live_app/macos/Runner.xcodeproj/project.pbxproj b/simple_live_app/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..df9ce104 --- /dev/null +++ b/simple_live_app/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,791 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 33E8CA35C15B26E48DA4EBD7 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4C1377411379D99120C8F83 /* Pods_Runner.framework */; }; + 9E6C57AAF7AD9FA590476061 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEF14C9BF8504F57660D2A38 /* Pods_RunnerTests.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 22F821424EC724046ABB4672 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* simple_live_app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = simple_live_app.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 63D7158B8577651B73F3032F /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 7E3E460DBF561AAF73690196 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + AEF14C9BF8504F57660D2A38 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + B51A5741C0A7E288C9368C1A /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + C7907028FBA71F2E559043FF /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + D4C1377411379D99120C8F83 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D9BBDE6BF6193671AE9960B0 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9E6C57AAF7AD9FA590476061 /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 33E8CA35C15B26E48DA4EBD7 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 24357D9109B54496E939BAD5 /* Pods */ = { + isa = PBXGroup; + children = ( + 22F821424EC724046ABB4672 /* Pods-Runner.debug.xcconfig */, + C7907028FBA71F2E559043FF /* Pods-Runner.release.xcconfig */, + B51A5741C0A7E288C9368C1A /* Pods-Runner.profile.xcconfig */, + 63D7158B8577651B73F3032F /* Pods-RunnerTests.debug.xcconfig */, + D9BBDE6BF6193671AE9960B0 /* Pods-RunnerTests.release.xcconfig */, + 7E3E460DBF561AAF73690196 /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + 24357D9109B54496E939BAD5 /* Pods */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* simple_live_app.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + D4C1377411379D99120C8F83 /* Pods_Runner.framework */, + AEF14C9BF8504F57660D2A38 /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 1C0ABA43D8228815BB859BFE /* [CP] Check Pods Manifest.lock */, + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 671FAACF9F58D03A0C709E83 /* [CP] Check Pods Manifest.lock */, + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + A261E453836422CA4D990339 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* simple_live_app.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 1C0ABA43D8228815BB859BFE /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; + 671FAACF9F58D03A0C709E83 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + A261E453836422CA4D990339 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 63D7158B8577651B73F3032F /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.xycz.simpleLiveApp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/simple_live_app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/simple_live_app"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D9BBDE6BF6193671AE9960B0 /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.xycz.simpleLiveApp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/simple_live_app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/simple_live_app"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7E3E460DBF561AAF73690196 /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.xycz.simpleLiveApp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/simple_live_app.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/simple_live_app"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/simple_live_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/simple_live_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/simple_live_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/simple_live_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/simple_live_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..3ea997b7 --- /dev/null +++ b/simple_live_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/simple_live_app/macos/Runner.xcworkspace/contents.xcworkspacedata b/simple_live_app/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..21a3cc14 --- /dev/null +++ b/simple_live_app/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/simple_live_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/simple_live_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/simple_live_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/simple_live_app/macos/Runner/AppDelegate.swift b/simple_live_app/macos/Runner/AppDelegate.swift new file mode 100644 index 00000000..d53ef643 --- /dev/null +++ b/simple_live_app/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..0a856ef5 --- /dev/null +++ b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images": [ + { + "size": "16x16", + "idiom": "mac", + "filename": "icon-16.png", + "scale": "1x" + }, + { + "size": "16x16", + "idiom": "mac", + "filename": "icon-16@2x.png", + "scale": "2x" + }, + { + "size": "32x32", + "idiom": "mac", + "filename": "icon-32.png", + "scale": "1x" + }, + { + "size": "32x32", + "idiom": "mac", + "filename": "icon-32@2x.png", + "scale": "2x" + }, + { + "size": "128x128", + "idiom": "mac", + "filename": "icon-128.png", + "scale": "1x" + }, + { + "size": "128x128", + "idiom": "mac", + "filename": "icon-128@2x.png", + "scale": "2x" + }, + { + "size": "256x256", + "idiom": "mac", + "filename": "icon-256.png", + "scale": "1x" + }, + { + "size": "256x256", + "idiom": "mac", + "filename": "icon-256@2x.png", + "scale": "2x" + }, + { + "size": "512x512", + "idiom": "mac", + "filename": "icon-512.png", + "scale": "1x" + }, + { + "size": "512x512", + "idiom": "mac", + "filename": "icon-512@2x.png", + "scale": "2x" + } + ], + "info": { + "version": 1, + "author": "icon.wuruihong.com" + } +} \ No newline at end of file diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-128.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-128.png new file mode 100644 index 00000000..25dd2e35 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-128.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-128@2x.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-128@2x.png new file mode 100644 index 00000000..e369d99e Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-128@2x.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-16.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-16.png new file mode 100644 index 00000000..bd285432 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-16.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-16@2x.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-16@2x.png new file mode 100644 index 00000000..df9fc2b8 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-16@2x.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-256.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-256.png new file mode 100644 index 00000000..e369d99e Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-256.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-256@2x.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-256@2x.png new file mode 100644 index 00000000..1c46dc73 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-256@2x.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-32.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-32.png new file mode 100644 index 00000000..df9fc2b8 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-32.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-32@2x.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-32@2x.png new file mode 100644 index 00000000..6b168d20 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-32@2x.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-512.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-512.png new file mode 100644 index 00000000..1c46dc73 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-512.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-512@2x.png b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-512@2x.png new file mode 100644 index 00000000..f7833403 Binary files /dev/null and b/simple_live_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/icon-512@2x.png differ diff --git a/simple_live_app/macos/Runner/Assets.xcassets/Contents.json b/simple_live_app/macos/Runner/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/simple_live_app/macos/Runner/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/simple_live_app/macos/Runner/Base.lproj/MainMenu.xib b/simple_live_app/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 00000000..80e867a4 --- /dev/null +++ b/simple_live_app/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/simple_live_app/macos/Runner/Configs/AppInfo.xcconfig b/simple_live_app/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 00000000..873937fe --- /dev/null +++ b/simple_live_app/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = Simple Live + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.xycz.simpleLiveApp + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2023 com.xycz. All rights reserved. diff --git a/simple_live_app/macos/Runner/Configs/Debug.xcconfig b/simple_live_app/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 00000000..36b0fd94 --- /dev/null +++ b/simple_live_app/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/simple_live_app/macos/Runner/Configs/Release.xcconfig b/simple_live_app/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 00000000..dff4f495 --- /dev/null +++ b/simple_live_app/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/simple_live_app/macos/Runner/Configs/Warnings.xcconfig b/simple_live_app/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 00000000..42bcbf47 --- /dev/null +++ b/simple_live_app/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/simple_live_app/macos/Runner/DebugProfile.entitlements b/simple_live_app/macos/Runner/DebugProfile.entitlements new file mode 100644 index 00000000..a900fa66 --- /dev/null +++ b/simple_live_app/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,16 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + com.apple.security.network.client + + com.apple.security.files.user-selected.read-write + + + diff --git a/simple_live_app/macos/Runner/Info.plist b/simple_live_app/macos/Runner/Info.plist new file mode 100644 index 00000000..4789daa6 --- /dev/null +++ b/simple_live_app/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/simple_live_app/macos/Runner/MainFlutterWindow.swift b/simple_live_app/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 00000000..3cc05eb2 --- /dev/null +++ b/simple_live_app/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/simple_live_app/macos/Runner/Release.entitlements b/simple_live_app/macos/Runner/Release.entitlements new file mode 100644 index 00000000..e234a356 --- /dev/null +++ b/simple_live_app/macos/Runner/Release.entitlements @@ -0,0 +1,14 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.server + + + diff --git a/simple_live_app/macos/RunnerTests/RunnerTests.swift b/simple_live_app/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..5418c9f5 --- /dev/null +++ b/simple_live_app/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/simple_live_app/macos/packaging/dmg/make_config.yaml b/simple_live_app/macos/packaging/dmg/make_config.yaml new file mode 100644 index 00000000..e127ba73 --- /dev/null +++ b/simple_live_app/macos/packaging/dmg/make_config.yaml @@ -0,0 +1,10 @@ +title: Simple Live +contents: + - x: 448 + y: 344 + type: link + path: "/Applications" + - x: 192 + y: 344 + type: file + path: Simple Live.app diff --git a/simple_live_app/pubspec.yaml b/simple_live_app/pubspec.yaml index 879c9009..ee44d344 100644 --- a/simple_live_app/pubspec.yaml +++ b/simple_live_app/pubspec.yaml @@ -1,5 +1,5 @@ name: simple_live_app -version: 1.5.3+10503 +version: 1.6.0+10600 publish_to: none description: "Simple Live APP" environment: @@ -14,18 +14,19 @@ dependencies: # 框架、工具 get: ^4.6.6 #状态管理、路由管理、国际化 - dio: ^5.3.2 #网络请求 + dio: ^5.4.3+1 #网络请求 hive: 2.2.3 #持久化存储 hive_flutter: 1.1.0 #持久化存储 logger: ^2.0.2 #日志 - intl: ^0.18.1 #国际化 + intl: ^0.19.0 #国际化 qr_flutter: ^4.1.0 #二维码生成 dynamic_color: ^1.6.8 #动态颜色 + path: any udp: ^5.0.3 #UDP uuid: ^4.3.3 #UUID #Widget - flutter_staggered_grid_view: ^0.6.2 #瀑布流/GridView + flutter_staggered_grid_view: ^0.7.0 #瀑布流/GridView flutter_easyrefresh: 2.2.2 #下拉刷新、上拉加载 extended_image: ^8.2.0 #拓展Image,支持缓存 flutter_smart_dialog: ^4.9.2 #各种弹窗 Toast/Dialog/Popup @@ -34,25 +35,27 @@ dependencies: ns_danmaku: #弹幕 git: url: https://github.com/xiaoyaocz/flutter_ns_danmaku.git - ref: master + tag: v0.0.8 + #系统交互 - package_info_plus: ^4.0.2 #包信息 - device_info_plus: ^9.0.2 #设备信息 - url_launcher: ^6.1.11 #打开链接 - share_plus: ^7.0.2 #分享 - path_provider: ^2.0.15 #常用路径 - cross_file: ^0.3.3+4 #跨平台文件 - permission_handler: ^10.3.0 #权限处理 - image_gallery_saver: ^2.0.2 #图片保存到相册 + package_info_plus: ^8.0.0 #包信息 + device_info_plus: ^10.1.0 #设备信息 + url_launcher: ^6.2.6 #打开链接 + share_plus: ^9.0.0 #分享 + path_provider: ^2.1.3 #常用路径 + cross_file: ^0.3.4+1 #跨平台文件 + permission_handler: ^11.3.1 #权限处理 + image_gallery_saver: ^2.0.3 #图片保存到相册 perfect_volume_control: ^1.0.5 #音量控制 - screen_brightness: ^0.2.2 #亮度控制 + screen_brightness: ^0.2.2+1 #亮度控制 auto_orientation: ^2.3.1 #屏幕方向 - wakelock_plus: ^1.1.1 #屏幕常亮 - file_picker: ^5.3.3 #文件选择 + wakelock_plus: ^1.2.5 #屏幕常亮 + file_picker: ^8.0.3 #文件选择 + window_manager: ^0.3.9 #窗口管理 floating: ^2.0.1 #PIP画中画 flutter_inappwebview: ^5.8.0 #WebView - connectivity_plus: ^5.0.2 #网络状态 + connectivity_plus: ^6.0.3 #网络状态 qr_code_scanner: ^1.0.1 #二维码扫描 # 网络相关 @@ -61,7 +64,7 @@ dependencies: network_info_plus: 3.0.5 # 视频播放 - media_kit: ^1.1.10 + media_kit: ^1.1.10+1 media_kit_video: ^1.2.4 media_kit_libs_video: ^1.0.4 @@ -69,17 +72,24 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - -dependency_overrides: - win32: 3.1.4 + dev_dependencies: flutter_lints: ^2.0.0 build_runner: ^2.3.3 hive_generator: ^2.0.0 + flutter_launcher_icons: ^0.13.1 flutter_test: sdk: flutter +flutter_launcher_icons: + android: true + ios: true + image_path: "assets/logo.png" + min_sdk_android: 21 + macos: + generate: true + flutter: uses-material-design: true assets: diff --git a/simple_live_app/windows/.gitignore b/simple_live_app/windows/.gitignore new file mode 100644 index 00000000..d492d0d9 --- /dev/null +++ b/simple_live_app/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/simple_live_app/windows/CMakeLists.txt b/simple_live_app/windows/CMakeLists.txt new file mode 100644 index 00000000..d83b6530 --- /dev/null +++ b/simple_live_app/windows/CMakeLists.txt @@ -0,0 +1,102 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(simple_live_app LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "simple_live_app") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/simple_live_app/windows/flutter/CMakeLists.txt b/simple_live_app/windows/flutter/CMakeLists.txt new file mode 100644 index 00000000..903f4899 --- /dev/null +++ b/simple_live_app/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/simple_live_app/windows/flutter/generated_plugin_registrant.cc b/simple_live_app/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..a99c1183 --- /dev/null +++ b/simple_live_app/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,44 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + ConnectivityPlusWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + DynamicColorPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); + MediaKitLibsWindowsVideoPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("MediaKitLibsWindowsVideoPluginCApi")); + MediaKitVideoPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi")); + NetworkInfoPlusWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("NetworkInfoPlusWindowsPlugin")); + PermissionHandlerWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); + ScreenBrightnessWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenBrightnessWindowsPlugin")); + ScreenRetrieverPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); + SharePlusWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); + WindowManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowManagerPlugin")); +} diff --git a/simple_live_app/windows/flutter/generated_plugin_registrant.h b/simple_live_app/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..dc139d85 --- /dev/null +++ b/simple_live_app/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/simple_live_app/windows/flutter/generated_plugins.cmake b/simple_live_app/windows/flutter/generated_plugins.cmake new file mode 100644 index 00000000..28028747 --- /dev/null +++ b/simple_live_app/windows/flutter/generated_plugins.cmake @@ -0,0 +1,35 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + connectivity_plus + dynamic_color + media_kit_libs_windows_video + media_kit_video + network_info_plus + permission_handler_windows + screen_brightness_windows + screen_retriever + share_plus + url_launcher_windows + window_manager +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + media_kit_native_event_loop +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/simple_live_app/windows/packaging/msix/make_config.yaml b/simple_live_app/windows/packaging/msix/make_config.yaml new file mode 100644 index 00000000..ca85eb04 --- /dev/null +++ b/simple_live_app/windows/packaging/msix/make_config.yaml @@ -0,0 +1,7 @@ +display_name: Simple Live +publisher_display_name: xiaoyaocz +identity_name: com.xycz.simplelive +logo_path: assets/logo_400.png +capabilities: internetClient +languages: zh-cn +install_certificate: "false" \ No newline at end of file diff --git a/simple_live_app/windows/runner/CMakeLists.txt b/simple_live_app/windows/runner/CMakeLists.txt new file mode 100644 index 00000000..394917c0 --- /dev/null +++ b/simple_live_app/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/simple_live_app/windows/runner/Runner.rc b/simple_live_app/windows/runner/Runner.rc new file mode 100644 index 00000000..f9d9ea25 --- /dev/null +++ b/simple_live_app/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.xycz" "\0" + VALUE "FileDescription", "simple_live_app" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "simple_live_app" "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 com.xycz. All rights reserved." "\0" + VALUE "OriginalFilename", "simple_live_app.exe" "\0" + VALUE "ProductName", "simple_live_app" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/simple_live_app/windows/runner/flutter_window.cpp b/simple_live_app/windows/runner/flutter_window.cpp new file mode 100644 index 00000000..955ee303 --- /dev/null +++ b/simple_live_app/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/simple_live_app/windows/runner/flutter_window.h b/simple_live_app/windows/runner/flutter_window.h new file mode 100644 index 00000000..6da0652f --- /dev/null +++ b/simple_live_app/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/simple_live_app/windows/runner/main.cpp b/simple_live_app/windows/runner/main.cpp new file mode 100644 index 00000000..d38ea712 --- /dev/null +++ b/simple_live_app/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"simple_live_app", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/simple_live_app/windows/runner/resource.h b/simple_live_app/windows/runner/resource.h new file mode 100644 index 00000000..66a65d1e --- /dev/null +++ b/simple_live_app/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/simple_live_app/windows/runner/resources/app_icon.ico b/simple_live_app/windows/runner/resources/app_icon.ico new file mode 100644 index 00000000..e87cfcec Binary files /dev/null and b/simple_live_app/windows/runner/resources/app_icon.ico differ diff --git a/simple_live_app/windows/runner/runner.exe.manifest b/simple_live_app/windows/runner/runner.exe.manifest new file mode 100644 index 00000000..a42ea768 --- /dev/null +++ b/simple_live_app/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/simple_live_app/windows/runner/utils.cpp b/simple_live_app/windows/runner/utils.cpp new file mode 100644 index 00000000..b2b08734 --- /dev/null +++ b/simple_live_app/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length <= 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/simple_live_app/windows/runner/utils.h b/simple_live_app/windows/runner/utils.h new file mode 100644 index 00000000..3879d547 --- /dev/null +++ b/simple_live_app/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/simple_live_app/windows/runner/win32_window.cpp b/simple_live_app/windows/runner/win32_window.cpp new file mode 100644 index 00000000..60608d0f --- /dev/null +++ b/simple_live_app/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/simple_live_app/windows/runner/win32_window.h b/simple_live_app/windows/runner/win32_window.h new file mode 100644 index 00000000..e901dde6 --- /dev/null +++ b/simple_live_app/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/simple_live_core/example/simple_live_core_example.dart b/simple_live_core/example/simple_live_core_example.dart index 040bb496..626809fa 100644 --- a/simple_live_core/example/simple_live_core_example.dart +++ b/simple_live_core/example/simple_live_core_example.dart @@ -2,7 +2,8 @@ import 'package:simple_live_core/simple_live_core.dart'; void main() async { CoreLog.enableLog = true; - LiveSite site = BiliBiliSite(); + CoreLog.requestLogType = RequestLogType.short; + LiveSite site = DouyinSite(); var danmaku = site.getDanmaku(); danmaku.onMessage = (event) { if (event.type == LiveMessageType.chat) { @@ -19,7 +20,7 @@ void main() async { }; //var categores = await site.getCategores(); //print(categores.length); - var detail = await site.getRoomDetail(roomId: "13"); + var detail = await site.getRoomDetail(roomId: "7375009979071236915"); // var playQualites = await site.getPlayQualites(detail: detail); // var playUrls = // await site.getPlayUrls(detail: detail, quality: playQualites.first); diff --git a/simple_live_core/lib/src/common/core_log.dart b/simple_live_core/lib/src/common/core_log.dart index 5a1c45e4..6c6876d0 100644 --- a/simple_live_core/lib/src/common/core_log.dart +++ b/simple_live_core/lib/src/common/core_log.dart @@ -1,7 +1,25 @@ import 'package:logger/logger.dart'; +enum RequestLogType { + /// 输出所有请求信息 + /// 包括请求的URL,请求的参数,请求的头,请求的体,响应的头,响应的内容,耗时 + all, + + /// 简洁的输出 + /// 仅输出请求的URL和响应的状态码 + short, + + /// 不输出请求信息 + none, +} + class CoreLog { + /// 是否启用日志 static bool enableLog = true; + + /// 请求日志模式 + static RequestLogType requestLogType = RequestLogType.all; + static Function(Level, String)? onPrintLog; static Logger logger = Logger( printer: PrettyPrinter( @@ -15,51 +33,57 @@ class CoreLog { ); static void d(String message) { - onPrintLog?.call(Level.debug, message); if (!enableLog) { return; } - logger.d("${DateTime.now().toString()}\n$message"); + onPrintLog?.call(Level.debug, message); + if (onPrintLog == null) { + logger.d("${DateTime.now().toString()}\n$message"); + } } static void i(String message) { - onPrintLog?.call(Level.info, message); if (!enableLog) { return; } - logger.i("${DateTime.now().toString()}\n$message"); + onPrintLog?.call(Level.info, message); + if (onPrintLog == null) { + logger.i("${DateTime.now().toString()}\n$message"); + } } static void e(String message, StackTrace stackTrace) { - onPrintLog?.call(Level.error, message); if (!enableLog) { return; } - logger.e("${DateTime.now().toString()}\n$message", stackTrace: stackTrace); + onPrintLog?.call(Level.error, message); + if (onPrintLog == null) { + logger.e("${DateTime.now().toString()}\n$message", + stackTrace: stackTrace); + } } static void error(e) { - onPrintLog?.call(Level.error, e.toString()); - logger.e( - "${DateTime.now().toString()}\n${e.toString()}", - error: e, - stackTrace: (e is Error) ? e.stackTrace : StackTrace.current, - ); - } - - static void w(String message) { - onPrintLog?.call(Level.warning, message); if (!enableLog) { return; } - logger.w("${DateTime.now().toString()}\n$message"); + onPrintLog?.call(Level.error, e.toString()); + if (onPrintLog == null) { + logger.e( + "${DateTime.now().toString()}\n${e.toString()}", + error: e, + stackTrace: (e is Error) ? e.stackTrace : StackTrace.current, + ); + } } - static void logPrint(dynamic obj) { - onPrintLog?.call(Level.error, obj.toString()); + static void w(String message) { if (!enableLog) { return; } - print(obj); + onPrintLog?.call(Level.warning, message); + if (onPrintLog == null) { + logger.w("${DateTime.now().toString()}\n$message"); + } } } diff --git a/simple_live_core/lib/src/common/custom_interceptor.dart b/simple_live_core/lib/src/common/custom_interceptor.dart index 5b860577..911a06db 100644 --- a/simple_live_core/lib/src/common/custom_interceptor.dart +++ b/simple_live_core/lib/src/common/custom_interceptor.dart @@ -6,6 +6,17 @@ class CustomInterceptor extends Interceptor { @override void onRequest(RequestOptions options, RequestInterceptorHandler handler) { options.extra["ts"] = DateTime.now().millisecondsSinceEpoch; + if (CoreLog.requestLogType == RequestLogType.all) { + CoreLog.i( + '''[HTTP Request] [${options.method}] +Request URL:${options.uri} +Request Query:${options.queryParameters} +Request Data:${options.data} +Request Headers:${options.headers}''', + ); + } else if (CoreLog.requestLogType == RequestLogType.short) { + CoreLog.i("[HTTP Request] [${options.method}] ${options.uri}"); + } super.onRequest(options, handler); } @@ -14,7 +25,8 @@ class CustomInterceptor extends Interceptor { void onError(DioException err, ErrorInterceptorHandler handler) { var time = DateTime.now().millisecondsSinceEpoch - err.requestOptions.extra["ts"]; - CoreLog.e('''【HTTP请求错误-${err.type}】 耗时:${time}ms + if (CoreLog.requestLogType == RequestLogType.all) { + CoreLog.e('''[HTTP Error] [${err.type}] [Time:${time}ms] ${err.message} Request Method:${err.requestOptions.method} @@ -25,6 +37,13 @@ Request Data:${err.requestOptions.data} Request Headers:${err.requestOptions.headers} Response Headers:${err.response?.headers.map} Response Data:${err.response?.data}''', err.stackTrace); + } else { + CoreLog.e( + "[HTTP Error] [${err.type}] [Time:${time}ms]\n[${err.response?.statusCode}] ${err.requestOptions.uri}", + err.stackTrace, + ); + } + super.onError(err, handler); } @@ -32,8 +51,9 @@ Response Data:${err.response?.data}''', err.stackTrace); void onResponse(Response response, ResponseInterceptorHandler handler) { var time = DateTime.now().millisecondsSinceEpoch - response.requestOptions.extra["ts"]; - CoreLog.i( - '''【HTTP请求响应】 耗时:${time}ms + if (CoreLog.requestLogType == RequestLogType.all) { + CoreLog.i( + '''[HTTP Response] [time:${time}ms] Request Method:${response.requestOptions.method} Request Code:${response.statusCode} Request URL:${response.requestOptions.uri} @@ -42,7 +62,12 @@ Request Data:${response.requestOptions.data} Request Headers:${response.requestOptions.headers} Response Headers:${response.headers.map} Response Data:${response.data}''', - ); + ); + } else if (CoreLog.requestLogType == RequestLogType.short) { + CoreLog.i( + "[HTTP Response] [time:${time}ms] [${response.statusCode}] ${response.requestOptions.uri}", + ); + } super.onResponse(response, handler); } } diff --git a/simple_live_core/lib/src/douyin_site.dart b/simple_live_core/lib/src/douyin_site.dart index 4fd43f22..80979165 100644 --- a/simple_live_core/lib/src/douyin_site.dart +++ b/simple_live_core/lib/src/douyin_site.dart @@ -16,7 +16,7 @@ class DouyinSite implements LiveSite { LiveDanmaku getDanmaku() => DouyinDanmaku(); static const String kDefaultUserAgent = - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0"; + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0"; static const String kDefaultReferer = "https://live.douyin.com"; @@ -125,7 +125,7 @@ class DouyinSite implements LiveSite { var items = []; for (var item in result["data"]["data"]) { var roomItem = LiveRoomItem( - roomId: item["web_rid"], + roomId: item["room"]["id_str"].toString(), title: item["room"]["title"].toString(), cover: item["room"]["cover"]["url_list"][0].toString(), userName: item["room"]["owner"]["nickname"].toString(), @@ -159,7 +159,7 @@ class DouyinSite implements LiveSite { var items = []; for (var item in result["data"]["data"]) { var roomItem = LiveRoomItem( - roomId: item["web_rid"], + roomId: item["room"]["id_str"].toString(), title: item["room"]["title"].toString(), cover: item["room"]["cover"]["url_list"][0].toString(), userName: item["room"]["owner"]["nickname"].toString(), @@ -174,64 +174,108 @@ class DouyinSite implements LiveSite { @override Future getRoomDetail({required String roomId}) async { - var detail = await getRoomWebDetail(roomId); - var requestHeader = await getRequestHeaders(); - var webRid = roomId; - var realRoomId = - detail["roomStore"]["roomInfo"]["room"]["id_str"].toString(); - var userUniqueId = detail["userStore"]["odin"]["user_unique_id"].toString(); - var result = await HttpClient.instance.getJson( - "https://live.douyin.com/webcast/room/web/enter/", - queryParameters: { - "aid": 6383, - "app_name": "douyin_web", - "live_id": 1, - "device_platform": "web", - "enter_from": "web_live", - "web_rid": webRid, - "room_id_str": realRoomId, - "enter_source": "", - "Room-Enter-User-Login-Ab": 0, - "is_need_double_stream": false, - "cookie_enabled": true, - "screen_width": 1980, - "screen_height": 1080, - "browser_language": "zh-CN", - "browser_platform": "Win32", - "browser_name": "Edge", - "browser_version": "120.0.0.0" - }, - header: requestHeader, + // 检查roomId是否为webRid + if (roomId.length < 15) { + return await getRoomDetailByWebRid(roomId); + } + + // 读取房间信息 + var roomInfo = await _getRoomInfo(roomId); + + // 通过房间信息获取WebRid + var webRid = roomInfo["data"]["room"]["owner"]["web_rid"].toString(); + + // 读取用户唯一ID,用于弹幕连接 + // 似乎这个参数不是必须的,先随机生成一个 + //var userUniqueId = await _getUserUniqueId(webRid); + var userUniqueId = generateRandomNumber(12).toString(); + + var room = roomInfo["data"]["room"]; + var owner = room["owner"]; + + var roomStatus = (asT(room["status"]) ?? 0) == 2; + + // 主要是为了获取cookie,用于弹幕websocket连接 + var headers = await getRequestHeaders(); + + return LiveRoomDetail( + roomId: roomId, + title: room["title"].toString(), + cover: roomStatus ? room["cover"]["url_list"][0].toString() : "", + userName: owner["nickname"].toString(), + userAvatar: owner["avatar_thumb"]["url_list"][0].toString(), + online: roomStatus + ? asT(room["room_view_stats"]["display_value"]) ?? 0 + : 0, + status: roomStatus, + url: "https://live.douyin.com/$webRid", + introduction: owner["signature"].toString(), + notice: "", + danmakuData: DouyinDanmakuArgs( + webRid: webRid, + roomId: roomId, + userId: userUniqueId, + cookie: headers["cookie"], + ), + data: room["stream_url"], ); - var roomInfo = result["data"]["data"][0]; - var userInfo = result["data"]["user"]; - var roomStatus = (asT(roomInfo["status"]) ?? 0) == 2; + } + + /// 通过webRid获取直播间信息,用于兼容旧版本 + /// - [webRid] 直播间RID + Future getRoomDetailByWebRid(String webRid) async { + var webRoomInfo = await _getWebRoomInfo(webRid); + var roomId = + webRoomInfo["roomStore"]["roomInfo"]["room"]["id_str"].toString(); + var userUniqueId = + webRoomInfo["userStore"]["odin"]["user_unique_id"].toString(); + + var roomInfo = await _getRoomInfo(roomId); + var room = roomInfo["data"]["room"]; + var owner = room["owner"]; + var roomStatus = (asT(room["status"]) ?? 0) == 2; + + // 主要是为了获取cookie,用于弹幕websocket连接 + var headers = await getRequestHeaders(); + return LiveRoomDetail( roomId: roomId, - title: roomInfo["title"].toString(), - cover: roomStatus ? roomInfo["cover"]["url_list"][0].toString() : "", - userName: userInfo["nickname"].toString(), - userAvatar: userInfo["avatar_thumb"]["url_list"][0].toString(), + title: room["title"].toString(), + cover: roomStatus ? room["cover"]["url_list"][0].toString() : "", + userName: owner["nickname"].toString(), + userAvatar: owner["avatar_thumb"]["url_list"][0].toString(), online: roomStatus - ? asT(roomInfo["room_view_stats"]["display_value"]) ?? 0 + ? asT(room["room_view_stats"]["display_value"]) ?? 0 : 0, status: roomStatus, url: "https://live.douyin.com/$webRid", - introduction: roomInfo["title"].toString(), + introduction: owner["signature"].toString(), notice: "", danmakuData: DouyinDanmakuArgs( webRid: webRid, - roomId: realRoomId, + roomId: roomId, userId: userUniqueId, cookie: headers["cookie"], ), - data: roomInfo["stream_url"], + data: room["stream_url"], ); } - Future getRoomWebDetail(String webRid) async { - var headResp = await HttpClient.instance - .head("https://live.douyin.com/$webRid", header: headers); + /// 读取用户名的唯一ID + /// - [webRid] 直播间RID + // ignore: unused_element + Future _getUserUniqueId(String webRid) async { + var webInfo = await _getWebRoomInfo(webRid); + return webInfo["userStore"]["odin"]["user_unique_id"].toString(); + } + + /// 进入直播间前需要先获取cookie + /// - [webRid] 直播间RID + Future _getWebCookie(String webRid) async { + var headResp = await HttpClient.instance.head( + "https://live.douyin.com/$webRid", + header: headers, + ); var dyCookie = ""; headResp.headers["set-cookie"]?.forEach((element) { var cookie = element.split(";")[0]; @@ -242,7 +286,12 @@ class DouyinSite implements LiveSite { dyCookie += "$cookie;"; } }); + return dyCookie; + } + /// 通过webRid获取直播间Web信息 + Future _getWebRoomInfo(String webRid) async { + var dyCookie = await _getWebCookie(webRid); var result = await HttpClient.instance.getText( "https://live.douyin.com/$webRid", queryParameters: {}, @@ -266,9 +315,24 @@ class DouyinSite implements LiveSite { var renderDataJson = json.decode(str); return renderDataJson["state"]; - // return renderDataJson["app"]["initialState"]["roomStore"]["roomInfo"] - // ["room"]["id_str"] - // .toString(); + } + + /// 通过roomId获取直播间信息 + /// - [roomId] 直播间ID + Future _getRoomInfo(String roomId) async { + var result = await HttpClient.instance.getJson( + 'https://webcast.amemv.com/webcast/room/reflow/info/', + queryParameters: { + "type_id": 0, + "live_id": 1, + "room_id": roomId, + "sec_user_id": "", + "version_code": "99.99.99", + "app_id": 1128, + }, + header: await getRequestHeaders(), + ); + return result; } @override @@ -393,8 +457,12 @@ class DouyinSite implements LiveSite { @override Future getLiveStatus({required String roomId}) async { - var result = await getRoomDetail(roomId: roomId); - return result.status; + if (roomId.length < 15) { + var result = await _getWebRoomInfo(roomId); + return result["roomStore"]["roomInfo"]["room"]["status"] == 2; + } + var result = await _getRoomInfo(roomId); + return (asT(result["data"]["room"]["status"]) ?? 0) == 2; } @override @@ -414,6 +482,18 @@ class DouyinSite implements LiveSite { return stringBuffer.toString(); } + // 生成随机的数字 + int generateRandomNumber(int length) { + var random = Random.secure(); + var values = List.generate(length, (i) => random.nextInt(10)); + StringBuffer stringBuffer = StringBuffer(); + for (var item in values) { + stringBuffer.write(item); + } + return int.tryParse(stringBuffer.toString()) ?? + Random().nextInt(1000000000); + } + Future signUrl(String url) async { try { // 发起一个签名请求 diff --git a/simple_live_core/lib/src/huya_site.dart b/simple_live_core/lib/src/huya_site.dart index 55466376..9f7ac303 100644 --- a/simple_live_core/lib/src/huya_site.dart +++ b/simple_live_core/lib/src/huya_site.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'dart:math'; -import 'package:simple_live_core/src/common/convert_helper.dart'; import 'package:simple_live_core/src/common/http_client.dart'; import 'package:simple_live_core/src/danmaku/huya_danmaku.dart'; import 'package:simple_live_core/src/interface/live_danmaku.dart'; @@ -55,7 +54,18 @@ class HuyaSite implements LiveSite { List subs = []; for (var item in result["data"]) { - var gid = (asT(item["gid"])?.toInt() ?? 0).toString(); + var gid = ""; + + if (item["gid"] is Map) { + gid = item["gid"]["value"].toString().split(",").first; + } else if (item["gid"] is double) { + gid = item["gid"].toInt().toString(); + } else if (item["gid"] is int) { + gid = item["gid"].toString(); + } else { + gid = item["gid"].toString(); + } + var subCategory = LiveSubCategory( id: gid, name: item["gameFullName"].toString(), @@ -216,11 +226,20 @@ class HuyaSite implements LiveSite { "user-agent": kUserAgent, }, ); - var text = RegExp(r"window\.HNF_GLOBAL_INIT.=.\{(.*?)\}.", + var text = RegExp( + r"window\.HNF_GLOBAL_INIT.=.\{[\s\S]*?\}[\s\S]*?", multiLine: false) .firstMatch(resultText) - ?.group(1); - var jsonObj = json.decode("{$text}"); + ?.group(0); + var jsonText = text! + .replaceAll(RegExp(r"window\.HNF_GLOBAL_INIT.=."), '') + .replaceAll("", "") + .replaceAllMapped(RegExp(r'function.*?\(.*?\).\{[\s\S]*?\}'), (match) { + return '""'; + }); + + var jsonObj = json.decode(jsonText); + var title = jsonObj["roomInfo"]["tLiveInfo"]["sIntroduction"]?.toString() ?? ""; if (title.isEmpty) { @@ -372,11 +391,18 @@ class HuyaSite implements LiveSite { .getText("https://m.huya.com/$roomId", queryParameters: {}, header: { "user-agent": kUserAgent, }); - var text = RegExp(r"window\.HNF_GLOBAL_INIT.=.\{(.*?)\}.", + var text = RegExp( + r"window\.HNF_GLOBAL_INIT.=.\{[\s\S]*?\}[\s\S]*?", multiLine: false) .firstMatch(resultText) - ?.group(1); - var jsonObj = json.decode("{$text}"); + ?.group(0); + var jsonText = text! + .replaceAll(RegExp(r"window\.HNF_GLOBAL_INIT.=."), '') + .replaceAll("", "") + .replaceAllMapped(RegExp(r'function.*?\(.*?\).\{[\s\S]*?\}'), (match) { + return '""'; + }); + var jsonObj = json.decode(jsonText); return jsonObj["roomInfo"]["eLiveStatus"] == 2; } diff --git a/simple_live_core/pubspec.yaml b/simple_live_core/pubspec.yaml index 6dedadf4..94524c70 100644 --- a/simple_live_core/pubspec.yaml +++ b/simple_live_core/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: brotli: ^0.6.0 dart_tars_protocol: git: https://github.com/xiaoyaocz/dart_tars_protocol.git + fixnum: ^1.1.0 dev_dependencies: lints: ^2.0.0 diff --git a/simple_live_tv_app/android/app/src/main/AndroidManifest.xml b/simple_live_tv_app/android/app/src/main/AndroidManifest.xml index c0b10f4f..54151819 100644 --- a/simple_live_tv_app/android/app/src/main/AndroidManifest.xml +++ b/simple_live_tv_app/android/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ android:label="Simple Live TV" android:name="${applicationName}" android:icon="@mipmap/ic_launcher" + android:banner="@mipmap/ic_banner" android:networkSecurityConfig="@xml/network_security_config" android:usesCleartextTraffic="true"> + android:windowSoftInputMode="adjustResize" + android:banner="@mipmap/ic_banner" + android:screenOrientation="landscape">