Compare commits
8 Commits
2.2.2+53
...
068ddcdcdc
| Author | SHA1 | Date | |
|---|---|---|---|
| 068ddcdcdc | |||
| f4e9252ca0 | |||
| 3b1e918117 | |||
| ed7981fdaf | |||
| 9698ca53e4 | |||
| ddc1dc7daf | |||
| 1625a957f8 | |||
| 2dc50d627e |
@@ -17,6 +17,7 @@
|
|||||||
android:label="Solian"
|
android:label="Solian"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:enableOnBackInvokedCallback="true"
|
||||||
android:requestLegacyExternalStorage="true">
|
android:requestLegacyExternalStorage="true">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
|||||||
@@ -215,8 +215,9 @@
|
|||||||
"sensitiveContentCollapsed": "Sensitive content has been collapsed.",
|
"sensitiveContentCollapsed": "Sensitive content has been collapsed.",
|
||||||
"sensitiveContentDescription": "This content has been marked as sensitive, and may not be suitable for all viewers.",
|
"sensitiveContentDescription": "This content has been marked as sensitive, and may not be suitable for all viewers.",
|
||||||
"sensitiveContentReveal": "Reveal",
|
"sensitiveContentReveal": "Reveal",
|
||||||
"serverConnecting": "Connecting to server...",
|
"serverConnecting": "Connecting...",
|
||||||
"serverDisconnected": "Lost connection from server",
|
"serverDisconnected": "Connection Lost",
|
||||||
|
"serverConnected": "Connected",
|
||||||
"fieldChatAlias": "Channel Alias",
|
"fieldChatAlias": "Channel Alias",
|
||||||
"fieldChatAliasHint": "The unique channel alias within the site, used to represent the channel in URL, leave blank to auto generate. Should be URL-Safe.",
|
"fieldChatAliasHint": "The unique channel alias within the site, used to represent the channel in URL, leave blank to auto generate. Should be URL-Safe.",
|
||||||
"fieldChatName": "Name",
|
"fieldChatName": "Name",
|
||||||
@@ -294,6 +295,7 @@
|
|||||||
"addAttachmentFromCameraPhoto": "Take photo",
|
"addAttachmentFromCameraPhoto": "Take photo",
|
||||||
"addAttachmentFromCameraVideo": "Take video",
|
"addAttachmentFromCameraVideo": "Take video",
|
||||||
"addAttachmentFromRandomId": "Link via RID",
|
"addAttachmentFromRandomId": "Link via RID",
|
||||||
|
"attachmentDetailInfo": "Attachment details",
|
||||||
"attachmentPastedImage": "Pasted Image",
|
"attachmentPastedImage": "Pasted Image",
|
||||||
"attachmentInsertLink": "Insert Link",
|
"attachmentInsertLink": "Insert Link",
|
||||||
"attachmentSetAsPostThumbnail": "Set as post thumbnail",
|
"attachmentSetAsPostThumbnail": "Set as post thumbnail",
|
||||||
|
|||||||
@@ -213,8 +213,9 @@
|
|||||||
"sensitiveContentCollapsed": "敏感内容已折叠。",
|
"sensitiveContentCollapsed": "敏感内容已折叠。",
|
||||||
"sensitiveContentDescription": "此内容已被标记,可能不适合所有人查看。",
|
"sensitiveContentDescription": "此内容已被标记,可能不适合所有人查看。",
|
||||||
"sensitiveContentReveal": "显示内容",
|
"sensitiveContentReveal": "显示内容",
|
||||||
"serverConnecting": "正在连接服务器…",
|
"serverConnecting": "正在连接…",
|
||||||
"serverDisconnected": "已与服务器断开连接",
|
"serverDisconnected": "已断开连接",
|
||||||
|
"serverConnected": "已连接",
|
||||||
"fieldChatAlias": "频道别名",
|
"fieldChatAlias": "频道别名",
|
||||||
"fieldChatAliasHint": "全站范围内唯一的频道别名,用于在 URL 中表示该频道,留空则自动生成。应遵循 URL-Safe 的原则。",
|
"fieldChatAliasHint": "全站范围内唯一的频道别名,用于在 URL 中表示该频道,留空则自动生成。应遵循 URL-Safe 的原则。",
|
||||||
"fieldChatName": "名称",
|
"fieldChatName": "名称",
|
||||||
@@ -292,6 +293,7 @@
|
|||||||
"addAttachmentFromCameraPhoto": "拍摄照片",
|
"addAttachmentFromCameraPhoto": "拍摄照片",
|
||||||
"addAttachmentFromCameraVideo": "拍摄视频",
|
"addAttachmentFromCameraVideo": "拍摄视频",
|
||||||
"addAttachmentFromRandomId": "通过访问 ID 链接",
|
"addAttachmentFromRandomId": "通过访问 ID 链接",
|
||||||
|
"attachmentDetailInfo": "附件详细信息",
|
||||||
"attachmentPastedImage": "粘贴的图片",
|
"attachmentPastedImage": "粘贴的图片",
|
||||||
"attachmentInsertLink": "插入连接",
|
"attachmentInsertLink": "插入连接",
|
||||||
"attachmentSetAsPostThumbnail": "设置为帖子缩略图",
|
"attachmentSetAsPostThumbnail": "设置为帖子缩略图",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:animations/animations.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:flutter_expandable_fab/flutter_expandable_fab.dart';
|
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
|
||||||
@@ -8,6 +9,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:surface/providers/post.dart';
|
import 'package:surface/providers/post.dart';
|
||||||
import 'package:surface/providers/sn_network.dart';
|
import 'package:surface/providers/sn_network.dart';
|
||||||
|
import 'package:surface/screens/post/post_detail.dart';
|
||||||
import 'package:surface/types/post.dart';
|
import 'package:surface/types/post.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';
|
||||||
@@ -210,6 +212,7 @@ class _ExploreScreenState extends State<ExploreScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SliverGap(8),
|
||||||
SliverInfiniteList(
|
SliverInfiniteList(
|
||||||
itemCount: _posts.length,
|
itemCount: _posts.length,
|
||||||
isLoading: _isBusy,
|
isLoading: _isBusy,
|
||||||
@@ -217,27 +220,37 @@ class _ExploreScreenState extends State<ExploreScreen> {
|
|||||||
hasReachedMax: _postCount != null && _posts.length >= _postCount!,
|
hasReachedMax: _postCount != null && _posts.length >= _postCount!,
|
||||||
onFetchData: _fetchPosts,
|
onFetchData: _fetchPosts,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return GestureDetector(
|
return Center(
|
||||||
child: PostItem(
|
child: OpenContainer(
|
||||||
data: _posts[idx],
|
closedBuilder: (_, __) => Container(
|
||||||
maxWidth: 640,
|
constraints: const BoxConstraints(maxWidth: 640),
|
||||||
onChanged: (data) {
|
child: PostItem(
|
||||||
setState(() => _posts[idx] = data);
|
data: _posts[idx],
|
||||||
},
|
maxWidth: 640,
|
||||||
onDeleted: () {
|
onChanged: (data) {
|
||||||
_refreshPosts();
|
setState(() => _posts[idx] = data);
|
||||||
},
|
},
|
||||||
|
onDeleted: () {
|
||||||
|
_refreshPosts();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
openBuilder: (_, close) => PostDetailScreen(
|
||||||
|
slug: _posts[idx].id.toString(),
|
||||||
|
preload: _posts[idx],
|
||||||
|
onBack: close,
|
||||||
|
),
|
||||||
|
openColor: Colors.transparent,
|
||||||
|
openElevation: 0,
|
||||||
|
closedColor: Theme.of(context).colorScheme.surface,
|
||||||
|
transitionType: ContainerTransitionType.fade,
|
||||||
|
closedShape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
|
||||||
GoRouter.of(context).pushNamed(
|
|
||||||
'postDetail',
|
|
||||||
pathParameters: {'slug': _posts[idx].id.toString()},
|
|
||||||
extra: _posts[idx],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => const Divider(height: 1),
|
separatorBuilder: (_, __) => const Gap(8),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import 'package:surface/providers/userinfo.dart';
|
|||||||
import 'package:surface/types/post.dart';
|
import 'package:surface/types/post.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_background.dart';
|
||||||
import 'package:surface/widgets/post/post_comment_list.dart';
|
import 'package:surface/widgets/post/post_comment_list.dart';
|
||||||
import 'package:surface/widgets/post/post_item.dart';
|
import 'package:surface/widgets/post/post_item.dart';
|
||||||
import 'package:surface/widgets/post/post_mini_editor.dart';
|
import 'package:surface/widgets/post/post_mini_editor.dart';
|
||||||
@@ -20,12 +21,9 @@ import 'package:surface/widgets/post/post_mini_editor.dart';
|
|||||||
class PostDetailScreen extends StatefulWidget {
|
class PostDetailScreen extends StatefulWidget {
|
||||||
final String slug;
|
final String slug;
|
||||||
final SnPost? preload;
|
final SnPost? preload;
|
||||||
|
final Function? onBack;
|
||||||
|
|
||||||
const PostDetailScreen({
|
const PostDetailScreen({super.key, required this.slug, this.preload, this.onBack});
|
||||||
super.key,
|
|
||||||
required this.slug,
|
|
||||||
this.preload,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PostDetailScreen> createState() => _PostDetailScreenState();
|
State<PostDetailScreen> createState() => _PostDetailScreenState();
|
||||||
@@ -67,123 +65,129 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
final ua = context.watch<UserProvider>();
|
final ua = context.watch<UserProvider>();
|
||||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||||
|
|
||||||
return Scaffold(
|
return AppBackground(
|
||||||
appBar: AppBar(
|
isRoot: widget.onBack != null,
|
||||||
leading: BackButton(
|
child: Scaffold(
|
||||||
onPressed: () {
|
appBar: AppBar(
|
||||||
if (GoRouter.of(context).canPop()) {
|
leading: BackButton(
|
||||||
GoRouter.of(context).pop(context);
|
onPressed: () {
|
||||||
return;
|
if (widget.onBack != null) {
|
||||||
}
|
widget.onBack!.call();
|
||||||
GoRouter.of(context).replaceNamed('explore');
|
}
|
||||||
},
|
if (GoRouter.of(context).canPop()) {
|
||||||
),
|
GoRouter.of(context).pop(context);
|
||||||
title: _data?.body['title'] != null
|
return;
|
||||||
? RichText(
|
}
|
||||||
textAlign: TextAlign.center,
|
GoRouter.of(context).replaceNamed('explore');
|
||||||
text: TextSpan(children: [
|
},
|
||||||
TextSpan(
|
|
||||||
text: _data?.body['title'] ?? 'postNoun'.tr(),
|
|
||||||
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
||||||
color: Theme.of(context).appBarTheme.foregroundColor!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const TextSpan(text: '\n'),
|
|
||||||
TextSpan(
|
|
||||||
text: 'postDetail'.tr(),
|
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
|
||||||
color: Theme.of(context).appBarTheme.foregroundColor!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
)
|
|
||||||
: Text('postDetail').tr(),
|
|
||||||
),
|
|
||||||
body: CustomScrollView(
|
|
||||||
slivers: [
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: LoadingIndicator(isActive: _isBusy),
|
|
||||||
),
|
),
|
||||||
if (_data != null)
|
title: _data?.body['title'] != null
|
||||||
SliverToBoxAdapter(
|
? RichText(
|
||||||
child: PostItem(
|
textAlign: TextAlign.center,
|
||||||
data: _data!,
|
text: TextSpan(children: [
|
||||||
maxWidth: 640,
|
TextSpan(
|
||||||
showComments: false,
|
text: _data?.body['title'] ?? 'postNoun'.tr(),
|
||||||
showFullPost: true,
|
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
||||||
onChanged: (data) {
|
color: Theme.of(context).appBarTheme.foregroundColor!,
|
||||||
setState(() => _data = data);
|
|
||||||
},
|
|
||||||
onDeleted: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SliverToBoxAdapter(child: Divider(height: 1)),
|
|
||||||
if (_data != null)
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: Container(
|
|
||||||
constraints: const BoxConstraints(maxWidth: 640),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Icon(Symbols.comment, size: 24),
|
|
||||||
const Gap(16),
|
|
||||||
Text('postCommentsDetailed')
|
|
||||||
.plural(_data!.metric.replyCount)
|
|
||||||
.textStyle(Theme.of(context).textTheme.titleLarge!),
|
|
||||||
],
|
|
||||||
).padding(horizontal: 20, vertical: 12).center(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_data != null && ua.isAuthorized)
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: Container(
|
|
||||||
height: 240,
|
|
||||||
constraints: const BoxConstraints(maxWidth: 640),
|
|
||||||
margin:
|
|
||||||
ResponsiveBreakpoints.of(context).largerThan(MOBILE) ? const EdgeInsets.all(8) : EdgeInsets.zero,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
|
||||||
? const BorderRadius.all(Radius.circular(8))
|
|
||||||
: BorderRadius.zero,
|
|
||||||
border: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
|
||||||
? Border.all(
|
|
||||||
color: Theme.of(context).dividerColor,
|
|
||||||
width: 1 / devicePixelRatio,
|
|
||||||
)
|
|
||||||
: Border.symmetric(
|
|
||||||
horizontal: BorderSide(
|
|
||||||
color: Theme.of(context).dividerColor,
|
|
||||||
width: 1 / devicePixelRatio,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const TextSpan(text: '\n'),
|
||||||
child: PostMiniEditor(
|
TextSpan(
|
||||||
postReplyId: _data!.id,
|
text: 'postDetail'.tr(),
|
||||||
onPost: () {
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
setState(() {
|
color: Theme.of(context).appBarTheme.foregroundColor!,
|
||||||
_data = _data!.copyWith(
|
),
|
||||||
metric: _data!.metric.copyWith(
|
),
|
||||||
replyCount: _data!.metric.replyCount + 1,
|
]),
|
||||||
),
|
maxLines: 2,
|
||||||
);
|
overflow: TextOverflow.ellipsis,
|
||||||
});
|
)
|
||||||
_childListKey.currentState!.refresh();
|
: Text('postDetail').tr(),
|
||||||
|
),
|
||||||
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: LoadingIndicator(isActive: _isBusy),
|
||||||
|
),
|
||||||
|
if (_data != null)
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: PostItem(
|
||||||
|
data: _data!,
|
||||||
|
maxWidth: 640,
|
||||||
|
showComments: false,
|
||||||
|
showFullPost: true,
|
||||||
|
onChanged: (data) {
|
||||||
|
setState(() => _data = data);
|
||||||
|
},
|
||||||
|
onDeleted: () {
|
||||||
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
).center(),
|
),
|
||||||
),
|
const SliverToBoxAdapter(child: Divider(height: 1)),
|
||||||
if (_data != null)
|
if (_data != null)
|
||||||
PostCommentSliverList(
|
SliverToBoxAdapter(
|
||||||
key: _childListKey,
|
child: Container(
|
||||||
parentPostId: _data!.id,
|
constraints: const BoxConstraints(maxWidth: 640),
|
||||||
maxWidth: 640,
|
child: Row(
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
SliverGap(math.max(MediaQuery.of(context).padding.bottom, 16)),
|
children: [
|
||||||
],
|
const Icon(Symbols.comment, size: 24),
|
||||||
|
const Gap(16),
|
||||||
|
Text('postCommentsDetailed')
|
||||||
|
.plural(_data!.metric.replyCount)
|
||||||
|
.textStyle(Theme.of(context).textTheme.titleLarge!),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 20, vertical: 12).center(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_data != null && ua.isAuthorized)
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Container(
|
||||||
|
height: 240,
|
||||||
|
constraints: const BoxConstraints(maxWidth: 640),
|
||||||
|
margin:
|
||||||
|
ResponsiveBreakpoints.of(context).largerThan(MOBILE) ? const EdgeInsets.all(8) : EdgeInsets.zero,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
||||||
|
? const BorderRadius.all(Radius.circular(8))
|
||||||
|
: BorderRadius.zero,
|
||||||
|
border: ResponsiveBreakpoints.of(context).largerThan(MOBILE)
|
||||||
|
? Border.all(
|
||||||
|
color: Theme.of(context).dividerColor,
|
||||||
|
width: 1 / devicePixelRatio,
|
||||||
|
)
|
||||||
|
: Border.symmetric(
|
||||||
|
horizontal: BorderSide(
|
||||||
|
color: Theme.of(context).dividerColor,
|
||||||
|
width: 1 / devicePixelRatio,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: PostMiniEditor(
|
||||||
|
postReplyId: _data!.id,
|
||||||
|
onPost: () {
|
||||||
|
setState(() {
|
||||||
|
_data = _data!.copyWith(
|
||||||
|
metric: _data!.metric.copyWith(
|
||||||
|
replyCount: _data!.metric.replyCount + 1,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
_childListKey.currentState!.refresh();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
).center(),
|
||||||
|
),
|
||||||
|
if (_data != null)
|
||||||
|
PostCommentSliverList(
|
||||||
|
key: _childListKey,
|
||||||
|
parentPostId: _data!.id,
|
||||||
|
maxWidth: 640,
|
||||||
|
),
|
||||||
|
SliverGap(math.max(MediaQuery.of(context).padding.bottom, 16)),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
subtitle: Text('settingsThemeMaterial3Description').tr(),
|
subtitle: Text('settingsThemeMaterial3Description').tr(),
|
||||||
contentPadding: const EdgeInsets.only(left: 24, right: 17),
|
contentPadding: const EdgeInsets.only(left: 24, right: 17),
|
||||||
secondary: const Icon(Symbols.new_releases),
|
secondary: const Icon(Symbols.new_releases),
|
||||||
value: _prefs.getBool(kMaterialYouToggleStoreKey) ?? false,
|
value: _prefs.getBool(kMaterialYouToggleStoreKey) ?? true,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_prefs.setBool(
|
_prefs.setBool(
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Future<ThemeData> createAppTheme(
|
|||||||
final hasAppBarBlurry = prefs.getBool(kAppbarTransparentStoreKey) ?? false;
|
final hasAppBarBlurry = prefs.getBool(kAppbarTransparentStoreKey) ?? false;
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
useMaterial3: useMaterial3 ?? (prefs.getBool(kMaterialYouToggleStoreKey) ?? false),
|
useMaterial3: useMaterial3 ?? (prefs.getBool(kMaterialYouToggleStoreKey) ?? true),
|
||||||
colorScheme: colorScheme,
|
colorScheme: colorScheme,
|
||||||
brightness: brightness,
|
brightness: brightness,
|
||||||
iconTheme: IconThemeData(
|
iconTheme: IconThemeData(
|
||||||
@@ -52,5 +52,15 @@ Future<ThemeData> createAppTheme(
|
|||||||
foregroundColor: hasAppBarBlurry ? colorScheme.onSurface : colorScheme.onPrimary,
|
foregroundColor: hasAppBarBlurry ? colorScheme.onSurface : colorScheme.onPrimary,
|
||||||
),
|
),
|
||||||
scaffoldBackgroundColor: Colors.transparent,
|
scaffoldBackgroundColor: Colors.transparent,
|
||||||
|
pageTransitionsTheme: PageTransitionsTheme(
|
||||||
|
builders: {
|
||||||
|
TargetPlatform.android: PredictiveBackPageTransitionsBuilder(),
|
||||||
|
TargetPlatform.iOS: ZoomPageTransitionsBuilder(),
|
||||||
|
TargetPlatform.macOS: ZoomPageTransitionsBuilder(),
|
||||||
|
TargetPlatform.fuchsia: ZoomPageTransitionsBuilder(),
|
||||||
|
TargetPlatform.linux: ZoomPageTransitionsBuilder(),
|
||||||
|
TargetPlatform.windows: ZoomPageTransitionsBuilder(),
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import 'package:surface/providers/experience.dart';
|
|||||||
import 'package:surface/providers/sn_network.dart';
|
import 'package:surface/providers/sn_network.dart';
|
||||||
import 'package:surface/screens/account/profile_page.dart';
|
import 'package:surface/screens/account/profile_page.dart';
|
||||||
import 'package:surface/types/account.dart';
|
import 'package:surface/types/account.dart';
|
||||||
import 'package:surface/types/post.dart';
|
|
||||||
import 'package:surface/widgets/account/account_image.dart';
|
import 'package:surface/widgets/account/account_image.dart';
|
||||||
import 'package:surface/widgets/universal_image.dart';
|
import 'package:surface/widgets/universal_image.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ class _AttachmentZoomViewState extends State<AttachmentZoomView> {
|
|||||||
|
|
||||||
Color get _unFocusColor => Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
Color get _unFocusColor => Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||||
|
|
||||||
|
bool _showDetail = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final sn = context.read<SnNetworkProvider>();
|
final sn = context.read<SnNetworkProvider>();
|
||||||
@@ -144,218 +146,348 @@ class _AttachmentZoomViewState extends State<AttachmentZoomView> {
|
|||||||
onDismissed: () {
|
onDismissed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
direction: DismissiblePageDismissDirection.down,
|
direction: DismissiblePageDismissDirection.none,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
isFullScreen: true,
|
isFullScreen: true,
|
||||||
child: Scaffold(
|
child: GestureDetector(
|
||||||
body: Stack(
|
behavior: HitTestBehavior.translucent,
|
||||||
children: [
|
child: Scaffold(
|
||||||
Builder(builder: (context) {
|
body: Stack(
|
||||||
if (widget.data.length == 1) {
|
children: [
|
||||||
final heroTag = widget.heroTags?.first ?? uuid.v4();
|
Builder(builder: (context) {
|
||||||
return Hero(
|
if (widget.data.length == 1) {
|
||||||
tag: 'attachment-${widget.data.first.rid}-$heroTag',
|
final heroTag = widget.heroTags?.first ?? uuid.v4();
|
||||||
child: PhotoView(
|
return Hero(
|
||||||
key: Key('attachment-detail-${widget.data.first.rid}-$heroTag'),
|
tag: 'attachment-${widget.data.first.rid}-$heroTag',
|
||||||
backgroundDecoration: BoxDecoration(color: Colors.transparent),
|
child: PhotoView(
|
||||||
imageProvider: UniversalImage.provider(
|
key: Key('attachment-detail-${widget.data.first.rid}-$heroTag'),
|
||||||
sn.getAttachmentUrl(widget.data.first.rid),
|
backgroundDecoration: BoxDecoration(color: Colors.transparent),
|
||||||
),
|
imageProvider: UniversalImage.provider(
|
||||||
),
|
sn.getAttachmentUrl(widget.data.first.rid),
|
||||||
);
|
),
|
||||||
}
|
|
||||||
|
|
||||||
return PhotoViewGallery.builder(
|
|
||||||
pageController: _pageController,
|
|
||||||
scrollPhysics: const BouncingScrollPhysics(),
|
|
||||||
builder: (context, idx) {
|
|
||||||
final heroTag = widget.heroTags?.elementAt(idx) ?? uuid.v4();
|
|
||||||
return PhotoViewGalleryPageOptions(
|
|
||||||
imageProvider: UniversalImage.provider(
|
|
||||||
sn.getAttachmentUrl(widget.data.elementAt(idx).rid),
|
|
||||||
),
|
|
||||||
heroAttributes: PhotoViewHeroAttributes(
|
|
||||||
tag: 'attachment-${widget.data.first.rid}-$heroTag',
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
itemCount: widget.data.length,
|
|
||||||
loadingBuilder: (context, event) => Center(
|
return PhotoViewGallery.builder(
|
||||||
child: SizedBox(
|
pageController: _pageController,
|
||||||
width: 20.0,
|
scrollPhysics: const BouncingScrollPhysics(),
|
||||||
height: 20.0,
|
builder: (context, idx) {
|
||||||
child: CircularProgressIndicator(
|
final heroTag = widget.heroTags?.elementAt(idx) ?? uuid.v4();
|
||||||
value: event == null ? 0 : event.cumulativeBytesLoaded / (event.expectedTotalBytes ?? 1),
|
return PhotoViewGalleryPageOptions(
|
||||||
|
imageProvider: UniversalImage.provider(
|
||||||
|
sn.getAttachmentUrl(widget.data.elementAt(idx).rid),
|
||||||
|
),
|
||||||
|
heroAttributes: PhotoViewHeroAttributes(
|
||||||
|
tag: 'attachment-${widget.data.first.rid}-$heroTag',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: widget.data.length,
|
||||||
|
loadingBuilder: (context, event) => Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 20.0,
|
||||||
|
height: 20.0,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
value: event == null ? 0 : event.cumulativeBytesLoaded / (event.expectedTotalBytes ?? 1),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
backgroundDecoration: BoxDecoration(color: Colors.transparent),
|
||||||
backgroundDecoration: BoxDecoration(color: Colors.transparent),
|
);
|
||||||
);
|
}),
|
||||||
}),
|
Align(
|
||||||
Align(
|
alignment: Alignment.bottomCenter,
|
||||||
alignment: Alignment.bottomCenter,
|
child: IgnorePointer(
|
||||||
child: IgnorePointer(
|
child: Container(
|
||||||
child: Container(
|
height: 300,
|
||||||
height: 300,
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
gradient: LinearGradient(
|
||||||
gradient: LinearGradient(
|
begin: Alignment.bottomCenter,
|
||||||
begin: Alignment.bottomCenter,
|
end: Alignment.topCenter,
|
||||||
end: Alignment.topCenter,
|
colors: [
|
||||||
colors: [
|
Theme.of(context).colorScheme.surface,
|
||||||
Theme.of(context).colorScheme.surface,
|
Colors.transparent,
|
||||||
Colors.transparent,
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Positioned(
|
||||||
Positioned(
|
left: 16,
|
||||||
left: 16,
|
right: 16,
|
||||||
right: 16,
|
bottom: 16 + MediaQuery.of(context).padding.bottom,
|
||||||
bottom: 16 + MediaQuery.of(context).padding.bottom,
|
child: Material(
|
||||||
child: Material(
|
color: Colors.transparent,
|
||||||
color: Colors.transparent,
|
child: Builder(builder: (context) {
|
||||||
child: Builder(builder: (context) {
|
final ud = context.read<UserDirectoryProvider>();
|
||||||
final ud = context.read<UserDirectoryProvider>();
|
final item = widget.data.elementAt(
|
||||||
final item = widget.data.elementAt(
|
widget.data.length > 1 ? _pageController.page?.round() ?? 0 : 0,
|
||||||
widget.data.length > 1 ? _pageController.page?.round() ?? 0 : 0,
|
);
|
||||||
);
|
final account = ud.getAccountFromCache(item.accountId);
|
||||||
final account = ud.getAccountFromCache(item.accountId);
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (item.accountId > 0)
|
if (item.accountId > 0)
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
IgnorePointer(
|
IgnorePointer(
|
||||||
child: AccountImage(
|
child: AccountImage(
|
||||||
content: account?.avatar,
|
content: account?.avatar,
|
||||||
radius: 19,
|
radius: 19,
|
||||||
),
|
|
||||||
),
|
|
||||||
const Gap(8),
|
|
||||||
Expanded(
|
|
||||||
child: IgnorePointer(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'attachmentUploadBy'.tr(),
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
account?.nick ?? 'unknown'.tr(),
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const Gap(8),
|
||||||
if (widget.data.length > 1)
|
Expanded(
|
||||||
IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: Text(
|
child: Column(
|
||||||
'${(_pageController.page?.round() ?? 0) + 1}/${widget.data.length}',
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
style: GoogleFonts.robotoMono(fontSize: 13),
|
children: [
|
||||||
).padding(right: 8),
|
Text(
|
||||||
),
|
'attachmentUploadBy'.tr(),
|
||||||
InkWell(
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
|
||||||
onTap: _isDownloading
|
|
||||||
? null
|
|
||||||
: () => _saveToAlbum(widget.data.length > 1 ? _pageController.page?.round() ?? 0 : 0),
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(6),
|
|
||||||
child: !_isDownloading
|
|
||||||
? !_isCompletedDownload
|
|
||||||
? const Icon(Symbols.save_alt)
|
|
||||||
: const Icon(Symbols.download_done)
|
|
||||||
: SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
value: _progressOfDownload,
|
|
||||||
strokeWidth: 3,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
Text(
|
||||||
|
account?.nick ?? 'unknown'.tr(),
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
if (widget.data.length > 1)
|
||||||
|
IgnorePointer(
|
||||||
|
child: Text(
|
||||||
|
'${(_pageController.page?.round() ?? 0) + 1}/${widget.data.length}',
|
||||||
|
style: GoogleFonts.robotoMono(fontSize: 13),
|
||||||
|
).padding(right: 8),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
|
onTap: _isDownloading
|
||||||
|
? null
|
||||||
|
: () =>
|
||||||
|
_saveToAlbum(widget.data.length > 1 ? _pageController.page?.round() ?? 0 : 0),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(6),
|
||||||
|
child: !_isDownloading
|
||||||
|
? !_isCompletedDownload
|
||||||
|
? const Icon(Symbols.save_alt)
|
||||||
|
: const Icon(Symbols.download_done)
|
||||||
|
: SizedBox(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
value: _progressOfDownload,
|
||||||
|
strokeWidth: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Gap(4),
|
||||||
|
IgnorePointer(
|
||||||
|
child: Text(
|
||||||
|
item.alt,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
const Gap(4),
|
|
||||||
IgnorePointer(
|
|
||||||
child: Text(
|
|
||||||
item.alt,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const Gap(2),
|
||||||
const Gap(2),
|
IgnorePointer(
|
||||||
IgnorePointer(
|
child: Wrap(
|
||||||
child: Wrap(
|
spacing: 6,
|
||||||
spacing: 6,
|
children: [
|
||||||
children: [
|
if (item.metadata['exif'] == null)
|
||||||
if (item.metadata['exif'] == null)
|
Text(
|
||||||
|
'#${item.rid}',
|
||||||
|
style: metaTextStyle,
|
||||||
|
),
|
||||||
|
if (item.metadata['exif']?['Model'] != null)
|
||||||
|
Text(
|
||||||
|
'attachmentShotOn'.tr(args: [
|
||||||
|
item.metadata['exif']?['Model'],
|
||||||
|
]),
|
||||||
|
style: metaTextStyle,
|
||||||
|
).padding(right: 2),
|
||||||
|
if (item.metadata['exif']?['ISO'] != null)
|
||||||
|
Text(
|
||||||
|
'ISO${item.metadata['exif']?['ISO']}',
|
||||||
|
style: metaTextStyle,
|
||||||
|
).padding(right: 2),
|
||||||
|
if (item.metadata['exif']?['Aperture'] != null)
|
||||||
|
Text(
|
||||||
|
'f/${item.metadata['exif']?['Aperture']}',
|
||||||
|
style: metaTextStyle,
|
||||||
|
).padding(right: 2),
|
||||||
|
if (item.metadata['exif']?['Megapixels'] != null &&
|
||||||
|
item.metadata['exif']?['Model'] != null)
|
||||||
|
Text(
|
||||||
|
'${item.metadata['exif']?['Megapixels']}MP',
|
||||||
|
style: metaTextStyle,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Text(
|
||||||
|
item.size.formatBytes(),
|
||||||
|
style: metaTextStyle,
|
||||||
|
),
|
||||||
|
if (item.metadata['width'] != null && item.metadata['height'] != null)
|
||||||
|
Text(
|
||||||
|
'${item.metadata['width']}x${item.metadata['height']}',
|
||||||
|
style: metaTextStyle,
|
||||||
|
),
|
||||||
|
if (item.metadata['ratio'] != null)
|
||||||
|
Text(
|
||||||
|
(item.metadata['ratio'] as num).toStringAsFixed(2),
|
||||||
|
style: metaTextStyle,
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
'#${item.rid}',
|
item.mimetype,
|
||||||
style: metaTextStyle,
|
style: metaTextStyle,
|
||||||
),
|
),
|
||||||
if (item.metadata['exif']?['Model'] != null)
|
],
|
||||||
Text(
|
),
|
||||||
'attachmentShotOn'.tr(args: [
|
|
||||||
item.metadata['exif']?['Model'],
|
|
||||||
]),
|
|
||||||
style: metaTextStyle,
|
|
||||||
).padding(right: 2),
|
|
||||||
if (item.metadata['exif']?['ISO'] != null)
|
|
||||||
Text(
|
|
||||||
'ISO${item.metadata['exif']?['ISO']}',
|
|
||||||
style: metaTextStyle,
|
|
||||||
).padding(right: 2),
|
|
||||||
if (item.metadata['exif']?['Aperture'] != null)
|
|
||||||
Text(
|
|
||||||
'f/${item.metadata['exif']?['Aperture']}',
|
|
||||||
style: metaTextStyle,
|
|
||||||
).padding(right: 2),
|
|
||||||
if (item.metadata['exif']?['Megapixels'] != null && item.metadata['exif']?['Model'] != null)
|
|
||||||
Text(
|
|
||||||
'${item.metadata['exif']?['Megapixels']}MP',
|
|
||||||
style: metaTextStyle,
|
|
||||||
)
|
|
||||||
else
|
|
||||||
Text(
|
|
||||||
item.size.formatBytes(),
|
|
||||||
style: metaTextStyle,
|
|
||||||
),
|
|
||||||
if (item.metadata['width'] != null && item.metadata['height'] != null)
|
|
||||||
Text(
|
|
||||||
'${item.metadata['width']}x${item.metadata['height']}',
|
|
||||||
style: metaTextStyle,
|
|
||||||
),
|
|
||||||
if (item.metadata['ratio'] != null)
|
|
||||||
Text(
|
|
||||||
(item.metadata['ratio'] as num).toStringAsFixed(2),
|
|
||||||
style: metaTextStyle,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
item.mimetype,
|
|
||||||
style: metaTextStyle,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
}),
|
||||||
}),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
|
onVerticalDragUpdate: (details) {
|
||||||
|
if (_showDetail) return;
|
||||||
|
if (details.delta.dy < 0) {
|
||||||
|
_showDetail = true;
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => _AttachmentZoomDetailPopup(
|
||||||
|
data: widget.data.elementAt(widget.data.length > 1 ? _pageController.page?.round() ?? 0 : 0),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
_showDetail = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AttachmentZoomDetailPopup extends StatelessWidget {
|
||||||
|
final SnAttachment data;
|
||||||
|
|
||||||
|
const _AttachmentZoomDetailPopup({required this.data});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final ud = context.read<UserDirectoryProvider>();
|
||||||
|
final account = ud.getAccountFromCache(data.accountId);
|
||||||
|
|
||||||
|
const tableGap = TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(child: SizedBox(height: 16)),
|
||||||
|
TableCell(child: SizedBox(height: 16)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.info, size: 24),
|
||||||
|
const Gap(16),
|
||||||
|
Text('attachmentDetailInfo').tr().textStyle(Theme.of(context).textTheme.titleLarge!),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 20, top: 16, bottom: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Table(
|
||||||
|
columnWidths: {
|
||||||
|
0: IntrinsicColumnWidth(),
|
||||||
|
1: FlexColumnWidth(),
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Text('attachmentUploadBy').tr().padding(right: 16),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (data.accountId > 0)
|
||||||
|
AccountImage(
|
||||||
|
content: account?.avatar,
|
||||||
|
radius: 8,
|
||||||
|
),
|
||||||
|
const Gap(8),
|
||||||
|
Text(data.accountId > 0 ? account?.nick ?? 'unknown'.tr() : 'unknown'.tr()),
|
||||||
|
const Gap(8),
|
||||||
|
Text('#${data.accountId}', style: GoogleFonts.robotoMono()).opacity(0.75),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
tableGap,
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(child: Text('Mimetype').padding(right: 16)),
|
||||||
|
TableCell(child: Text(data.mimetype)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(child: Text('Size').padding(right: 16)),
|
||||||
|
TableCell(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(data.size.formatBytes()),
|
||||||
|
const Gap(12),
|
||||||
|
Text('${data.size} Bytes', style: GoogleFonts.robotoMono()).opacity(0.75),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(child: Text('Name').padding(right: 16)),
|
||||||
|
TableCell(child: Text(data.name)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (data.hash.isNotEmpty)
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(child: Text('Hash').padding(right: 16)),
|
||||||
|
TableCell(child: Text(data.hash, style: GoogleFonts.robotoMono(fontSize: 11)).opacity(0.9)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
tableGap,
|
||||||
|
...(data.metadata['exif']?.keys.map((k) => TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(child: Text(k).padding(right: 16)),
|
||||||
|
TableCell(child: Text(data.metadata['exif'][k].toString())),
|
||||||
|
],
|
||||||
|
)) ??
|
||||||
|
[]),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 20, vertical: 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
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: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/userinfo.dart';
|
import 'package:surface/providers/userinfo.dart';
|
||||||
@@ -18,13 +20,9 @@ class ConnectionIndicator extends StatelessWidget {
|
|||||||
final ua = context.read<UserProvider>();
|
final ua = context.read<UserProvider>();
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Container(
|
child: Material(
|
||||||
padding: EdgeInsets.only(
|
elevation: 2,
|
||||||
bottom: 8,
|
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))),
|
||||||
top: MediaQuery.of(context).padding.top + 8,
|
|
||||||
left: 24,
|
|
||||||
right: 24,
|
|
||||||
),
|
|
||||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
child: ua.isAuthorized
|
child: ua.isAuthorized
|
||||||
? Row(
|
? Row(
|
||||||
@@ -32,21 +30,25 @@ class ConnectionIndicator extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (ws.isBusy)
|
if (ws.isBusy)
|
||||||
Text('serverConnecting').tr().textColor(
|
Text('serverConnecting').tr().textColor(Theme.of(context).colorScheme.onSecondaryContainer)
|
||||||
Theme.of(context).colorScheme.onSecondaryContainer)
|
|
||||||
else if (!ws.isConnected)
|
else if (!ws.isConnected)
|
||||||
Text('serverDisconnected').tr().textColor(
|
Text('serverDisconnected').tr().textColor(Theme.of(context).colorScheme.onSecondaryContainer)
|
||||||
Theme.of(context).colorScheme.onSecondaryContainer),
|
else
|
||||||
|
Text('serverConnected').tr().textColor(Theme.of(context).colorScheme.onSecondaryContainer),
|
||||||
|
const Gap(8),
|
||||||
|
if (ws.isBusy)
|
||||||
|
const CircularProgressIndicator(strokeWidth: 2.5)
|
||||||
|
.width(12)
|
||||||
|
.height(12)
|
||||||
|
.padding(horizontal: 4, right: 4)
|
||||||
|
else if (!ws.isConnected)
|
||||||
|
const Icon(Symbols.power_off, size: 18)
|
||||||
|
else
|
||||||
|
const Icon(Symbols.power, size: 18),
|
||||||
],
|
],
|
||||||
)
|
).padding(horizontal: 8, vertical: 4)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
)
|
).opacity((ws.isBusy || !ws.isConnected) && ua.isAuthorized ? 1 : 0, animate: true).animate(
|
||||||
.height(
|
|
||||||
(ws.isBusy || !ws.isConnected) && ua.isAuthorized
|
|
||||||
? MediaQuery.of(context).padding.top + 36
|
|
||||||
: 0,
|
|
||||||
animate: true)
|
|
||||||
.animate(
|
|
||||||
const Duration(milliseconds: 300),
|
const Duration(milliseconds: 300),
|
||||||
Curves.easeInOut,
|
Curves.easeInOut,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ class _AppRailNavigationState extends State<AppRailNavigation> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context
|
context.read<NavigationProvider>().autoDetectIndex(GoRouter.maybeOf(context));
|
||||||
.read<NavigationProvider>()
|
|
||||||
.autoDetectIndex(GoRouter.maybeOf(context));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,11 +29,11 @@ class _AppRailNavigationState extends State<AppRailNavigation> {
|
|||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: nav,
|
listenable: nav,
|
||||||
builder: (context, _) {
|
builder: (context, _) {
|
||||||
final destinations =
|
final destinations = nav.destinations.where((ele) => ele.isPinned).toList();
|
||||||
nav.destinations.where((ele) => ele.isPinned).toList();
|
|
||||||
|
|
||||||
return NavigationRail(
|
return NavigationRail(
|
||||||
selectedIndex: nav.currentIndex,
|
selectedIndex:
|
||||||
|
nav.currentIndex != null && nav.currentIndex! < nav.pinnedDestinationCount ? nav.currentIndex : null,
|
||||||
destinations: [
|
destinations: [
|
||||||
...destinations.where((ele) => ele.isPinned).map((ele) {
|
...destinations.where((ele) => ele.isPinned).map((ele) {
|
||||||
return NavigationRailDestination(
|
return NavigationRailDestination(
|
||||||
|
|||||||
@@ -98,56 +98,58 @@ class AppRootScaffold extends StatelessWidget {
|
|||||||
iconMouseDown: Theme.of(context).colorScheme.primary,
|
iconMouseDown: Theme.of(context).colorScheme.primary,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final safeTop = MediaQuery.of(context).padding.top;
|
||||||
|
|
||||||
return AppBackground(
|
return AppBackground(
|
||||||
isRoot: true,
|
isRoot: true,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
key: globalRootScaffoldKey,
|
key: globalRootScaffoldKey,
|
||||||
body: Column(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS))
|
Column(
|
||||||
Container(
|
children: [
|
||||||
decoration: BoxDecoration(
|
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS))
|
||||||
border: Border(
|
Container(
|
||||||
bottom: BorderSide(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).dividerColor,
|
border: Border(
|
||||||
width: 1 / devicePixelRatio,
|
bottom: BorderSide(
|
||||||
),
|
color: Theme.of(context).dividerColor,
|
||||||
),
|
width: 1 / devicePixelRatio,
|
||||||
),
|
),
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: Platform.isMacOS ? MainAxisAlignment.center : MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
WindowTitleBarBox(
|
|
||||||
child: MoveWindow(
|
|
||||||
child: Text(
|
|
||||||
'Solar Network',
|
|
||||||
style: GoogleFonts.spaceGrotesk(),
|
|
||||||
).padding(horizontal: 12, vertical: 5),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!Platform.isMacOS)
|
child: Row(
|
||||||
Expanded(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
child: WindowTitleBarBox(
|
mainAxisAlignment: Platform.isMacOS ? MainAxisAlignment.center : MainAxisAlignment.start,
|
||||||
child: Row(
|
children: [
|
||||||
children: [
|
WindowTitleBarBox(
|
||||||
Expanded(child: MoveWindow()),
|
child: MoveWindow(
|
||||||
Row(
|
child: Text(
|
||||||
|
'Solar Network',
|
||||||
|
style: GoogleFonts.spaceGrotesk(),
|
||||||
|
).padding(horizontal: 12, vertical: 5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!Platform.isMacOS)
|
||||||
|
MoveWindow(
|
||||||
|
child: WindowTitleBarBox(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
MinimizeWindowButton(colors: windowButtonColor),
|
MinimizeWindowButton(colors: windowButtonColor),
|
||||||
MaximizeWindowButton(colors: windowButtonColor),
|
MaximizeWindowButton(colors: windowButtonColor),
|
||||||
CloseWindowButton(colors: windowButtonColor),
|
CloseWindowButton(colors: windowButtonColor),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
Expanded(child: innerWidget),
|
||||||
),
|
],
|
||||||
ConnectionIndicator(),
|
),
|
||||||
Expanded(child: innerWidget),
|
Positioned(top: safeTop > 0 ? safeTop : 16, right: 8, child: ConnectionIndicator()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
drawer: !isExpandedDrawer ? AppNavigationDrawer() : null,
|
drawer: !isExpandedDrawer ? AppNavigationDrawer() : null,
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ id = "solian"
|
|||||||
|
|
||||||
[[locations]]
|
[[locations]]
|
||||||
id = "solian"
|
id = "solian"
|
||||||
host = ["sn.solsynth.dev"]
|
hosts = ["sn.solsynth.dev"]
|
||||||
path = ["/"]
|
paths = ["/"]
|
||||||
[[locations.destinations]]
|
[[locations.destinations]]
|
||||||
id = "solian-web"
|
id = "solian-web"
|
||||||
uri = "files:///workdir/solian?fallback=index.html&index=index.html"
|
uri = "files:///workdir/solian?fallback=index.html&index=index.html"
|
||||||
|
|||||||
Reference in New Issue
Block a user