Skip to content

Commit

Permalink
fix image
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenDoXiu committed Jan 5, 2025
1 parent 5de190f commit bbcd905
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 28 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/flutter-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ name: 构建发布Flutter应用

on:
push:
paths:
- "pubspec.yaml"
branches:
- main
tags:
- "*"
jobs:
pre-build:
name: 预构建
Expand Down Expand Up @@ -39,7 +37,7 @@ jobs:
build-apk:
name: 编译android
runs-on: ubuntu-latest
needs: [pre-build]
needs: [ pre-build ]
steps:
- name: 设置Flutter环境
uses: subosito/flutter-action@v2
Expand Down Expand Up @@ -81,7 +79,7 @@ jobs:
build-linux:
name: 编译linux
runs-on: ubuntu-latest
needs: [pre-build]
needs: [ pre-build ]
steps:
- name: 拉取代码
uses: actions/checkout@v4
Expand Down Expand Up @@ -120,7 +118,7 @@ jobs:
build-windows:
name: 编译windows
runs-on: windows-latest
needs: [pre-build]
needs: [ pre-build ]
steps:
- name: 拉取代码
uses: actions/checkout@v4
Expand Down Expand Up @@ -157,7 +155,7 @@ jobs:
build-macos:
name: 编译macOS
runs-on: macos-latest
needs: [pre-build]
needs: [ pre-build ]
steps:
- name: 拉取代码
uses: actions/checkout@v4
Expand Down Expand Up @@ -194,7 +192,7 @@ jobs:
release:
name: 上传包
needs: [build-apk, build-linux, build-windows, build-macos, pre-build]
needs: [ build-apk, build-linux, build-windows, build-macos, pre-build ]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
230 changes: 230 additions & 0 deletions .github/workflows/flutter-pre-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
name: 构建发布Flutter应用

#on:
# push:

on:
push:
branches:
- main
jobs:
pre-build:
name: 预构建
runs-on: ubuntu-latest
outputs:
APP_VERSION: ${{ steps.output-version.outputs.APP_VERSION }}
APP_LAST_VERSION: ${{ steps.output-tag-version.outputs.APP_VERSION }}
steps:
- name: 拉取代码
uses: actions/checkout@v3
with:
sparse-checkout: |
pubspec.yaml
sparse-checkout-cone-mode: false
fetch-depth: 0
- name: 读取当前版本号
id: output-version
run: |
VERSION=`grep -iE --regexp="version: ([0-9\.+]*)" pubspec.yaml | grep -io "[0-9\.+]*"`
echo "Version: $VERSION"
echo "APP_VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: 获取最新的TAG
id: output-tag-version
run: |
LAST_VERSION=`git tag --sort=-creatordate | head -1`
echo "Version: $LAST_VERSION"
echo "APP_LAST_VERSION=$LAST_VERSION" >> $GITHUB_OUTPUT
build-apk:
name: 编译android
runs-on: ubuntu-latest
needs: [ pre-build ]
steps:
- name: 设置Flutter环境
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: 拉取代码
uses: actions/checkout@v4

- name: 安装依赖项
run: flutter pub get

- name: 设置java环境
uses: actions/setup-java@v4
with:
distribution: "adopt"
java-version: "21"

- name: 运行代码生成器
run: dart run build_runner build

- name: 初始化签名
run: |
touch ./android/key.properties
echo keyPassword='${{ secrets.KEYPASSWORD }}' >> ./android/key.properties
echo storePassword='${{ secrets.STOREPASSWORD }}' >> ./android/key.properties
echo keyAlias='${{ secrets.KEYALIAS }}' >> ./android/key.properties
echo storeFile='./key.jks' >> ./android/key.properties
echo ${{ secrets.KEY_STORE }} | base64 --decode > ./android/app/key.jks
- name: 编译apk
run: flutter build apk --split-per-abi --obfuscate --split-debug-info=build/app/outputs/symbols/release

- name: 上传apk到工作流程
uses: actions/upload-artifact@v4
with:
name: build-apk
path: build/app/outputs/apk/release/*

build-linux:
name: 编译linux
runs-on: ubuntu-latest
needs: [ pre-build ]
steps:
- name: 拉取代码
uses: actions/checkout@v4

- name: 设置Flutter环境
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: 安装ninja、libgtk
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev libmpv-dev mpv
- name: 安装依赖项
run: flutter pub get

- name: 配置桌面
run: flutter config --enable-linux-desktop

- name: 运行代码生成器
run: dart run build_runner build

- name: 编译linux
run: flutter build linux

- name: 压缩生成的文件
run: tar -zcvf "MoeKey-${{ needs.pre-build.outputs.APP_VERSION }}-linux-x86_64-release.tar.gz" --directory=build/linux/x64/release/bundle .

- name: 上传到工作流程
uses: actions/upload-artifact@v4
with:
name: build-linux
path: "MoeKey-${{ needs.pre-build.outputs.APP_VERSION }}-linux-x86_64-release.tar.gz"

build-windows:
name: 编译windows
runs-on: windows-latest
needs: [ pre-build ]
steps:
- name: 拉取代码
uses: actions/checkout@v4

- name: 设置Flutter环境
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: 安装依赖项
run: flutter pub get

- name: 启动windows桌面
run: flutter config --enable-windows-desktop

- name: 运行代码生成器
run: dart run build_runner build

- name: 编译windows
run: flutter build windows

- name: 压缩生成的文件
run: |
$sourceFolder = "build\windows\x64\runner\Release"
$destinationPath = "MoeKey-${{ needs.pre-build.outputs.APP_VERSION }}-windows-x86_64-release.zip"
Compress-Archive -Path $sourceFolder -DestinationPath $destinationPath
- name: 上传到工作流程
uses: actions/upload-artifact@v4
with:
name: build-windows
path: "MoeKey-${{ needs.pre-build.outputs.APP_VERSION }}-windows-x86_64-release.zip"

build-macos:
name: 编译macOS
runs-on: macos-latest
needs: [ pre-build ]
steps:
- name: 拉取代码
uses: actions/checkout@v4

- name: 设置Flutter环境
uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: 安装依赖项
run: flutter pub get

- name: 启动桌面
run: flutter config --enable-macos-desktop

- name: 运行代码生成器
run: dart run build_runner build

- name: 编译macOS
run: flutter build macos

- name: 压缩生成的文件
run: |
cd build/macos/Build/Products/Release
zip -rq MoeKey-${{ needs.pre-build.outputs.APP_VERSION }}-macOS-universal-release.zip MoeKey.app
mv MoeKey-${{ needs.pre-build.outputs.APP_VERSION }}-macOS-universal-release.zip $GITHUB_WORKSPACE
- name: 上传到工作流程
uses: actions/upload-artifact@v4
with:
name: build-macos
path: |
MoeKey-${{ needs.pre-build.outputs.APP_VERSION }}-macOS-universal-release.zip
# release:
# name: 上传包
# needs: [build-apk, build-linux, build-windows, build-macos, pre-build]
# runs-on: ubuntu-latest
# permissions:
# contents: write
# steps:
# - name: 下载apk
# uses: actions/download-artifact@v4
# with:
# name: build-apk
# path: artifact
#
# - name: 下载linux
# uses: actions/download-artifact@v4
# with:
# name: build-linux
# path: artifact
#
# - name: 下载windows
# uses: actions/download-artifact@v4
# with:
# name: build-windows
# path: artifact
#
# - name: 下载macOS
# uses: actions/download-artifact@v4
# with:
# name: build-macos
# path: artifact
#
# - name: 创建releases
# id: create_release
# uses: softprops/action-gh-release@v2
# with:
# tag_name: ${{ needs.pre-build.outputs.APP_VERSION }}
# files: ./artifact/*
# body: "[CHANGELOG.md](CHANGELOG.md)"
4 changes: 1 addition & 3 deletions lib/pages/settings/profile/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class SettingsProfile extends HookConsumerWidget {
MkFormItem(
label: "个人简介",
helperText: "你可以在个人简介中包含一些#标签。",
child: const MkInput(
maxLines: 6,
),
child: const MkSelect(),
),
MkFormItem(
label: "位置",
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/mfm_text/mfm_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ _getParse({
MkImage(
"$loginServerUrl/avatar/@$user${host != null ? "@$host" : ""}",
height: textStyle.fontSize! * 1.5,
width: textStyle.fontSize! * 1.5,
shape: BoxShape.circle,
),
Text.rich(
Expand Down
24 changes: 9 additions & 15 deletions lib/widgets/mk_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ class MkImage extends StatelessWidget {
if (constraints.maxWidth == double.infinity) {
constraintsWidth = constraints.minWidth;
}
return Container(
Widget child = ColoredBox(
color: const Color.fromARGB(40, 0, 0, 0),
);
if (blurHash != null && blurHash!.isNotEmpty) {
child = BlurHash(blurHash!);
}
return SizedBox(
width: width ?? height ?? constraintsWidth,
height: height ?? constraintsHeight,
color: const Color.fromARGB(128, 0, 0, 0),
child: child,
);
},
);
Expand All @@ -73,20 +79,8 @@ class MkImage extends StatelessWidget {
);
}

child = AnimatedOpacity(
return AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
opacity:
state.extendedImageLoadState == LoadState.completed ? 1.0 : 0.1,
child: child,
);

if (blurHash == null ||
blurHash!.isEmpty ||
state.extendedImageLoadState == LoadState.completed) {
return child;
}
return BlurHash(
blurHash!,
child: child,
);
},
Expand Down
34 changes: 34 additions & 0 deletions lib/widgets/mk_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,37 @@ class MkInput extends ConsumerWidget {
);
}
}

class MkSelect extends HookConsumerWidget {
const MkSelect({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
var themes = ref.watch(themeColorsProvider);
return Material(
color: themes.panelColor,
child: FormField(builder: (FormFieldState state) {
return DropdownButtonFormField(
decoration: inputDecoration(themes, "请选择"),
style: TextStyle(fontSize: 14, color: themes.fgColor),
dropdownColor: themes.panelColor,
focusColor: themes.panelColor,
isExpanded: true,
items: const [
DropdownMenuItem(
child: Text("选项1"),
value: "1",
),
DropdownMenuItem(
child: Text("选项2"),
value: "2",
),
],
onChanged: (value) {
state.didChange(value);
},
);
}),
);
}
}
Loading

0 comments on commit bbcd905

Please sign in to comment.