merge: 合并 K86.12 评论文字居中修复

This commit is contained in:
Zhou Weidong committed 2026-10-21 13:16:39 +08:00
commit fc877f25bf
2 files changed
+57 -12

No files matched your search

@@ -457,7 +457,11 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
), ),
); );
InputDecoration _composerDecoration(String hint, {required bool focused}) { InputDecoration _composerDecoration(
String hint, {
required bool focused,
required bool multiline,
}) {
final radius = BorderRadius.circular( final radius = BorderRadius.circular(
focused ? _expandedInputRadius : _composerRadius, focused ? _expandedInputRadius : _composerRadius,
); );
@@ -467,7 +471,11 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
); );
return InputDecoration( return InputDecoration(
hintText: hint, hintText: hint,
hintStyle: const TextStyle(color: AppColors.muted, fontSize: 14), hintStyle: TextStyle(
color: AppColors.muted,
fontSize: 14,
height: multiline ? 1.4 : null,
),
counterText: '', counterText: '',
contentPadding: EdgeInsets.symmetric( contentPadding: EdgeInsets.symmetric(
horizontal: 16, horizontal: 16,
@@ -525,7 +533,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
child: Container( child: Container(
key: const Key('comment-input-placeholder'), key: const Key('comment-input-placeholder'),
height: _composerHeight, height: _composerHeight,
padding: const EdgeInsets.only(right: 3), padding: const EdgeInsets.only(right: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.commentInput, color: AppColors.commentInput,
borderRadius: BorderRadius.circular(_composerRadius), borderRadius: BorderRadius.circular(_composerRadius),
@@ -533,13 +541,21 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: Padding( child: Align(
padding: const EdgeInsets.only(left: 16), alignment: Alignment.centerLeft,
child: Text( child: Padding(
signedIn ? l10n.writeComment : l10n.commentLoginHint, padding: const EdgeInsets.only(left: 16),
maxLines: 1, child: Text(
overflow: TextOverflow.ellipsis, signedIn ? l10n.writeComment : l10n.commentLoginHint,
style: const TextStyle(color: AppColors.muted, fontSize: 14), key: const Key('comment-input-placeholder-label'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.muted,
fontSize: 14,
height: 1,
),
),
), ),
), ),
), ),
@@ -566,6 +582,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
required bool hasContent, required bool hasContent,
required bool canPost, required bool canPost,
}) { }) {
final multiline = _input.text.contains('\n');
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -587,12 +604,19 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
minLines: 1, minLines: 1,
maxLines: 4, maxLines: 4,
maxLength: _maxCommentLength, maxLength: _maxCommentLength,
textAlignVertical: TextAlignVertical.top, textAlignVertical: multiline
style: const TextStyle(color: AppColors.cream, fontSize: 15), ? TextAlignVertical.top
: TextAlignVertical.center,
style: TextStyle(
color: AppColors.cream,
fontSize: 15,
height: multiline ? 1.4 : null,
),
cursorColor: AppColors.blue, cursorColor: AppColors.blue,
decoration: _composerDecoration( decoration: _composerDecoration(
signedIn ? l10n.writeComment : l10n.commentLoginHint, signedIn ? l10n.writeComment : l10n.commentLoginHint,
focused: true, focused: true,
multiline: multiline,
), ),
onTap: signedIn ? null : _authenticateForComment, onTap: signedIn ? null : _authenticateForComment,
), ),
@@ -109,6 +109,16 @@ void main() {
final input = find.byKey(const Key('comment-input')); final input = find.byKey(const Key('comment-input'));
expect(input, findsOneWidget); expect(input, findsOneWidget);
expect(tester.widget<TextField>(input).focusNode?.hasFocus, isTrue); expect(tester.widget<TextField>(input).focusNode?.hasFocus, isTrue);
expect(
tester.widget<TextField>(input).textAlignVertical,
TextAlignVertical.center,
);
await tester.enterText(input, 'First line\nSecond line');
await tester.pump();
final multilineField = tester.widget<TextField>(input);
expect(multilineField.textAlignVertical, TextAlignVertical.top);
expect(multilineField.style?.height, 1.4);
}); });
testWidgets('should_gate_guest_post_without_creating_comment', ( testWidgets('should_gate_guest_post_without_creating_comment', (
@@ -492,6 +502,17 @@ void main() {
tester.getSize(find.byKey(const Key('comment-input-placeholder'))).height, tester.getSize(find.byKey(const Key('comment-input-placeholder'))).height,
44, 44,
); );
final placeholderLabel = find.byKey(
const Key('comment-input-placeholder-label'),
);
final placeholderSendIcon = find.descendant(
of: find.byKey(const Key('comment-post')),
matching: find.byIcon(Icons.send_rounded),
);
expect(
tester.getCenter(placeholderLabel).dy,
closeTo(tester.getCenter(placeholderSendIcon).dy, 1),
);
expect(find.byKey(const Key('player-comments-drag-handle')), findsNothing); expect(find.byKey(const Key('player-comments-drag-handle')), findsNothing);
expect( expect(
tester.getSize(find.byKey(const Key('player-comments-close'))), tester.getSize(find.byKey(const Key('player-comments-close'))),