Skip to content

Commit

Permalink
fix: change style of cw button
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Dec 1, 2024
1 parent 700c584 commit 86a57ed
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 186 deletions.
19 changes: 14 additions & 5 deletions lib/view/widget/cw_button.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:misskey_dart/misskey_dart.dart';

import '../../i18n/strings.g.dart';
import '../../provider/misskey_colors_provider.dart';

class CwButton extends StatelessWidget {
class CwButton extends ConsumerWidget {
const CwButton({
super.key,
required this.note,
Expand All @@ -16,13 +18,20 @@ class CwButton extends StatelessWidget {
final bool isOpen;

@override
Widget build(BuildContext context) {
final style = DefaultTextStyle.of(context).style;
Widget build(BuildContext context, WidgetRef ref) {
final colors =
ref.watch(misskeyColorsProvider(Theme.of(context).brightness));
final style = DefaultTextStyle.of(context).style.apply(fontSizeFactor: 0.9);

return OutlinedButton(
style: OutlinedButton.styleFrom(
textStyle: style,
minimumSize: Size(double.infinity, style.fontSize! * 2.5),
foregroundColor: colors.fg,
backgroundColor: colors.buttonBg,
textStyle: style.copyWith(fontWeight: FontWeight.bold),
padding: const EdgeInsets.symmetric(vertical: 6.0, horizontal: 12.0),
minimumSize: const Size(double.infinity, 0.0),
side: BorderSide.none,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: onPressed != null ? () => onPressed?.call(!isOpen) : null,
child: Text.rich(
Expand Down
7 changes: 7 additions & 0 deletions lib/view/widget/follow_requests_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ class FollowRequestsListView extends HookConsumerWidget {
Positioned(
top: 8.0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: Size(
0.0,
DefaultTextStyle.of(context).style.fontSize! * 2.75,
),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () {
controller.scrollToTop();
keepAnimation.value = true;
Expand Down
123 changes: 61 additions & 62 deletions lib/view/widget/note_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ class NoteWidget extends HookConsumerWidget {
),
],
if (appearNote.cw == null || showContent.value) ...[
if (parsed != null || appearNote.replyId != null)
if (parsed != null ||
appearNote.replyId != null) ...[
Text.rich(
TextSpan(
children: [
Expand Down Expand Up @@ -479,76 +480,71 @@ class NoteWidget extends HookConsumerWidget {
),
maxLines: isCollapsed.value ? 10 : null,
),
const SizedBox(height: 4.0),
],
if (!isCollapsed.value) ...[
if (appearNote.files.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
),
child: MediaList(
account: account,
files: appearNote.files,
user: appearNote.user,
),
if (appearNote.files.isNotEmpty) ...[
MediaList(
account: account,
files: appearNote.files,
user: appearNote.user,
),
if (appearNote case Note(:final poll?))
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
),
child: PollWidget(
account: account,
noteId: appearNote.id,
poll: poll,
),
const SizedBox(height: 8.0),
],
if (appearNote case Note(:final poll?)) ...[
PollWidget(
account: account,
noteId: appearNote.id,
poll: poll,
),
if (urls != null)
...urls.map(
(url) => Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
const SizedBox(height: 4.0),
],
if (urls != null && urls.isNotEmpty)
for (final url in urls) ...[
UrlPreview(account: account, link: url),
const SizedBox(height: 8.0),
],
if (appearNote case Note(:final renoteId?)) ...[
DottedBorder(
color: colors.renote,
borderType: BorderType.RRect,
dashPattern: const [2, 4],
radius: const Radius.circular(8.0),
child: DefaultTextStyle.merge(
style: style.apply(
fontSizeFactor: 0.95,
),
child: UrlPreview(
child: NoteSimpleWidget(
account: account,
link: url,
),
),
),
if (appearNote case Note(:final renoteId?))
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
),
child: DottedBorder(
color: colors.renote,
borderType: BorderType.RRect,
dashPattern: const [2, 4],
radius: const Radius.circular(8.0),
child: DefaultTextStyle.merge(
style: style.apply(
fontSizeFactor: 0.95,
),
child: NoteSimpleWidget(
account: account,
noteId: renoteId,
borderRadius:
BorderRadius.circular(4.0),
showFooter: this.showFooter,
focusPostForm: focusPostForm,
note: this.note?.renote,
),
noteId: renoteId,
borderRadius:
BorderRadius.circular(4.0),
showFooter: this.showFooter,
focusPostForm: focusPostForm,
note: this.note?.renote,
),
),
),
const SizedBox(height: 4.0),
],
],
if (isLong)
if (isLong) ...[
OutlinedButton(
style: OutlinedButton.styleFrom(
textStyle: style,
minimumSize: Size(
double.infinity,
style.fontSize! * 2.5,
foregroundColor: colors.fg,
backgroundColor: colors.buttonBg,
textStyle: style
.apply(fontSizeFactor: 0.9)
.copyWith(fontWeight: FontWeight.bold),
padding: const EdgeInsets.symmetric(
vertical: 6.0,
horizontal: 12.0,
),
minimumSize:
const Size(double.infinity, 0.0),
side: BorderSide.none,
tapTargetSize:
MaterialTapTargetSize.shrinkWrap,
),
onPressed: () =>
isCollapsed.value = !isCollapsed.value,
Expand All @@ -558,9 +554,10 @@ class NoteWidget extends HookConsumerWidget {
: t.misskey.showLess,
),
),
const SizedBox(height: 4.0),
],
],
if (appearNote case Note(:final channel?)) ...[
const SizedBox(height: 4.0),
InkWell(
onTap: () => context
.push('/$account/channels/${channel.id}'),
Expand All @@ -587,17 +584,19 @@ class NoteWidget extends HookConsumerWidget {
],
),
),
const SizedBox(height: 4.0),
],
const SizedBox(height: 4.0),
if (appearNote.reactionAcceptance !=
ReactionAcceptance.likeOnly &&
showReactionsViewer)
showReactionsViewer &&
appearNote.reactions.isNotEmpty) ...[
ReactionsViewer(
account: account,
noteId: appearNote.id,
showAllReactions: showAllReactions,
note: this.note,
),
],
if (showFooter)
NoteFooter(
account: account,
Expand Down
7 changes: 7 additions & 0 deletions lib/view/widget/notifications_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ class NotificationsListView extends HookConsumerWidget {
Positioned(
top: 8.0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: Size(
0.0,
DefaultTextStyle.of(context).style.fontSize! * 2.75,
),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () {
controller.scrollToTop();
keepAnimation.value = true;
Expand Down
Loading

0 comments on commit 86a57ed

Please sign in to comment.