Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: "3.41.9"
flutter-version: "3.44.9"
cache: true

- name: Get Flutter dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Setup flutter-ohos
run: |
git clone -b oh-3.41.9-dev https://gitcode.com/CPF-Flutter/flutter_flutter.git $GITHUB_WORKSPACE/flutter
git clone -b oh-3.44.9-dev https://gitcode.com/CPF-Flutter/flutter_flutter.git $GITHUB_WORKSPACE/flutter
echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
shell: bash

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,6 @@ test*
.agents
skills-lock.json

ohos/.codegenie
ohos/.codegenie
.codex/skills/deveco-cli/SKILL.md
.claude/skills/deveco-cli/SKILL.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
> [!TIP]
> 当前项目编译API已经提升到了26.0.0,请在华为官网下载最新的配套IDE和SDK使用,防止编译异常

- 1、配置鸿蒙flutter3.41.9环境,参考[鸿蒙flutter3.41.9](https://gitcode.com/CPF-Flutter/flutter_flutter/tree/oh-3.41.9-dev)
- 1、配置鸿蒙flutter3.44.9环境,参考[鸿蒙flutter3.44.9](https://gitcode.com/CPF-Flutter/flutter_flutter/tree/oh-3.44.9-dev)

- 2、通过vscode运行启动配置或是build_hap任务以确保应用内所需环境变量正确写入

Expand Down
Binary file removed assets/fonts/HarmonyOS_Sans_SC_w300.ttf
Binary file not shown.
Binary file removed assets/fonts/HarmonyOS_Sans_SC_w400.ttf
Binary file not shown.
Binary file removed assets/fonts/HarmonyOS_Sans_SC_w500.ttf
Binary file not shown.
Binary file removed assets/fonts/HarmonyOS_Sans_SC_w600.ttf
Binary file not shown.
Binary file removed assets/fonts/HarmonyOS_Sans_SC_w700.ttf
Binary file not shown.
Binary file removed assets/fonts/HarmonyOS_Sans_SC_w800.ttf
Binary file not shown.
34 changes: 12 additions & 22 deletions lib/common/widgets/flutter/live_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,30 @@ import 'package:flutter/rendering.dart'
import 'package:flutter/widgets.dart';

class LiveListView extends ListView {
// 上游用 `required super.itemBuilder` 这类 super 形参直接转发给
// ListView.separated;3.41 的 ListView.separated 把它们收成普通具名形参
// (不是字段),super 形参用不了,只能显式列出再转发。3.41 也还没有
// `scrollCacheExtent`,一并去掉。
LiveListView.separated({
super.key,
super.scrollDirection,
super.controller,
super.primary,
super.physics,
super.padding,
required NullableIndexedWidgetBuilder itemBuilder,
ChildIndexGetter? findItemIndexCallback,
required IndexedWidgetBuilder separatorBuilder,
required int itemCount,
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
super.cacheExtent,
required super.itemBuilder,
// ignore: deprecated_member_use
super.findChildIndexCallback,
super.findItemIndexCallback,
required super.separatorBuilder,
required super.itemCount,
super.addAutomaticKeepAlives,
super.addRepaintBoundaries,
super.addSemanticIndexes,
super.scrollCacheExtent,
super.dragStartBehavior,
super.keyboardDismissBehavior,
super.restorationId,
super.clipBehavior,
super.hitTestBehavior,
this.initialIndex = 0,
}) : super.separated(
itemBuilder: itemBuilder,
findItemIndexCallback: findItemIndexCallback,
separatorBuilder: separatorBuilder,
itemCount: itemCount,
addAutomaticKeepAlives: addAutomaticKeepAlives,
addRepaintBoundaries: addRepaintBoundaries,
addSemanticIndexes: addSemanticIndexes,
);
}) : super.separated();

final int initialIndex;

Expand Down Expand Up @@ -310,4 +300,4 @@ class RenderLiveSliverList extends RenderSliverList {
}
childManager.didFinishLayout();
}
}
}
1 change: 0 additions & 1 deletion lib/common/widgets/flutter/page/page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ class _PageViewState<T extends HorizontalDragGestureRecognizer>
// independent of implicit scrolling:
// https://github.com/flutter/flutter/issues/45632
cacheExtent: widget.allowImplicitScrolling ? 1.0 : 0.0,
cacheExtentStyle: CacheExtentStyle.viewport,
axisDirection: axisDirection,
offset: position,
clipBehavior: widget.clipBehavior,
Expand Down
116 changes: 78 additions & 38 deletions lib/common/widgets/flutter/refresh_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

import 'dart:async' show Completer;

import 'package:PiliPlus/common/widgets/refresh_layout.dart';
import 'package:PiliPlus/common/widgets/scroll_behavior.dart';
import 'package:PiliPlus/common/widgets/scroll_physics.dart'
show BouncingScrollPhysicsExt;
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'
show RefreshScrollPhysics;
import 'package:extended_nested_scroll_view/refresh.dart';
import 'package:flutter/foundation.dart' show clampDouble;
import 'package:flutter/material.dart' hide RefreshIndicator;
import 'package:os_type/os_type.dart';

const kIndicatorSize = 49.0;

/// The distance from the child's top or bottom [edgeOffset] where
/// the refresh indicator will settle. During the drag that exposes the refresh
/// indicator, its actual displacement may significantly exceed this value.
Expand Down Expand Up @@ -218,6 +222,9 @@ class RefreshIndicatorState extends State<RefreshIndicator>
RefreshIndicatorStatus? _status;
late Future<void> _pendingRefreshFuture;
double? _dragOffset;

// 鸿蒙保留kDragContainerExtentPercentage= Pref.refreshDragPercentage所需
double _containerExtent = 0.0;
late Color _effectiveValueColor;
// late Color _backgroundColor;

Expand Down Expand Up @@ -313,6 +320,10 @@ class RefreshIndicatorState extends State<RefreshIndicator>
if (!widget.notificationPredicate(notification)) {
return false;
}
final viewportDimension = notification.metrics.viewportDimension;
if (viewportDimension > 0) {
_containerExtent = viewportDimension;
}
if (_shouldStart(notification)) {
setState(() {
_status = RefreshIndicatorStatus.drag;
Expand Down Expand Up @@ -508,42 +519,37 @@ class RefreshIndicatorState extends State<RefreshIndicator>
_status == RefreshIndicatorStatus.refresh ||
_status == RefreshIndicatorStatus.done;

child = Stack(
clipBehavior: Clip.none,
children: <Widget>[
child,
if (_status != null)
Positioned(
top: widget.edgeOffset,
left: 0.0,
right: 0.0,
child: SizeTransition(
axisAlignment: 1.0,
sizeFactor: _positionFactor, // This is what brings it down.
child: Padding(
padding: EdgeInsets.only(top: displacement),
child: Align(
alignment: Alignment.topCenter,
child: ScaleTransition(
scale: _scaleFactor,
child: AnimatedBuilder(
animation: _positionController,
builder: (context, child) => RefreshProgressIndicator(
value: showIndeterminateIndicator ? null : _value.value,
valueColor: _valueColor,
backgroundColor: widget.backgroundColor,
strokeWidth: widget.strokeWidth,
elevation: widget.elevation,
),
),
),
),
child = RefreshLayout(
body: child,
scale: _scaleFactor,
position: _positionFactor,
indicator: _status == null
? null
: AnimatedBuilder(
animation: _positionController,
builder: (context, child) => RefreshProgressIndicator(
value: showIndeterminateIndicator ? null : _value.value,
valueColor: _valueColor,
backgroundColor: widget.backgroundColor,
strokeWidth: widget.strokeWidth,
elevation: widget.elevation,
),
),
),
],
);
if (!widget.isClampingScrollPhysics && (PlatformUtils.isDarwin || OS.isHarmony)) {

// 鸿蒙与iOS保持一致的下拉动画
if (PlatformUtils.isDarwin || OS.isHarmony) {
if (widget.isClampingScrollPhysics) {
return ScrollConfiguration(
behavior: RefreshScrollBehavior(
scrollPhysics: RefreshScrollPhysicsIOS(
parent: const RangeMaintainingScrollPhysics(),
onDrag: _onDrag,
),
),
child: child,
);
}
return child;
}
return ScrollConfiguration(
Expand All @@ -557,10 +563,12 @@ class RefreshIndicatorState extends State<RefreshIndicator>
);
}

bool _onDrag(double offset, double viewportDimension) {
bool _onDrag(double offset) {
if (_positionController.value > 0.0 && _status == .drag) {
_dragOffset = _dragOffset! + offset;
_checkDragOffset(viewportDimension);
if (_containerExtent > 0.0) {
_checkDragOffset(_containerExtent);
}
return true;
}
return false;
Expand Down Expand Up @@ -614,10 +622,42 @@ class RefreshScrollBehavior extends CustomScrollBehavior {
required this.scrollPhysics,
});

final RefreshScrollPhysics scrollPhysics;
final RefreshScrollPhysicsMixin scrollPhysics;

@override
ScrollPhysics getScrollPhysics(BuildContext context) {
return scrollPhysics;
}
}

class RefreshScrollPhysics extends ClampingScrollPhysics
with RefreshScrollPhysicsMixin {
const RefreshScrollPhysics({
super.parent,
required this.onDrag,
});

@override
final OnDrag onDrag;

@override
RefreshScrollPhysics applyTo(ScrollPhysics? ancestor) {
return RefreshScrollPhysics(parent: buildParent(ancestor), onDrag: onDrag);
}
}

class RefreshScrollPhysicsIOS extends BouncingScrollPhysicsExt
with RefreshScrollPhysicsMixin {
const RefreshScrollPhysicsIOS({super.parent, required this.onDrag});

@override
final OnDrag onDrag;

@override
RefreshScrollPhysicsIOS applyTo(ScrollPhysics? ancestor) {
return RefreshScrollPhysicsIOS(
parent: buildParent(ancestor),
onDrag: onDrag,
);
}
}
68 changes: 0 additions & 68 deletions lib/common/widgets/flutter/text_field/editable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5581,69 +5581,6 @@ class EditableTextState extends State<EditableText>
_scrollController.jumpTo(destination);
}

/// Extend the selection down by page if the `forward` parameter is true, or
/// up by page otherwise.
void _extendSelectionByPage(ExtendSelectionByPageIntent intent) {
if (widget.maxLines == 1) {
return;
}

final TextSelection nextSelection;
final Rect extentRect = renderEditable.getLocalRectForCaret(
_value.selection.extent,
);
final state = _scrollableKey.currentState as ScrollableState?;
final double increment = ScrollAction.getDirectionalIncrement(
state!,
ScrollIntent(
direction: intent.forward ? AxisDirection.down : AxisDirection.up,
type: ScrollIncrementType.page,
),
);
final ScrollPosition position = _scrollController.position;
if (intent.forward) {
if (_value.selection.extentOffset >= _value.text.length) {
return;
}
final nextExtentOffset = Offset(
extentRect.left,
extentRect.top + increment,
);
final double height =
position.maxScrollExtent + renderEditable.size.height;
final TextPosition nextExtent =
nextExtentOffset.dy + position.pixels >= height
? TextPosition(offset: _value.text.length)
: renderEditable.getPositionForPoint(
renderEditable.localToGlobal(nextExtentOffset),
);
nextSelection = _value.selection.copyWith(
extentOffset: nextExtent.offset,
);
} else {
if (_value.selection.extentOffset <= 0) {
return;
}
final nextExtentOffset = Offset(
extentRect.left,
extentRect.top + increment,
);
final TextPosition nextExtent = nextExtentOffset.dy + position.pixels <= 0
? const TextPosition(offset: 0)
: renderEditable.getPositionForPoint(
renderEditable.localToGlobal(nextExtentOffset),
);
nextSelection = _value.selection.copyWith(
extentOffset: nextExtent.offset,
);
}

bringIntoView(nextSelection.extent);
userUpdateTextEditingValue(
_value.copyWith(selection: nextSelection),
SelectionChangedCause.keyboard,
);
}

void _updateSelection(UpdateSelectionIntent intent) {
assert(
Expand Down Expand Up @@ -5782,11 +5719,6 @@ class EditableTextState extends State<EditableText>
ignoreNonCollapsedSelection: false,
),
),
ExtendSelectionByPageIntent: _makeOverridable(
CallbackAction<ExtendSelectionByPageIntent>(
onInvoke: _extendSelectionByPage,
),
),
ExtendSelectionToNextWordBoundaryIntent: _makeOverridable(
_UpdateTextSelectionAction<ExtendSelectionToNextWordBoundaryIntent>(
this,
Expand Down
Loading
Loading