✨ Post date
This commit is contained in:
parent
129c215a02
commit
36fb06b81c
@ -113,7 +113,8 @@
|
|||||||
"addVideo": "Add video",
|
"addVideo": "Add video",
|
||||||
"addPhoto": "Add photo",
|
"addPhoto": "Add photo",
|
||||||
"addFile": "Add file",
|
"addFile": "Add file",
|
||||||
"createDirectMessage": "New direct message",
|
"createDirectMessage": "Send new DM",
|
||||||
|
"gotoDirectMessage": "Go to DM",
|
||||||
"react": "React",
|
"react": "React",
|
||||||
"reactions": {
|
"reactions": {
|
||||||
"zero": "Reactions",
|
"zero": "Reactions",
|
||||||
@ -230,6 +231,7 @@
|
|||||||
"creatorHubUnselectedHint": "Pick / create a publisher to get started.",
|
"creatorHubUnselectedHint": "Pick / create a publisher to get started.",
|
||||||
"relationships": "Relationships",
|
"relationships": "Relationships",
|
||||||
"addFriend": "Send a Friend Request",
|
"addFriend": "Send a Friend Request",
|
||||||
|
"addFriendShort": "Add as Friend",
|
||||||
"addFriendHint": "Add a friend to your relationship list.",
|
"addFriendHint": "Add a friend to your relationship list.",
|
||||||
"pendingRequest": "Pending",
|
"pendingRequest": "Pending",
|
||||||
"waitingRequest": "Waiting",
|
"waitingRequest": "Waiting",
|
||||||
@ -426,5 +428,6 @@
|
|||||||
"checkInResultT3": "Good",
|
"checkInResultT3": "Good",
|
||||||
"checkInResultT4": "Best",
|
"checkInResultT4": "Best",
|
||||||
"accountProfileView": "View Profile",
|
"accountProfileView": "View Profile",
|
||||||
"unspecified": "Unspecified"
|
"unspecified": "Unspecified",
|
||||||
|
"added": "Added"
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:island/models/chat.dart';
|
||||||
|
import 'package:island/models/relationship.dart';
|
||||||
import 'package:island/models/user.dart';
|
import 'package:island/models/user.dart';
|
||||||
import 'package:island/pods/config.dart';
|
import 'package:island/pods/config.dart';
|
||||||
import 'package:island/pods/event_calendar.dart';
|
import 'package:island/pods/event_calendar.dart';
|
||||||
@ -16,6 +19,7 @@ import 'package:island/widgets/account/badge.dart';
|
|||||||
import 'package:island/widgets/account/fortune_graph.dart';
|
import 'package:island/widgets/account/fortune_graph.dart';
|
||||||
import 'package:island/widgets/account/leveling_progress.dart';
|
import 'package:island/widgets/account/leveling_progress.dart';
|
||||||
import 'package:island/widgets/account/status.dart';
|
import 'package:island/widgets/account/status.dart';
|
||||||
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
import 'package:island/widgets/content/cloud_files.dart';
|
import 'package:island/widgets/content/cloud_files.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
@ -62,6 +66,36 @@ Future<Color?> accountAppbarForcegroundColor(Ref ref, String uname) async {
|
|||||||
return dominantColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
|
return dominantColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
Future<SnChatRoom?> accountDirectChat(Ref ref, String uname) async {
|
||||||
|
final account = await ref.watch(accountProvider(uname).future);
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
try {
|
||||||
|
final resp = await apiClient.get("/chat/direct/${account.id}");
|
||||||
|
return SnChatRoom.fromJson(resp.data);
|
||||||
|
} catch (err) {
|
||||||
|
if (err is DioException && err.response?.statusCode == 404) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
Future<SnRelationship?> accountRelationship(Ref ref, String uname) async {
|
||||||
|
final account = await ref.watch(accountProvider(uname).future);
|
||||||
|
final apiClient = ref.watch(apiClientProvider);
|
||||||
|
try {
|
||||||
|
final resp = await apiClient.get("/relationships/${account.id}");
|
||||||
|
return SnRelationship.fromJson(resp.data);
|
||||||
|
} catch (err) {
|
||||||
|
if (err is DioException && err.response?.statusCode == 404) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@RoutePage()
|
@RoutePage()
|
||||||
class AccountProfileScreen extends HookConsumerWidget {
|
class AccountProfileScreen extends HookConsumerWidget {
|
||||||
final String name;
|
final String name;
|
||||||
@ -80,6 +114,9 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
EventCalendarQuery(uname: name, year: now.year, month: now.month),
|
EventCalendarQuery(uname: name, year: now.year, month: now.month),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
final accountChat = ref.watch(accountDirectChatProvider(name));
|
||||||
|
final accountRelationship = ref.watch(accountRelationshipProvider(name));
|
||||||
|
|
||||||
final appbarColor = ref.watch(accountAppbarForcegroundColorProvider(name));
|
final appbarColor = ref.watch(accountAppbarForcegroundColorProvider(name));
|
||||||
|
|
||||||
final appbarShadow = Shadow(
|
final appbarShadow = Shadow(
|
||||||
@ -88,6 +125,100 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
offset: Offset(1.0, 1.0),
|
offset: Offset(1.0, 1.0),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Future<void> relationshipAction() async {
|
||||||
|
if (accountRelationship.value != null) return;
|
||||||
|
showLoadingModal(context);
|
||||||
|
try {
|
||||||
|
final client = ref.watch(apiClientProvider);
|
||||||
|
await client.post('/relationships/${account.value!.id}/friends');
|
||||||
|
ref.invalidate(accountRelationshipProvider(name));
|
||||||
|
} catch (err) {
|
||||||
|
showErrorAlert(err);
|
||||||
|
} finally {
|
||||||
|
if (context.mounted) hideLoadingModal(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> directMessageAction() async {
|
||||||
|
if (!account.hasValue) return;
|
||||||
|
if (accountChat.value != null) {
|
||||||
|
context.router.pushPath('/chat/${accountChat.value!.id}');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showLoadingModal(context);
|
||||||
|
try {
|
||||||
|
final client = ref.watch(apiClientProvider);
|
||||||
|
final resp = await client.post(
|
||||||
|
'/chat/direct',
|
||||||
|
data: {'related_user_id': account.value!.id},
|
||||||
|
);
|
||||||
|
final chat = SnChatRoom.fromJson(resp.data);
|
||||||
|
if (context.mounted) context.router.pushPath('/chat/${chat.id}');
|
||||||
|
ref.invalidate(accountDirectChatProvider(name));
|
||||||
|
} catch (err) {
|
||||||
|
showErrorAlert(err);
|
||||||
|
} finally {
|
||||||
|
if (context.mounted) hideLoadingModal(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> buildSubcolumn(SnAccount data) {
|
||||||
|
return [
|
||||||
|
if (data.profile.birthday != null)
|
||||||
|
Row(
|
||||||
|
spacing: 6,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.cake, size: 17, fill: 1),
|
||||||
|
Text(data.profile.birthday!.formatCustom('yyyy-MM-dd')),
|
||||||
|
Text('·').bold(),
|
||||||
|
Text(
|
||||||
|
'${DateTime.now().difference(data.profile.birthday!).inDays ~/ 365} yrs old',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (data.profile.location.isNotEmpty)
|
||||||
|
Row(
|
||||||
|
spacing: 6,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.location_on, size: 17, fill: 1),
|
||||||
|
Text(data.profile.location),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (data.profile.pronouns.isNotEmpty || data.profile.gender.isNotEmpty)
|
||||||
|
Row(
|
||||||
|
spacing: 6,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.person, size: 17, fill: 1),
|
||||||
|
Text(
|
||||||
|
data.profile.gender.isEmpty
|
||||||
|
? 'unspecified'.tr()
|
||||||
|
: data.profile.gender,
|
||||||
|
),
|
||||||
|
Text('·').bold(),
|
||||||
|
Text(
|
||||||
|
data.profile.pronouns.isEmpty
|
||||||
|
? 'unspecified'.tr()
|
||||||
|
: data.profile.pronouns,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (data.profile.firstName.isNotEmpty ||
|
||||||
|
data.profile.middleName.isNotEmpty ||
|
||||||
|
data.profile.lastName.isNotEmpty)
|
||||||
|
Row(
|
||||||
|
spacing: 6,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.id_card, size: 17, fill: 1),
|
||||||
|
if (data.profile.firstName.isNotEmpty)
|
||||||
|
Text(data.profile.firstName),
|
||||||
|
if (data.profile.middleName.isNotEmpty)
|
||||||
|
Text(data.profile.middleName),
|
||||||
|
if (data.profile.lastName.isNotEmpty) Text(data.profile.lastName),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return account.when(
|
return account.when(
|
||||||
data:
|
data:
|
||||||
(data) => AppScaffold(
|
(data) => AppScaffold(
|
||||||
@ -196,74 +327,12 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
spacing: 24,
|
spacing: 24,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
if (buildSubcolumn(data).isNotEmpty)
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Column(
|
||||||
spacing: 2,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
spacing: 2,
|
||||||
if (data.profile.birthday != null)
|
children: buildSubcolumn(data),
|
||||||
Row(
|
),
|
||||||
spacing: 6,
|
|
||||||
children: [
|
|
||||||
const Icon(Symbols.cake, size: 17, fill: 1),
|
|
||||||
Text(
|
|
||||||
data.profile.birthday!.formatCustom(
|
|
||||||
'yyyy-MM-dd',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text('·').bold(),
|
|
||||||
Text(
|
|
||||||
'${DateTime.now().difference(data.profile.birthday!).inDays ~/ 365} yrs old',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (data.profile.location.isNotEmpty)
|
|
||||||
Row(
|
|
||||||
spacing: 6,
|
|
||||||
children: [
|
|
||||||
const Icon(
|
|
||||||
Symbols.location_on,
|
|
||||||
size: 17,
|
|
||||||
fill: 1,
|
|
||||||
),
|
|
||||||
Text(data.profile.location),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (data.profile.pronouns.isNotEmpty ||
|
|
||||||
data.profile.gender.isNotEmpty)
|
|
||||||
Row(
|
|
||||||
spacing: 6,
|
|
||||||
children: [
|
|
||||||
const Icon(Symbols.person, size: 17, fill: 1),
|
|
||||||
Text(
|
|
||||||
data.profile.gender.isEmpty
|
|
||||||
? 'unspecified'.tr()
|
|
||||||
: data.profile.gender,
|
|
||||||
),
|
|
||||||
Text('·').bold(),
|
|
||||||
Text(
|
|
||||||
data.profile.pronouns.isEmpty
|
|
||||||
? 'unspecified'.tr()
|
|
||||||
: data.profile.pronouns,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (data.profile.firstName.isNotEmpty ||
|
|
||||||
data.profile.middleName.isNotEmpty ||
|
|
||||||
data.profile.lastName.isNotEmpty)
|
|
||||||
Row(
|
|
||||||
spacing: 6,
|
|
||||||
children: [
|
|
||||||
const Icon(Symbols.id_card, size: 17, fill: 1),
|
|
||||||
if (data.profile.firstName.isNotEmpty)
|
|
||||||
Text(data.profile.firstName),
|
|
||||||
if (data.profile.middleName.isNotEmpty)
|
|
||||||
Text(data.profile.middleName),
|
|
||||||
if (data.profile.lastName.isNotEmpty)
|
|
||||||
Text(data.profile.lastName),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -308,7 +377,57 @@ class AccountProfileScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: const Divider(height: 1).padding(top: 24),
|
child: const Divider(height: 1).padding(top: 24, bottom: 12),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Row(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: FilledButton.icon(
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: WidgetStatePropertyAll(
|
||||||
|
accountRelationship.value == null
|
||||||
|
? null
|
||||||
|
: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
foregroundColor: WidgetStatePropertyAll(
|
||||||
|
accountRelationship.value == null
|
||||||
|
? null
|
||||||
|
: Theme.of(context).colorScheme.onSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: relationshipAction,
|
||||||
|
label:
|
||||||
|
Text(
|
||||||
|
accountRelationship.value == null
|
||||||
|
? 'addFriendShort'
|
||||||
|
: 'added',
|
||||||
|
).tr(),
|
||||||
|
icon:
|
||||||
|
accountRelationship.value == null
|
||||||
|
? const Icon(Symbols.person_add)
|
||||||
|
: const Icon(Symbols.person_check),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: FilledButton.icon(
|
||||||
|
onPressed: directMessageAction,
|
||||||
|
icon: const Icon(Symbols.message),
|
||||||
|
label:
|
||||||
|
Text(
|
||||||
|
accountChat.value == null
|
||||||
|
? 'createDirectMessage'
|
||||||
|
: 'gotoDirectMessage',
|
||||||
|
maxLines: 1,
|
||||||
|
).tr(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 16),
|
||||||
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: const Divider(height: 1).padding(top: 12),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -395,5 +395,249 @@ class _AccountAppbarForcegroundColorProviderElement
|
|||||||
String get uname => (origin as AccountAppbarForcegroundColorProvider).uname;
|
String get uname => (origin as AccountAppbarForcegroundColorProvider).uname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _$accountDirectChatHash() => r'60d0015fc2a3c8fc2190bb41d6818cf3027d9d0a';
|
||||||
|
|
||||||
|
/// See also [accountDirectChat].
|
||||||
|
@ProviderFor(accountDirectChat)
|
||||||
|
const accountDirectChatProvider = AccountDirectChatFamily();
|
||||||
|
|
||||||
|
/// See also [accountDirectChat].
|
||||||
|
class AccountDirectChatFamily extends Family<AsyncValue<SnChatRoom?>> {
|
||||||
|
/// See also [accountDirectChat].
|
||||||
|
const AccountDirectChatFamily();
|
||||||
|
|
||||||
|
/// See also [accountDirectChat].
|
||||||
|
AccountDirectChatProvider call(String uname) {
|
||||||
|
return AccountDirectChatProvider(uname);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AccountDirectChatProvider getProviderOverride(
|
||||||
|
covariant AccountDirectChatProvider provider,
|
||||||
|
) {
|
||||||
|
return call(provider.uname);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'accountDirectChatProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [accountDirectChat].
|
||||||
|
class AccountDirectChatProvider extends AutoDisposeFutureProvider<SnChatRoom?> {
|
||||||
|
/// See also [accountDirectChat].
|
||||||
|
AccountDirectChatProvider(String uname)
|
||||||
|
: this._internal(
|
||||||
|
(ref) => accountDirectChat(ref as AccountDirectChatRef, uname),
|
||||||
|
from: accountDirectChatProvider,
|
||||||
|
name: r'accountDirectChatProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$accountDirectChatHash,
|
||||||
|
dependencies: AccountDirectChatFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
AccountDirectChatFamily._allTransitiveDependencies,
|
||||||
|
uname: uname,
|
||||||
|
);
|
||||||
|
|
||||||
|
AccountDirectChatProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.uname,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String uname;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(
|
||||||
|
FutureOr<SnChatRoom?> Function(AccountDirectChatRef provider) create,
|
||||||
|
) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: AccountDirectChatProvider._internal(
|
||||||
|
(ref) => create(ref as AccountDirectChatRef),
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
uname: uname,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeFutureProviderElement<SnChatRoom?> createElement() {
|
||||||
|
return _AccountDirectChatProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is AccountDirectChatProvider && other.uname == uname;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, uname.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin AccountDirectChatRef on AutoDisposeFutureProviderRef<SnChatRoom?> {
|
||||||
|
/// The parameter `uname` of this provider.
|
||||||
|
String get uname;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AccountDirectChatProviderElement
|
||||||
|
extends AutoDisposeFutureProviderElement<SnChatRoom?>
|
||||||
|
with AccountDirectChatRef {
|
||||||
|
_AccountDirectChatProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get uname => (origin as AccountDirectChatProvider).uname;
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$accountRelationshipHash() =>
|
||||||
|
r'cb7d0d3f8cd4f23ad9d2d529872c540dac483d4f';
|
||||||
|
|
||||||
|
/// See also [accountRelationship].
|
||||||
|
@ProviderFor(accountRelationship)
|
||||||
|
const accountRelationshipProvider = AccountRelationshipFamily();
|
||||||
|
|
||||||
|
/// See also [accountRelationship].
|
||||||
|
class AccountRelationshipFamily extends Family<AsyncValue<SnRelationship?>> {
|
||||||
|
/// See also [accountRelationship].
|
||||||
|
const AccountRelationshipFamily();
|
||||||
|
|
||||||
|
/// See also [accountRelationship].
|
||||||
|
AccountRelationshipProvider call(String uname) {
|
||||||
|
return AccountRelationshipProvider(uname);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AccountRelationshipProvider getProviderOverride(
|
||||||
|
covariant AccountRelationshipProvider provider,
|
||||||
|
) {
|
||||||
|
return call(provider.uname);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'accountRelationshipProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [accountRelationship].
|
||||||
|
class AccountRelationshipProvider
|
||||||
|
extends AutoDisposeFutureProvider<SnRelationship?> {
|
||||||
|
/// See also [accountRelationship].
|
||||||
|
AccountRelationshipProvider(String uname)
|
||||||
|
: this._internal(
|
||||||
|
(ref) => accountRelationship(ref as AccountRelationshipRef, uname),
|
||||||
|
from: accountRelationshipProvider,
|
||||||
|
name: r'accountRelationshipProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$accountRelationshipHash,
|
||||||
|
dependencies: AccountRelationshipFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
AccountRelationshipFamily._allTransitiveDependencies,
|
||||||
|
uname: uname,
|
||||||
|
);
|
||||||
|
|
||||||
|
AccountRelationshipProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.uname,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String uname;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(
|
||||||
|
FutureOr<SnRelationship?> Function(AccountRelationshipRef provider) create,
|
||||||
|
) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: AccountRelationshipProvider._internal(
|
||||||
|
(ref) => create(ref as AccountRelationshipRef),
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
uname: uname,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeFutureProviderElement<SnRelationship?> createElement() {
|
||||||
|
return _AccountRelationshipProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is AccountRelationshipProvider && other.uname == uname;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, uname.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
|
// ignore: unused_element
|
||||||
|
mixin AccountRelationshipRef on AutoDisposeFutureProviderRef<SnRelationship?> {
|
||||||
|
/// The parameter `uname` of this provider.
|
||||||
|
String get uname;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AccountRelationshipProviderElement
|
||||||
|
extends AutoDisposeFutureProviderElement<SnRelationship?>
|
||||||
|
with AccountRelationshipRef {
|
||||||
|
_AccountRelationshipProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get uname => (origin as AccountRelationshipProvider).uname;
|
||||||
|
}
|
||||||
|
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||||
|
@ -47,6 +47,7 @@ class PostDetailScreen extends HookConsumerWidget {
|
|||||||
PostItem(
|
PostItem(
|
||||||
item: post!,
|
item: post!,
|
||||||
isOpenable: false,
|
isOpenable: false,
|
||||||
|
isFullPost: true,
|
||||||
backgroundColor: isWide ? Colors.transparent : null,
|
backgroundColor: isWide ? Colors.transparent : null,
|
||||||
),
|
),
|
||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
@ -63,7 +64,6 @@ class PostDetailScreen extends HookConsumerWidget {
|
|||||||
right: 0,
|
right: 0,
|
||||||
child: Material(
|
child: Material(
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
color: Colors.transparent,
|
|
||||||
child: PostQuickReply(
|
child: PostQuickReply(
|
||||||
parent: post,
|
parent: post,
|
||||||
onPosted: () {
|
onPosted: () {
|
||||||
|
@ -5,12 +5,14 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/post.dart';
|
import 'package:island/models/post.dart';
|
||||||
import 'package:island/pods/network.dart';
|
import 'package:island/pods/network.dart';
|
||||||
import 'package:island/pods/userinfo.dart';
|
import 'package:island/pods/userinfo.dart';
|
||||||
import 'package:island/route.gr.dart';
|
import 'package:island/route.gr.dart';
|
||||||
import 'package:island/services/responsive.dart';
|
import 'package:island/services/responsive.dart';
|
||||||
|
import 'package:island/services/time.dart';
|
||||||
import 'package:island/widgets/account/account_name.dart';
|
import 'package:island/widgets/account/account_name.dart';
|
||||||
import 'package:island/widgets/alert.dart';
|
import 'package:island/widgets/alert.dart';
|
||||||
import 'package:island/widgets/app_scaffold.dart';
|
import 'package:island/widgets/app_scaffold.dart';
|
||||||
@ -26,6 +28,7 @@ class PostItem extends HookConsumerWidget {
|
|||||||
final SnPost item;
|
final SnPost item;
|
||||||
final EdgeInsets? padding;
|
final EdgeInsets? padding;
|
||||||
final bool isOpenable;
|
final bool isOpenable;
|
||||||
|
final bool isFullPost;
|
||||||
final bool showReferencePost;
|
final bool showReferencePost;
|
||||||
final Function? onRefresh;
|
final Function? onRefresh;
|
||||||
final Function(SnPost)? onUpdate;
|
final Function(SnPost)? onUpdate;
|
||||||
@ -35,6 +38,7 @@ class PostItem extends HookConsumerWidget {
|
|||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
this.padding,
|
this.padding,
|
||||||
this.isOpenable = true,
|
this.isOpenable = true,
|
||||||
|
this.isFullPost = false,
|
||||||
this.showReferencePost = true,
|
this.showReferencePost = true,
|
||||||
this.onRefresh,
|
this.onRefresh,
|
||||||
this.onUpdate,
|
this.onUpdate,
|
||||||
@ -153,6 +157,13 @@ class PostItem extends HookConsumerWidget {
|
|||||||
VerificationMark(
|
VerificationMark(
|
||||||
mark: item.publisher.verification!,
|
mark: item.publisher.verification!,
|
||||||
).padding(left: 4),
|
).padding(left: 4),
|
||||||
|
Spacer(),
|
||||||
|
Text(
|
||||||
|
isFullPost
|
||||||
|
? item.publishedAt.formatSystem()
|
||||||
|
: item.publishedAt.formatRelative(context),
|
||||||
|
).fontSize(11).alignment(Alignment.bottomRight),
|
||||||
|
const Gap(4),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// Add visibility indicator if not public (visibility != 0)
|
// Add visibility indicator if not public (visibility != 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user