Skip to content

Commit

Permalink
Merge branch 'main' into feat-hidden-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
KoolShow authored Feb 16, 2024
2 parents fa8ddc0 + ff6845f commit b7c7e9b
Show file tree
Hide file tree
Showing 96 changed files with 3,787 additions and 1,904 deletions.
143 changes: 143 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- '*'
paths-ignore:
- '**.md'
- '**.txt'
- '.github/**'
- '.idea/**'
- '!.github/workflows/**'

jobs:
android:
name: Build CI (Android)
runs-on: ubuntu-latest

steps:
- name: 代码迁出
uses: actions/checkout@v3

- name: 构建Java环境
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
token: ${{secrets.GIT_TOKEN}}

- name: 检查缓存
uses: actions/cache@v2
id: cache-flutter
with:
path: /root/flutter-sdk
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}

- name: 安装Flutter
if: steps.cache-flutter.outputs.cache-hit != 'true'
uses: subosito/flutter-action@v2
with:
flutter-version: 3.16.5
channel: any

- name: 下载项目依赖
run: flutter pub get

- name: 解码生成 jks
run: echo $KEYSTORE_BASE64 | base64 -di > android/app/vvex.jks
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}

- name: flutter build apk
run: flutter build apk --release --split-per-abi
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD}}

- name: 获取版本号
id: version
run: echo "version=${GITHUB_SHA::7}" >>$GITHUB_OUTPUT

- name: 重命名应用
run: |
for file in build/app/outputs/flutter-apk/app-*.apk; do
if [[ $file =~ app-(.?*)release.apk ]]; then
new_file_name="build/app/outputs/flutter-apk/Pili-${BASH_REMATCH[1]}${{ steps.version.outputs.version }}.apk"
mv "$file" "$new_file_name"
fi
done
- name: 上传
uses: actions/upload-artifact@v3
with:
name: Pilipala-CI
path: |
build/app/outputs/flutter-apk/Pili-*.apk
iOS:
name: Build CI (iOS)
runs-on: macos-latest

steps:
- name: 代码迁出
uses: actions/checkout@v4

- name: 安装Flutter
if: steps.cache-flutter.outputs.cache-hit != 'true'
uses: subosito/[email protected]
with:
cache: true
flutter-version: 3.16.5

- name: flutter build ipa
run: |
flutter build ios --release --no-codesign
ln -sf ./build/ios/iphoneos Payload
zip -r9 app.ipa Payload/runner.app
- name: 获取版本号
id: version
run: echo "version=${GITHUB_SHA::7}" >>$GITHUB_OUTPUT

- name: 重命名应用
run: |
DATE=${{ steps.date.outputs.date }}
for file in app.ipa; do
new_file_name="build/Pili-${{ steps.version.outputs.version }}.ipa"
mv "$file" "$new_file_name"
done
- name: 上传
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: Pilipala-CI
path: |
build/Pili-*.ipa
upload:
runs-on: ubuntu-latest

needs:
- android
- iOS
steps:

- uses: actions/download-artifact@v3
with:
name: Pilipala-CI
path: ./Pilipala-CI

- name: Upload Pre-release
uses: ncipollo/release-action@v1
with:
name: v${{ github.run_number }}
token: ${{ secrets.GIT_TOKEN }}
commit: main
tag: v${{ github.run_number }}
prerelease: true
allowUpdates: true
artifacts: Pilipala-CI/*
16 changes: 15 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.9.22'
repositories {
maven { url "https://maven.aliyun.com/repository/google" }
maven { url "https://maven.aliyun.com/repository/central" }
maven { url "https://maven.aliyun.com/repository/jcenter" }
maven { url "https://maven.aliyun.com/repository/public" }
maven { url "http://download.flutter.io"
allowInsecureProtocol = true
}
google()
mavenCentral()
}
Expand All @@ -13,6 +20,13 @@ buildscript {

allprojects {
repositories {
maven { url "https://maven.aliyun.com/repository/google" }
maven { url "https://maven.aliyun.com/repository/central" }
maven { url "https://maven.aliyun.com/repository/jcenter" }
maven { url "https://maven.aliyun.com/repository/public" }
maven { url "http://download.flutter.io"
allowInsecureProtocol = true
}
google()
mavenCentral()
}
Expand Down
Binary file removed assets/images/live/default_bg.webp
Binary file not shown.
31 changes: 9 additions & 22 deletions lib/common/widgets/network_img_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,16 @@ class NetworkImgLayer extends StatelessWidget {
final String imageUrl =
'${src!.startsWith('//') ? 'https:${src!}' : src!}@${quality ?? 100}q.webp';
int? memCacheWidth, memCacheHeight;
double aspectRatio = (width / height).toDouble();

void setMemCacheSizes() {
if (aspectRatio > 1) {
memCacheHeight = height.cacheSize(context);
} else if (aspectRatio < 1) {
memCacheWidth = width.cacheSize(context);
} else {
if (origAspectRatio != null && origAspectRatio! > 1) {
memCacheWidth = width.cacheSize(context);
} else if (origAspectRatio != null && origAspectRatio! < 1) {
memCacheHeight = height.cacheSize(context);
} else {
memCacheWidth = width.cacheSize(context);
memCacheHeight = height.cacheSize(context);
}
}
}

setMemCacheSizes();

if (memCacheWidth == null && memCacheHeight == null) {
memCacheWidth = width.toInt();
if (width > height || (origAspectRatio != null && origAspectRatio! > 1)) {
memCacheWidth = width.cacheSize(context);
} else if (width < height ||
(origAspectRatio != null && origAspectRatio! < 1)) {
memCacheHeight = height.cacheSize(context);
} else {
// 不能同时设置,否则会导致图片变形
memCacheWidth = width.cacheSize(context);
// memCacheHeight = height.cacheSize(context);
}

return src != '' && src != null
Expand Down
110 changes: 5 additions & 105 deletions lib/common/widgets/video_card_h.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import '../../http/search.dart';
import '../../http/user.dart';
import '../../http/video.dart';
import '../../utils/utils.dart';
import '../constants.dart';
import 'badge.dart';
import 'network_img_layer.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
import 'video_popup_menu.dart';

// 视频卡片 - 水平布局
class VideoCardH extends StatelessWidget {
Expand Down Expand Up @@ -240,113 +239,14 @@ class VideoContent extends StatelessWidget {
),

const Spacer(),
// SizedBox(
// width: 20,
// height: 20,
// child: IconButton(
// tooltip: '稍后再看',
// style: ButtonStyle(
// padding: MaterialStateProperty.all(EdgeInsets.zero),
// ),
// onPressed: () async {
// var res =
// await UserHttp.toViewLater(bvid: videoItem.bvid);
// SmartDialog.showToast(res['msg']);
// },
// icon: Icon(
// Icons.more_vert_outlined,
// color: Theme.of(context).colorScheme.outline,
// size: 14,
// ),
// ),
// ),
if (source == 'normal')
SizedBox(
width: 24,
height: 24,
child: PopupMenuButton<String>(
padding: EdgeInsets.zero,
icon: Icon(
Icons.more_vert_outlined,
color: Theme.of(context).colorScheme.outline,
size: 14,
),
position: PopupMenuPosition.under,
// constraints: const BoxConstraints(maxHeight: 35),
onSelected: (String type) {},
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<String>>[
PopupMenuItem<String>(
onTap: () async {
var res = await UserHttp.toViewLater(
bvid: videoItem.bvid as String);
SmartDialog.showToast(res['msg']);
},
value: 'pause',
height: 40,
child: const Row(
children: [
Icon(Icons.watch_later_outlined, size: 16),
SizedBox(width: 6),
Text('稍后再看', style: TextStyle(fontSize: 13))
],
),
),
const PopupMenuDivider(),
PopupMenuItem<String>(
onTap: () async {
SmartDialog.show(
useSystem: true,
animationType:
SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: Text(
'确定拉黑:${videoItem.owner.name}(${videoItem.owner.mid})?'
'\n\n注:被拉黑的Up可以在隐私设置-黑名单管理中解除'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'点错了',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.outline),
),
),
TextButton(
onPressed: () async {
var res = await VideoHttp.relationMod(
mid: videoItem.owner.mid,
act: 5,
reSrc: 11,
);
SmartDialog.dismiss();
SmartDialog.showToast(res['code'] == 0
? '成功'
: res['msg']);
},
child: const Text('确认'),
)
],
);
},
);
},
value: 'pause',
height: 40,
child: Row(
children: [
const Icon(Icons.block, size: 16),
const SizedBox(width: 6),
Text('拉黑:${videoItem.owner.name}',
style: const TextStyle(fontSize: 13))
],
),
),
],
child: VideoPopupMenu(
size: 32,
iconSize: 18,
videoItem: videoItem,
),
),
],
Expand Down
Loading

0 comments on commit b7c7e9b

Please sign in to comment.