这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: show request count only if non zero #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2024
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
114 changes: 4 additions & 110 deletions lib/view/page/user/user_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import '../../widget/mfm.dart';
import '../../widget/note_widget.dart';
import '../../widget/role_chip.dart';
import '../../widget/shake_widget.dart';
import '../../widget/skeb_status_widget.dart';
import '../../widget/time_widget.dart';
import '../../widget/url_widget.dart';
import '../../widget/user_avatar.dart';
Expand Down Expand Up @@ -528,116 +529,9 @@ class _UserHome extends ConsumerWidget {
padding: const EdgeInsets.all(4.0),
child: Align(
alignment: Alignment.centerLeft,
child: InkWell(
onTap: () => launchUrl(
Uri.https(
'skeb.jp',
'@${skebStatus.screenName}',
),
mode: LaunchMode.externalApplication,
),
child: Text.rich(
TextSpan(
children: [
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: Container(
decoration: BoxDecoration(
color: skebStatus.isAcceptable
? const Color(0xFFF14668)
: const Color(0xFF363636),
borderRadius:
BorderRadius.circular(6.0),
),
padding: const EdgeInsets.symmetric(
vertical: 2.0,
horizontal: 6.0,
),
child: Text(
skebStatus.isAcceptable
? t.misskeyIO.skebStatus_.seeking
: skebStatus.isCreator
? t.misskeyIO.skebStatus_
.stopped
: t.misskeyIO.skebStatus_
.client,
style: style.apply(
color: Colors.white,
fontSizeFactor: 0.85,
),
),
),
),
const WidgetSpan(
child: SizedBox(width: 2.0),
),
...buildMfm(
ref,
account: account,
text: [
if (skebStatus.isAcceptable)
if (skebStatus.skills.firstOrNull
case final skill?) ...[
switch (skill.genre) {
SkebStatusSkillGenre.art => t
.misskeyIO
.skebStatus_
.genres_
.art,
SkebStatusSkillGenre.comic => t
.misskeyIO
.skebStatus_
.genres_
.comic,
SkebStatusSkillGenre.voice => t
.misskeyIO
.skebStatus_
.genres_
.voice,
SkebStatusSkillGenre.novel => t
.misskeyIO
.skebStatus_
.genres_
.novel,
SkebStatusSkillGenre.video => t
.misskeyIO
.skebStatus_
.genres_
.video,
SkebStatusSkillGenre.music => t
.misskeyIO
.skebStatus_
.genres_
.music,
SkebStatusSkillGenre.correction =>
t.misskeyIO.skebStatus_.genres_
.correction,
null => t.misskey.unknown,
},
t.misskeyIO.skebStatus_.yenX(
x: NumberFormat()
.format(skill.amount),
),
],
if (skebStatus.creatorRequestCount > 0)
if (skebStatus.isAcceptable) '|',
t.misskeyIO.skebStatus_.nWorks(
n: NumberFormat().format(
skebStatus.creatorRequestCount,
),
),
].join(' '),
),
WidgetSpan(
child: Icon(
Icons.open_in_new,
size: style.fontSize,
),
),
],
),
),
child: SkebStatusWidget(
account: account,
skebStatus: skebStatus,
),
),
),
Expand Down
146 changes: 146 additions & 0 deletions lib/view/widget/skeb_status_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:intl/intl.dart';
import 'package:misskey_dart/misskey_dart.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../i18n/strings.g.dart';
import '../../model/account.dart';
import 'mfm.dart';

class SkebStatusWidget extends ConsumerWidget {
const SkebStatusWidget({
super.key,
required this.account,
required this.skebStatus,
});

final Account account;
final UsersGetSkebStatusResponse skebStatus;

@override
Widget build(BuildContext context, WidgetRef ref) {
final style = DefaultTextStyle.of(context).style;

return Tooltip(
message: skebStatus.skills.nonNulls
.map(
(skill) => [
switch (skill.genre) {
SkebStatusSkillGenre.art => t.misskeyIO.skebStatus_.genres_.art,
SkebStatusSkillGenre.comic =>
t.misskeyIO.skebStatus_.genres_.comic,
SkebStatusSkillGenre.voice =>
t.misskeyIO.skebStatus_.genres_.voice,
SkebStatusSkillGenre.novel =>
t.misskeyIO.skebStatus_.genres_.novel,
SkebStatusSkillGenre.video =>
t.misskeyIO.skebStatus_.genres_.video,
SkebStatusSkillGenre.music =>
t.misskeyIO.skebStatus_.genres_.music,
SkebStatusSkillGenre.correction =>
t.misskeyIO.skebStatus_.genres_.correction,
null => t.misskey.unknown,
},
t.misskeyIO.skebStatus_.yenX(
x: NumberFormat().format(skill.amount),
),
].join(' '),
)
.join(' | '),
child: InkWell(
onTap: () => launchUrl(
Uri.https(
'skeb.jp',
'@${skebStatus.screenName}',
),
mode: LaunchMode.externalApplication,
),
child: Text.rich(
TextSpan(
children: [
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: Container(
decoration: BoxDecoration(
color: skebStatus.isAcceptable
? const Color(0xFFF14668)
: const Color(0xFF363636),
borderRadius: BorderRadius.circular(6.0),
),
padding: const EdgeInsets.symmetric(
vertical: 2.0,
horizontal: 6.0,
),
child: Text(
skebStatus.isAcceptable
? t.misskeyIO.skebStatus_.seeking
: skebStatus.isCreator
? t.misskeyIO.skebStatus_.stopped
: t.misskeyIO.skebStatus_.client,
style: style.apply(
color: Colors.white,
fontSizeFactor: 0.85,
),
),
),
),
const WidgetSpan(
child: SizedBox(width: 2.0),
),
...buildMfm(
ref,
account: account,
text: [
if (skebStatus.isAcceptable)
if (skebStatus.skills.firstOrNull case final skill?) ...[
switch (skill.genre) {
SkebStatusSkillGenre.art =>
t.misskeyIO.skebStatus_.genres_.art,
SkebStatusSkillGenre.comic =>
t.misskeyIO.skebStatus_.genres_.comic,
SkebStatusSkillGenre.voice =>
t.misskeyIO.skebStatus_.genres_.voice,
SkebStatusSkillGenre.novel =>
t.misskeyIO.skebStatus_.genres_.novel,
SkebStatusSkillGenre.video =>
t.misskeyIO.skebStatus_.genres_.video,
SkebStatusSkillGenre.music =>
t.misskeyIO.skebStatus_.genres_.music,
SkebStatusSkillGenre.correction =>
t.misskeyIO.skebStatus_.genres_.correction,
null => t.misskey.unknown,
},
t.misskeyIO.skebStatus_.yenX(
x: NumberFormat().format(skill.amount),
),
],
if (skebStatus.creatorRequestCount > 0) ...[
if (skebStatus.isAcceptable) '|',
t.misskeyIO.skebStatus_.nWorks(
n: NumberFormat().format(
skebStatus.creatorRequestCount,
),
),
] else if (skebStatus.clientRequestCount > 0)
t.misskeyIO.skebStatus_.nRequests(
n: NumberFormat().format(
skebStatus.clientRequestCount,
),
),
].join(' '),
),
WidgetSpan(
child: Icon(
Icons.open_in_new,
size: style.fontSize,
),
),
],
),
),
),
);
}
}
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: d25ddfb398cae2bf230758c6f5b7a7648acaedd5
resolved-ref: d25ddfb398cae2bf230758c6f5b7a7648acaedd5
ref: e430aec5a1a2774811a608d98bcc19edaf1b1eb4
resolved-ref: e430aec5a1a2774811a608d98bcc19edaf1b1eb4
url: "https://github.com/poppingmoon/misskey_dart"
source: git
version: "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dependencies:
misskey_dart:
git:
url: https://github.com/poppingmoon/misskey_dart
ref: d25ddfb398cae2bf230758c6f5b7a7648acaedd5
ref: e430aec5a1a2774811a608d98bcc19edaf1b1eb4
package_info_plus: ^4.2.0
photo_view: ^0.14.0
punycode: ^1.0.0
Expand Down