Compare commits
No commits in common. "a8e0ade0c8b857daffcb8f0a8b10787d9927c878" and "e07da3efa5bba29f781523c1da75a37ac6eca1de" have entirely different histories.
a8e0ade0c8
...
e07da3efa5
@ -17,7 +17,6 @@ const kAppDrawerPreferCollapse = 'app_drawer_prefer_collapse';
|
|||||||
const kAppNotifyWithHaptic = 'app_notify_with_haptic';
|
const kAppNotifyWithHaptic = 'app_notify_with_haptic';
|
||||||
const kAppExpandPostLink = 'app_expand_post_link';
|
const kAppExpandPostLink = 'app_expand_post_link';
|
||||||
const kAppExpandChatLink = 'app_expand_chat_link';
|
const kAppExpandChatLink = 'app_expand_chat_link';
|
||||||
const kAppRealmCompactView = 'app_realm_compact_view';
|
|
||||||
|
|
||||||
const Map<String, FilterQuality> kImageQualityLevel = {
|
const Map<String, FilterQuality> kImageQualityLevel = {
|
||||||
'settingsImageQualityLowest': FilterQuality.none,
|
'settingsImageQualityLowest': FilterQuality.none,
|
||||||
@ -73,13 +72,6 @@ class ConfigProvider extends ChangeNotifier {
|
|||||||
return prefs.getString(kNetworkServerStoreKey) ?? kNetworkServerDefault;
|
return prefs.getString(kNetworkServerStoreKey) ?? kNetworkServerDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get realmCompactView {
|
|
||||||
return prefs.getBool(kAppRealmCompactView) ?? false;
|
|
||||||
}
|
|
||||||
set realmCompactView(bool value) {
|
|
||||||
prefs.setBool(kAppRealmCompactView, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
set serverUrl(String url) {
|
set serverUrl(String url) {
|
||||||
prefs.setString(kNetworkServerStoreKey, url);
|
prefs.setString(kNetworkServerStoreKey, url);
|
||||||
_home.saveWidgetData("nex_server_url", url);
|
_home.saveWidgetData("nex_server_url", url);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:dismissible_page/dismissible_page.dart';
|
import 'package:dismissible_page/dismissible_page.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';
|
||||||
|
@ -104,7 +104,7 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
try {
|
try {
|
||||||
final sn = context.read<SnNetworkProvider>();
|
final sn = context.read<SnNetworkProvider>();
|
||||||
await sn.client.delete(
|
await sn.client.delete(
|
||||||
'/cgi/im/channels/${_channel!.realm?.alias ?? 'global'}/${_channel!.alias}/members/me',
|
'/cgi/im/channels/${_channel!.realm?.alias ?? 'global'}/${_channel!.id}/members/me',
|
||||||
);
|
);
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
Navigator.pop(context, false);
|
Navigator.pop(context, false);
|
||||||
|
@ -4,16 +4,17 @@ import 'package:gap/gap.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:surface/providers/config.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:surface/providers/sn_network.dart';
|
import 'package:surface/providers/sn_network.dart';
|
||||||
import 'package:surface/providers/userinfo.dart';
|
import 'package:surface/providers/userinfo.dart';
|
||||||
import 'package:surface/types/realm.dart';
|
import 'package:surface/types/realm.dart';
|
||||||
|
import 'package:surface/widgets/account/account_image.dart';
|
||||||
import 'package:surface/widgets/app_bar_leading.dart';
|
import 'package:surface/widgets/app_bar_leading.dart';
|
||||||
import 'package:surface/widgets/dialog.dart';
|
import 'package:surface/widgets/dialog.dart';
|
||||||
import 'package:surface/widgets/loading_indicator.dart';
|
import 'package:surface/widgets/loading_indicator.dart';
|
||||||
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
||||||
import 'package:surface/widgets/realm/realm_item.dart';
|
|
||||||
import 'package:surface/widgets/unauthorized_hint.dart';
|
import 'package:surface/widgets/unauthorized_hint.dart';
|
||||||
|
import 'package:surface/widgets/universal_image.dart';
|
||||||
|
|
||||||
class RealmScreen extends StatefulWidget {
|
class RealmScreen extends StatefulWidget {
|
||||||
const RealmScreen({super.key});
|
const RealmScreen({super.key});
|
||||||
@ -74,12 +75,12 @@ class _RealmScreenState extends State<RealmScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_isCompactView = context.read<ConfigProvider>().realmCompactView;
|
|
||||||
_fetchRealms();
|
_fetchRealms();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
final ua = context.read<UserProvider>();
|
final ua = context.read<UserProvider>();
|
||||||
|
|
||||||
if (!ua.isAuthorized) {
|
if (!ua.isAuthorized) {
|
||||||
@ -109,7 +110,6 @@ class _RealmScreenState extends State<RealmScreen> {
|
|||||||
icon: !_isCompactView ? const Icon(Symbols.view_list) : const Icon(Symbols.view_module),
|
icon: !_isCompactView ? const Icon(Symbols.view_list) : const Icon(Symbols.view_module),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() => _isCompactView = !_isCompactView);
|
setState(() => _isCompactView = !_isCompactView);
|
||||||
context.read<ConfigProvider>().realmCompactView = _isCompactView;
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Gap(8),
|
const Gap(8),
|
||||||
@ -134,46 +134,129 @@ class _RealmScreenState extends State<RealmScreen> {
|
|||||||
itemCount: _realms?.length ?? 0,
|
itemCount: _realms?.length ?? 0,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
final realm = _realms![idx];
|
final realm = _realms![idx];
|
||||||
|
if (_isCompactView) {
|
||||||
|
return ListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
leading: AccountImage(
|
||||||
|
content: realm.avatar,
|
||||||
|
fallbackWidget: const Icon(Symbols.group, size: 20),
|
||||||
|
),
|
||||||
|
title: Text(realm.name),
|
||||||
|
subtitle: Text(
|
||||||
|
realm.description,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
trailing: PopupMenuButton(
|
||||||
|
itemBuilder: (BuildContext context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.edit),
|
||||||
|
const Gap(16),
|
||||||
|
Text('edit').tr(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).pushNamed(
|
||||||
|
'realmManage',
|
||||||
|
queryParameters: {'editing': realm.alias},
|
||||||
|
).then((value) {
|
||||||
|
if (value != null) {
|
||||||
|
_fetchRealms();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.delete),
|
||||||
|
const Gap(16),
|
||||||
|
Text('delete').tr(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
_deleteRealm(realm);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).pushNamed(
|
||||||
|
'realmDetail',
|
||||||
|
pathParameters: {'alias': realm.alias},
|
||||||
|
).then((value) {
|
||||||
|
if (value == true) {
|
||||||
|
_fetchRealms();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return RealmItemWidget(
|
return Container(
|
||||||
showPopularity: false,
|
constraints: BoxConstraints(maxWidth: 640),
|
||||||
item: realm,
|
child: Card(
|
||||||
isListView: _isCompactView,
|
margin: const EdgeInsets.all(12),
|
||||||
actionListView: [
|
child: InkWell(
|
||||||
PopupMenuItem(
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
child: Row(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.edit),
|
AspectRatio(
|
||||||
const Gap(16),
|
aspectRatio: 16 / 7,
|
||||||
Text('edit').tr(),
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
child: Container(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: (realm.banner?.isEmpty ?? true)
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: AutoResizeUniversalImage(
|
||||||
|
sn.getAttachmentUrl(realm.banner!),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: -30,
|
||||||
|
left: 18,
|
||||||
|
child: AccountImage(
|
||||||
|
content: realm.avatar,
|
||||||
|
radius: 24,
|
||||||
|
fallbackWidget: const Icon(Symbols.group, size: 24),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(20 + 12),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(realm.name).textStyle(Theme.of(context).textTheme.titleMedium!),
|
||||||
|
Text(realm.description).textStyle(Theme.of(context).textTheme.bodySmall!),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, bottom: 14),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'realmManage',
|
'realmDetail',
|
||||||
queryParameters: {'editing': realm.alias},
|
pathParameters: {'alias': realm.alias},
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
if (value == true) {
|
||||||
_fetchRealms();
|
_fetchRealms();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
),
|
||||||
child: Row(
|
).center();
|
||||||
children: [
|
|
||||||
const Icon(Symbols.delete),
|
|
||||||
const Gap(16),
|
|
||||||
Text('delete').tr(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
_deleteRealm(realm);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onUpdate: _fetchRealms,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -4,7 +4,6 @@ import 'package:gap/gap.dart';
|
|||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:surface/providers/config.dart';
|
|
||||||
import 'package:surface/providers/sn_network.dart';
|
import 'package:surface/providers/sn_network.dart';
|
||||||
import 'package:surface/providers/userinfo.dart';
|
import 'package:surface/providers/userinfo.dart';
|
||||||
import 'package:surface/types/chat.dart';
|
import 'package:surface/types/chat.dart';
|
||||||
@ -13,7 +12,6 @@ import 'package:surface/widgets/account/account_image.dart';
|
|||||||
import 'package:surface/widgets/dialog.dart';
|
import 'package:surface/widgets/dialog.dart';
|
||||||
import 'package:surface/widgets/loading_indicator.dart';
|
import 'package:surface/widgets/loading_indicator.dart';
|
||||||
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
||||||
import 'package:surface/widgets/realm/realm_item.dart';
|
|
||||||
import 'package:surface/widgets/universal_image.dart';
|
import 'package:surface/widgets/universal_image.dart';
|
||||||
|
|
||||||
class RealmDiscoveryScreen extends StatefulWidget {
|
class RealmDiscoveryScreen extends StatefulWidget {
|
||||||
@ -26,7 +24,6 @@ class RealmDiscoveryScreen extends StatefulWidget {
|
|||||||
class _RealmDiscoveryScreenState extends State<RealmDiscoveryScreen> {
|
class _RealmDiscoveryScreenState extends State<RealmDiscoveryScreen> {
|
||||||
List<SnRealm>? _realms;
|
List<SnRealm>? _realms;
|
||||||
bool _isBusy = false;
|
bool _isBusy = false;
|
||||||
bool _isCompactView = false;
|
|
||||||
|
|
||||||
Future<void> _fetchRealms() async {
|
Future<void> _fetchRealms() async {
|
||||||
try {
|
try {
|
||||||
@ -47,25 +44,16 @@ class _RealmDiscoveryScreenState extends State<RealmDiscoveryScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_isCompactView = context.read<ConfigProvider>().realmCompactView;
|
|
||||||
_fetchRealms();
|
_fetchRealms();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
|
||||||
return AppScaffold(
|
return AppScaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text('screenRealmDiscovery').tr(),
|
title: Text('screenRealmDiscovery').tr(),
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: _isCompactView ? const Icon(Symbols.view_list) : const Icon(Symbols.view_module),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() => _isCompactView = !_isCompactView);
|
|
||||||
context.read<ConfigProvider>().realmCompactView = _isCompactView;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Gap(8),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -78,16 +66,64 @@ class _RealmDiscoveryScreenState extends State<RealmDiscoveryScreen> {
|
|||||||
itemCount: _realms?.length ?? 0,
|
itemCount: _realms?.length ?? 0,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
final realm = _realms![idx];
|
final realm = _realms![idx];
|
||||||
return RealmItemWidget(
|
return Container(
|
||||||
item: realm,
|
constraints: BoxConstraints(maxWidth: 640),
|
||||||
isListView: _isCompactView,
|
child: Card(
|
||||||
onTap: () {
|
margin: const EdgeInsets.all(12),
|
||||||
showModalBottomSheet(
|
child: InkWell(
|
||||||
context: context,
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
builder: (context) => _RealmJoinPopup(realm: realm),
|
child: Column(
|
||||||
);
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
},
|
children: [
|
||||||
);
|
AspectRatio(
|
||||||
|
aspectRatio: 16 / 7,
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
child: Container(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: (realm.banner?.isEmpty ?? true)
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: AutoResizeUniversalImage(
|
||||||
|
sn.getAttachmentUrl(realm.banner!),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: -30,
|
||||||
|
left: 18,
|
||||||
|
child: AccountImage(
|
||||||
|
content: realm.avatar,
|
||||||
|
radius: 24,
|
||||||
|
fallbackWidget: const Icon(Symbols.group, size: 24),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(20 + 12),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(realm.name).textStyle(Theme.of(context).textTheme.titleMedium!),
|
||||||
|
Text(realm.description).textStyle(Theme.of(context).textTheme.bodySmall!),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, bottom: 14),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => _RealmJoinPopup(realm: realm),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).center();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -43,7 +43,6 @@ class SnRealm with _$SnRealm {
|
|||||||
@HiveField(10) required int accountId,
|
@HiveField(10) required int accountId,
|
||||||
@HiveField(11) required bool isPublic,
|
@HiveField(11) required bool isPublic,
|
||||||
@HiveField(12) required bool isCommunity,
|
@HiveField(12) required bool isCommunity,
|
||||||
@Default(0) int popularity,
|
|
||||||
}) = _SnRealm;
|
}) = _SnRealm;
|
||||||
|
|
||||||
factory SnRealm.fromJson(Map<String, dynamic> json) =>
|
factory SnRealm.fromJson(Map<String, dynamic> json) =>
|
||||||
|
@ -394,7 +394,6 @@ mixin _$SnRealm {
|
|||||||
bool get isPublic => throw _privateConstructorUsedError;
|
bool get isPublic => throw _privateConstructorUsedError;
|
||||||
@HiveField(12)
|
@HiveField(12)
|
||||||
bool get isCommunity => throw _privateConstructorUsedError;
|
bool get isCommunity => throw _privateConstructorUsedError;
|
||||||
int get popularity => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Serializes this SnRealm to a JSON map.
|
/// Serializes this SnRealm to a JSON map.
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
@ -424,8 +423,7 @@ abstract class $SnRealmCopyWith<$Res> {
|
|||||||
@HiveField(9) Map<String, dynamic>? accessPolicy,
|
@HiveField(9) Map<String, dynamic>? accessPolicy,
|
||||||
@HiveField(10) int accountId,
|
@HiveField(10) int accountId,
|
||||||
@HiveField(11) bool isPublic,
|
@HiveField(11) bool isPublic,
|
||||||
@HiveField(12) bool isCommunity,
|
@HiveField(12) bool isCommunity});
|
||||||
int popularity});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -457,7 +455,6 @@ class _$SnRealmCopyWithImpl<$Res, $Val extends SnRealm>
|
|||||||
Object? accountId = null,
|
Object? accountId = null,
|
||||||
Object? isPublic = null,
|
Object? isPublic = null,
|
||||||
Object? isCommunity = null,
|
Object? isCommunity = null,
|
||||||
Object? popularity = null,
|
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
id: null == id
|
id: null == id
|
||||||
@ -516,10 +513,6 @@ class _$SnRealmCopyWithImpl<$Res, $Val extends SnRealm>
|
|||||||
? _value.isCommunity
|
? _value.isCommunity
|
||||||
: isCommunity // ignore: cast_nullable_to_non_nullable
|
: isCommunity // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
popularity: null == popularity
|
|
||||||
? _value.popularity
|
|
||||||
: popularity // ignore: cast_nullable_to_non_nullable
|
|
||||||
as int,
|
|
||||||
) as $Val);
|
) as $Val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -545,8 +538,7 @@ abstract class _$$SnRealmImplCopyWith<$Res> implements $SnRealmCopyWith<$Res> {
|
|||||||
@HiveField(9) Map<String, dynamic>? accessPolicy,
|
@HiveField(9) Map<String, dynamic>? accessPolicy,
|
||||||
@HiveField(10) int accountId,
|
@HiveField(10) int accountId,
|
||||||
@HiveField(11) bool isPublic,
|
@HiveField(11) bool isPublic,
|
||||||
@HiveField(12) bool isCommunity,
|
@HiveField(12) bool isCommunity});
|
||||||
int popularity});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -576,7 +568,6 @@ class __$$SnRealmImplCopyWithImpl<$Res>
|
|||||||
Object? accountId = null,
|
Object? accountId = null,
|
||||||
Object? isPublic = null,
|
Object? isPublic = null,
|
||||||
Object? isCommunity = null,
|
Object? isCommunity = null,
|
||||||
Object? popularity = null,
|
|
||||||
}) {
|
}) {
|
||||||
return _then(_$SnRealmImpl(
|
return _then(_$SnRealmImpl(
|
||||||
id: null == id
|
id: null == id
|
||||||
@ -635,10 +626,6 @@ class __$$SnRealmImplCopyWithImpl<$Res>
|
|||||||
? _value.isCommunity
|
? _value.isCommunity
|
||||||
: isCommunity // ignore: cast_nullable_to_non_nullable
|
: isCommunity // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
popularity: null == popularity
|
|
||||||
? _value.popularity
|
|
||||||
: popularity // ignore: cast_nullable_to_non_nullable
|
|
||||||
as int,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,8 +648,7 @@ class _$SnRealmImpl extends _SnRealm {
|
|||||||
@HiveField(9) required final Map<String, dynamic>? accessPolicy,
|
@HiveField(9) required final Map<String, dynamic>? accessPolicy,
|
||||||
@HiveField(10) required this.accountId,
|
@HiveField(10) required this.accountId,
|
||||||
@HiveField(11) required this.isPublic,
|
@HiveField(11) required this.isPublic,
|
||||||
@HiveField(12) required this.isCommunity,
|
@HiveField(12) required this.isCommunity})
|
||||||
this.popularity = 0})
|
|
||||||
: _members = members,
|
: _members = members,
|
||||||
_accessPolicy = accessPolicy,
|
_accessPolicy = accessPolicy,
|
||||||
super._();
|
super._();
|
||||||
@ -727,13 +713,10 @@ class _$SnRealmImpl extends _SnRealm {
|
|||||||
@override
|
@override
|
||||||
@HiveField(12)
|
@HiveField(12)
|
||||||
final bool isCommunity;
|
final bool isCommunity;
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final int popularity;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnRealm(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, alias: $alias, name: $name, description: $description, members: $members, avatar: $avatar, banner: $banner, accessPolicy: $accessPolicy, accountId: $accountId, isPublic: $isPublic, isCommunity: $isCommunity, popularity: $popularity)';
|
return 'SnRealm(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, alias: $alias, name: $name, description: $description, members: $members, avatar: $avatar, banner: $banner, accessPolicy: $accessPolicy, accountId: $accountId, isPublic: $isPublic, isCommunity: $isCommunity)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -762,9 +745,7 @@ class _$SnRealmImpl extends _SnRealm {
|
|||||||
(identical(other.isPublic, isPublic) ||
|
(identical(other.isPublic, isPublic) ||
|
||||||
other.isPublic == isPublic) &&
|
other.isPublic == isPublic) &&
|
||||||
(identical(other.isCommunity, isCommunity) ||
|
(identical(other.isCommunity, isCommunity) ||
|
||||||
other.isCommunity == isCommunity) &&
|
other.isCommunity == isCommunity));
|
||||||
(identical(other.popularity, popularity) ||
|
|
||||||
other.popularity == popularity));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@ -784,8 +765,7 @@ class _$SnRealmImpl extends _SnRealm {
|
|||||||
const DeepCollectionEquality().hash(_accessPolicy),
|
const DeepCollectionEquality().hash(_accessPolicy),
|
||||||
accountId,
|
accountId,
|
||||||
isPublic,
|
isPublic,
|
||||||
isCommunity,
|
isCommunity);
|
||||||
popularity);
|
|
||||||
|
|
||||||
/// Create a copy of SnRealm
|
/// Create a copy of SnRealm
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -818,8 +798,7 @@ abstract class _SnRealm extends SnRealm {
|
|||||||
@HiveField(9) required final Map<String, dynamic>? accessPolicy,
|
@HiveField(9) required final Map<String, dynamic>? accessPolicy,
|
||||||
@HiveField(10) required final int accountId,
|
@HiveField(10) required final int accountId,
|
||||||
@HiveField(11) required final bool isPublic,
|
@HiveField(11) required final bool isPublic,
|
||||||
@HiveField(12) required final bool isCommunity,
|
@HiveField(12) required final bool isCommunity}) = _$SnRealmImpl;
|
||||||
final int popularity}) = _$SnRealmImpl;
|
|
||||||
const _SnRealm._() : super._();
|
const _SnRealm._() : super._();
|
||||||
|
|
||||||
factory _SnRealm.fromJson(Map<String, dynamic> json) = _$SnRealmImpl.fromJson;
|
factory _SnRealm.fromJson(Map<String, dynamic> json) = _$SnRealmImpl.fromJson;
|
||||||
@ -865,8 +844,6 @@ abstract class _SnRealm extends SnRealm {
|
|||||||
@override
|
@override
|
||||||
@HiveField(12)
|
@HiveField(12)
|
||||||
bool get isCommunity;
|
bool get isCommunity;
|
||||||
@override
|
|
||||||
int get popularity;
|
|
||||||
|
|
||||||
/// Create a copy of SnRealm
|
/// Create a copy of SnRealm
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@ -128,7 +128,6 @@ _$SnRealmImpl _$$SnRealmImplFromJson(Map<String, dynamic> json) =>
|
|||||||
accountId: (json['account_id'] as num).toInt(),
|
accountId: (json['account_id'] as num).toInt(),
|
||||||
isPublic: json['is_public'] as bool,
|
isPublic: json['is_public'] as bool,
|
||||||
isCommunity: json['is_community'] as bool,
|
isCommunity: json['is_community'] as bool,
|
||||||
popularity: (json['popularity'] as num?)?.toInt() ?? 0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$$SnRealmImplToJson(_$SnRealmImpl instance) =>
|
Map<String, dynamic> _$$SnRealmImplToJson(_$SnRealmImpl instance) =>
|
||||||
@ -147,5 +146,4 @@ Map<String, dynamic> _$$SnRealmImplToJson(_$SnRealmImpl instance) =>
|
|||||||
'account_id': instance.accountId,
|
'account_id': instance.accountId,
|
||||||
'is_public': instance.isPublic,
|
'is_public': instance.isPublic,
|
||||||
'is_community': instance.isCommunity,
|
'is_community': instance.isCommunity,
|
||||||
'popularity': instance.popularity,
|
|
||||||
};
|
};
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:gap/gap.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
|
||||||
import 'package:surface/providers/sn_network.dart';
|
|
||||||
import 'package:surface/types/realm.dart';
|
|
||||||
import 'package:surface/widgets/account/account_image.dart';
|
|
||||||
import 'package:surface/widgets/universal_image.dart';
|
|
||||||
|
|
||||||
class RealmItemWidget extends StatelessWidget {
|
|
||||||
final SnRealm item;
|
|
||||||
final bool isListView;
|
|
||||||
final List<PopupMenuItem>? actionListView;
|
|
||||||
final Function? onUpdate;
|
|
||||||
final Function? onTap;
|
|
||||||
final bool showPopularity;
|
|
||||||
|
|
||||||
const RealmItemWidget({
|
|
||||||
super.key,
|
|
||||||
required this.item,
|
|
||||||
required this.isListView,
|
|
||||||
this.actionListView,
|
|
||||||
this.onUpdate,
|
|
||||||
this.onTap,
|
|
||||||
this.showPopularity = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (isListView) {
|
|
||||||
return ListTile(
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
leading: AccountImage(
|
|
||||||
content: item.avatar,
|
|
||||||
fallbackWidget: const Icon(Symbols.group, size: 20),
|
|
||||||
),
|
|
||||||
title: Text(item.name),
|
|
||||||
subtitle: Row(
|
|
||||||
children: [
|
|
||||||
if (showPopularity) const Icon(Symbols.local_fire_department, size: 18).padding(right: 1),
|
|
||||||
if (showPopularity) Text(item.popularity.toString()),
|
|
||||||
if (showPopularity) const Gap(6),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
item.description,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
trailing:
|
|
||||||
actionListView != null ? PopupMenuButton(itemBuilder: (BuildContext context) => actionListView!) : null,
|
|
||||||
onTap: () {
|
|
||||||
if (onTap != null) {
|
|
||||||
onTap!();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GoRouter.of(context).pushNamed(
|
|
||||||
'realmDetail',
|
|
||||||
pathParameters: {'alias': item.alias},
|
|
||||||
).then((value) {
|
|
||||||
if (value == true) {
|
|
||||||
onUpdate?.call();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final sn = context.read<SnNetworkProvider>();
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
constraints: BoxConstraints(maxWidth: 640),
|
|
||||||
child: Card(
|
|
||||||
margin: const EdgeInsets.all(12),
|
|
||||||
child: InkWell(
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
AspectRatio(
|
|
||||||
aspectRatio: 16 / 7,
|
|
||||||
child: Stack(
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
fit: StackFit.expand,
|
|
||||||
children: [
|
|
||||||
ClipRRect(
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
||||||
child: Container(
|
|
||||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
|
||||||
child: (item.banner?.isEmpty ?? true)
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: AutoResizeUniversalImage(
|
|
||||||
sn.getAttachmentUrl(item.banner!),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: -30,
|
|
||||||
left: 18,
|
|
||||||
child: AccountImage(
|
|
||||||
content: item.avatar,
|
|
||||||
radius: 24,
|
|
||||||
fallbackWidget: const Icon(Symbols.group, size: 24),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Gap(20 + 12),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(item.name).textStyle(Theme.of(context).textTheme.titleMedium!),
|
|
||||||
if (showPopularity)
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(item.popularity.toString()),
|
|
||||||
const Icon(Symbols.local_fire_department, size: 16).padding(bottom: 2),
|
|
||||||
],
|
|
||||||
).padding(top: 6),
|
|
||||||
Text(item.description).textStyle(Theme.of(context).textTheme.bodySmall!),
|
|
||||||
],
|
|
||||||
).padding(horizontal: 24, bottom: 14),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
if (onTap != null) {
|
|
||||||
onTap!();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GoRouter.of(context).pushNamed(
|
|
||||||
'realmDetail',
|
|
||||||
pathParameters: {'alias': item.alias},
|
|
||||||
).then((value) {
|
|
||||||
if (value == true) {
|
|
||||||
onUpdate?.call();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
).center();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user