💄 Optimized publisher profile & personal profile
This commit is contained in:
51
lib/widgets/account/account_nameplate.dart
Normal file
51
lib/widgets/account/account_nameplate.dart
Normal file
@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/screens/account/profile.dart';
|
||||
import 'package:island/widgets/content/cloud_files.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
|
||||
class AccountNameplate extends HookConsumerWidget {
|
||||
final String name;
|
||||
const AccountNameplate({super.key, required this.name});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final user = ref.watch(accountProvider(name));
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 1 / MediaQuery.of(context).devicePixelRatio,
|
||||
color: Theme.of(context).dividerColor,
|
||||
),
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
margin: EdgeInsets.all(16),
|
||||
child: Card(
|
||||
margin: EdgeInsets.zero,
|
||||
elevation: 0,
|
||||
color: Colors.transparent,
|
||||
child: user.when(
|
||||
data: (account) => ListTile(
|
||||
leading: ProfilePictureWidget(
|
||||
fileId: account.profile.picture?.id,
|
||||
),
|
||||
title: Text(account.nick).bold(),
|
||||
subtitle: Text('@${account.name}'),
|
||||
),
|
||||
loading: () => ListTile(
|
||||
leading: const CircularProgressIndicator(),
|
||||
title: const Text('loading').bold().tr(),
|
||||
subtitle: const Text('...'),
|
||||
),
|
||||
error: (error, stackTrace) => ListTile(
|
||||
leading: Icon(Icons.error_outline, color: Colors.red),
|
||||
title: Text('somethingWentWrong').bold().tr(),
|
||||
subtitle: Text(error.toString()),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_popup_card/flutter_popup_card.dart';
|
||||
@ -12,6 +13,7 @@ import 'package:island/widgets/account/leveling_progress.dart';
|
||||
import 'package:island/widgets/account/status.dart';
|
||||
import 'package:island/widgets/content/cloud_files.dart';
|
||||
import 'package:island/widgets/response.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
class AccountProfileCard extends HookConsumerWidget {
|
||||
@ -34,17 +36,18 @@ class AccountProfileCard extends HookConsumerWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(12),
|
||||
if (data.profile.background != null)
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(12),
|
||||
),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 16 / 9,
|
||||
child: CloudImageWidget(file: data.profile.background),
|
||||
),
|
||||
),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 16 / 9,
|
||||
child: CloudImageWidget(file: data.profile.background),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
@ -76,6 +79,14 @@ class AccountProfileCard extends HookConsumerWidget {
|
||||
experience: data.profile.experience,
|
||||
progress: data.profile.levelingProgress,
|
||||
).padding(top: 12),
|
||||
FilledButton.tonalIcon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
context.router.pushPath('/account/${data.name}');
|
||||
},
|
||||
icon: const Icon(Symbols.launch),
|
||||
label: Text('accountProfileView').tr(),
|
||||
).padding(top: 12, horizontal: 2),
|
||||
],
|
||||
).padding(horizontal: 24, vertical: 16),
|
||||
],
|
||||
@ -86,9 +97,14 @@ class AccountProfileCard extends HookConsumerWidget {
|
||||
onRetry: () => ref.invalidate(accountProvider(uname)),
|
||||
),
|
||||
loading:
|
||||
() => Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: CircularProgressIndicator(),
|
||||
() => SizedBox(
|
||||
width: width,
|
||||
height: width,
|
||||
child:
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: CircularProgressIndicator(),
|
||||
).center(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -23,6 +24,8 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
||||
/// Callback when a point is selected
|
||||
final void Function(DateTime)? onPointSelected;
|
||||
|
||||
final String? eventCalanderUser;
|
||||
|
||||
const FortuneGraphWidget({
|
||||
super.key,
|
||||
required this.events,
|
||||
@ -30,6 +33,7 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
||||
this.maxWidth = double.infinity,
|
||||
this.height = 180,
|
||||
this.onPointSelected,
|
||||
this.eventCalanderUser,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -48,9 +52,27 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
||||
final content = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'fortuneGraph',
|
||||
).tr().fontSize(18).bold().padding(all: 16, bottom: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('fortuneGraph').tr().fontSize(18).bold(),
|
||||
if (eventCalanderUser != null)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.calendar_month, size: 20),
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: -4,
|
||||
vertical: -4,
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () {
|
||||
context.router.pushNamed(
|
||||
'/account/$eventCalanderUser/calendar',
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
).padding(all: 16, bottom: 24),
|
||||
SizedBox(
|
||||
height: height,
|
||||
child: filteredEvents.when(
|
||||
@ -75,7 +97,7 @@ class FortuneGraphWidget extends HookConsumerWidget {
|
||||
final maxDate = data.last.date;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
gridData: FlGridData(
|
||||
|
@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/models/user.dart';
|
||||
import 'package:island/pods/network.dart';
|
||||
import 'package:island/screens/account/profile.dart';
|
||||
import 'package:island/services/time.dart';
|
||||
import 'package:island/widgets/account/status_creation.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
@ -104,14 +106,15 @@ class AccountStatusWidget extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final userStatus = ref.watch(accountStatusProvider(uname));
|
||||
final status = ref.watch(accountStatusProvider(uname));
|
||||
final account = ref.watch(accountProvider(uname));
|
||||
|
||||
return Padding(
|
||||
padding: padding ?? EdgeInsets.symmetric(horizontal: 27, vertical: 4),
|
||||
child: Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
if (userStatus.value?.isOnline ?? false)
|
||||
if (status.value?.isOnline ?? false)
|
||||
Icon(
|
||||
Symbols.circle,
|
||||
fill: 1,
|
||||
@ -119,13 +122,24 @@ class AccountStatusWidget extends HookConsumerWidget {
|
||||
size: 16,
|
||||
).padding(right: 4)
|
||||
else
|
||||
Icon(Symbols.circle, color: Colors.grey, size: 16).padding(all: 4),
|
||||
if (userStatus.value?.isCustomized ?? false)
|
||||
Text(userStatus.value?.label ?? 'unknown'.tr())
|
||||
Icon(
|
||||
Symbols.circle,
|
||||
color: Colors.grey,
|
||||
size: 16,
|
||||
).padding(right: 4),
|
||||
if (status.value?.isCustomized ?? false)
|
||||
Text(status.value?.label ?? 'unknown'.tr())
|
||||
else
|
||||
Text((userStatus.value?.label ?? 'offline').toLowerCase()).tr(),
|
||||
Text((status.value?.label ?? 'offline').toLowerCase()).tr(),
|
||||
if (!(status.value?.isOnline ?? false) &&
|
||||
account.value?.profile.lastSeenAt != null)
|
||||
Flexible(
|
||||
child: Text(
|
||||
account.value!.profile.lastSeenAt!.formatRelative(context),
|
||||
).opacity(0.75),
|
||||
),
|
||||
],
|
||||
),
|
||||
).opacity((userStatus.value?.isCustomized ?? false) ? 1 : 0.85);
|
||||
).opacity((status.value?.isCustomized ?? false) ? 1 : 0.85);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user