From 95af7140cda76aa0da0f565cd6c98ee9fefb1bb0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 22 Dec 2024 13:54:46 +0800 Subject: [PATCH] :lipstick: Optimize app bar --- assets/translations/en-US.json | 2 +- assets/translations/zh-CN.json | 2 +- assets/translations/zh-HK.json | 2 +- assets/translations/zh-TW.json | 2 +- lib/screens/account/pfp.dart | 115 ++++++++++++------------ lib/screens/post/publisher_page.dart | 125 ++++++++++++++------------- 6 files changed, 131 insertions(+), 117 deletions(-) diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index bbc9b8f..02fba8d 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -57,7 +57,7 @@ "reply": "Reply", "unset": "Unset", "untitled": "Untitled", - "postDetail": "Post detail", + "postDetail": "Post Detail", "postNoun": "Post", "postReadMore": "Read more", "postReadEstimate": "Est read time {}", diff --git a/assets/translations/zh-CN.json b/assets/translations/zh-CN.json index 010a260..f1de935 100644 --- a/assets/translations/zh-CN.json +++ b/assets/translations/zh-CN.json @@ -416,7 +416,7 @@ "accountStatus": "状态", "accountStatusOnline": "在线", "accountStatusOffline": "离线", - "accountStatusLastSeen": "最后一次在 {} 上线", + "accountStatusLastSeen": "最后一次上线于 {}", "postArticle": "Solar Network 上的文章", "postStory": "Solar Network 上的故事", "articleWrittenAt": "发表于 {}", diff --git a/assets/translations/zh-HK.json b/assets/translations/zh-HK.json index d6e006e..fcd16a8 100644 --- a/assets/translations/zh-HK.json +++ b/assets/translations/zh-HK.json @@ -416,7 +416,7 @@ "accountStatus": "狀態", "accountStatusOnline": "在線", "accountStatusOffline": "離線", - "accountStatusLastSeen": "最後一次在 {} 上線", + "accountStatusLastSeen": "最後一次上線於 {}", "postArticle": "Solar Network 上的文章", "postStory": "Solar Network 上的故事", "articleWrittenAt": "發表於 {}", diff --git a/assets/translations/zh-TW.json b/assets/translations/zh-TW.json index 25588eb..7760052 100644 --- a/assets/translations/zh-TW.json +++ b/assets/translations/zh-TW.json @@ -416,7 +416,7 @@ "accountStatus": "狀態", "accountStatusOnline": "線上", "accountStatusOffline": "離線", - "accountStatusLastSeen": "最後一次在 {} 上線", + "accountStatusLastSeen": "最後一次上線於 {}", "postArticle": "Solar Network 上的文章", "postStory": "Solar Network 上的故事", "articleWrittenAt": "發表於 {}", diff --git a/lib/screens/account/pfp.dart b/lib/screens/account/pfp.dart index d957921..81fad70 100644 --- a/lib/screens/account/pfp.dart +++ b/lib/screens/account/pfp.dart @@ -228,65 +228,72 @@ class _UserScreenState extends State with SingleTickerProviderStateM body: CustomScrollView( controller: _scrollController, slivers: [ - SliverAppBar( - expandedHeight: _appBarHeight, - title: _account == null - ? Text('loading').tr() - : RichText( - textAlign: TextAlign.center, - text: TextSpan(children: [ - TextSpan( - text: _account!.nick, - style: Theme.of(context).textTheme.titleLarge!.copyWith( - color: Theme.of(context).appBarTheme.foregroundColor!, - shadows: labelShadows, - ), - ), - const TextSpan(text: '\n'), - TextSpan( - text: '@${_account!.name}', - style: Theme.of(context).textTheme.bodySmall!.copyWith( - color: Theme.of(context).appBarTheme.foregroundColor!, - shadows: labelShadows, - ), - ), - ]), + Theme( + data: Theme.of(context).copyWith( + appBarTheme: Theme.of(context).appBarTheme.copyWith( + foregroundColor: Colors.white, ), - pinned: true, - flexibleSpace: _account != null - ? Stack( - fit: StackFit.expand, - children: [ - UniversalImage( - sn.getAttachmentUrl(_account!.banner), - fit: BoxFit.cover, - height: imageHeight, - width: _appBarWidth, - cacheHeight: imageHeight, - cacheWidth: _appBarWidth, - ), - Positioned( - top: 0, - left: 0, - right: 0, - height: 56 + MediaQuery.of(context).padding.top, - child: ClipRect( - child: BackdropFilter( - filter: ImageFilter.blur( - sigmaX: _appBarBlur, - sigmaY: _appBarBlur, - ), - child: Container( - color: Colors.black.withOpacity( - clampDouble(_appBarBlur * 0.1, 0, 0.5), + ), + child: SliverAppBar( + expandedHeight: _appBarHeight, + title: _account == null + ? Text('loading').tr() + : RichText( + textAlign: TextAlign.center, + text: TextSpan(children: [ + TextSpan( + text: _account!.nick, + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: Colors.white, + shadows: labelShadows, + ), + ), + const TextSpan(text: '\n'), + TextSpan( + text: '@${_account!.name}', + style: Theme.of(context).textTheme.bodySmall!.copyWith( + color: Colors.white, + shadows: labelShadows, + ), + ), + ]), + ), + pinned: true, + flexibleSpace: _account != null + ? Stack( + fit: StackFit.expand, + children: [ + UniversalImage( + sn.getAttachmentUrl(_account!.banner), + fit: BoxFit.cover, + height: imageHeight, + width: _appBarWidth, + cacheHeight: imageHeight, + cacheWidth: _appBarWidth, + ), + Positioned( + top: 0, + left: 0, + right: 0, + height: 56 + MediaQuery.of(context).padding.top, + child: ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur( + sigmaX: _appBarBlur, + sigmaY: _appBarBlur, + ), + child: Container( + color: Colors.black.withOpacity( + clampDouble(_appBarBlur * 0.1, 0, 0.5), + ), ), ), ), ), - ), - ], - ) - : null, + ], + ) + : null, + ), ), if (_account != null) SliverToBoxAdapter( diff --git a/lib/screens/post/publisher_page.dart b/lib/screens/post/publisher_page.dart index 70d30b9..654fed0 100644 --- a/lib/screens/post/publisher_page.dart +++ b/lib/screens/post/publisher_page.dart @@ -277,70 +277,77 @@ class _PostPublisherScreenState extends State with SingleTi handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), sliver: MultiSliver( children: [ - SliverAppBar( - expandedHeight: _appBarHeight, - title: _publisher == null - ? Text('loading').tr() - : RichText( - textAlign: TextAlign.center, - text: TextSpan(children: [ - TextSpan( - text: _publisher!.nick, - style: Theme.of(context).textTheme.titleLarge!.copyWith( - color: Theme.of(context).appBarTheme.foregroundColor!, - shadows: labelShadows, - ), - ), - const TextSpan(text: '\n'), - TextSpan( - text: '@${_publisher!.name}', - style: Theme.of(context).textTheme.bodySmall!.copyWith( - color: Colors.white, - shadows: labelShadows, - ), - ), - ]), - ), - pinned: true, - flexibleSpace: _publisher != null - ? Stack( - fit: StackFit.expand, - children: [ - if (_publisher!.banner.isNotEmpty) - UniversalImage( - sn.getAttachmentUrl(_publisher!.banner), - fit: BoxFit.cover, - height: imageHeight, - width: _appBarWidth, - cacheHeight: imageHeight, - cacheWidth: _appBarWidth, - ) - else - Container( - color: Theme.of(context).colorScheme.surfaceContainer, + Theme( + data: Theme.of(context).copyWith( + appBarTheme: Theme.of(context).appBarTheme.copyWith( + foregroundColor: Colors.white, + ), + ), + child: SliverAppBar( + expandedHeight: _appBarHeight, + title: _publisher == null + ? Text('loading').tr() + : RichText( + textAlign: TextAlign.center, + text: TextSpan(children: [ + TextSpan( + text: _publisher!.nick, + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: Colors.white, + shadows: labelShadows, + ), ), - Positioned( - top: 0, - left: 0, - right: 0, - height: 56 + MediaQuery.of(context).padding.top, - child: ClipRect( - child: BackdropFilter( - filter: ImageFilter.blur( - sigmaX: _appBarBlur, - sigmaY: _appBarBlur, - ), - child: Container( - color: Colors.black.withOpacity( - clampDouble(_appBarBlur * 0.1, 0, 0.5), + const TextSpan(text: '\n'), + TextSpan( + text: '@${_publisher!.name}', + style: Theme.of(context).textTheme.bodySmall!.copyWith( + color: Colors.white, + shadows: labelShadows, + ), + ), + ]), + ), + pinned: true, + flexibleSpace: _publisher != null + ? Stack( + fit: StackFit.expand, + children: [ + if (_publisher!.banner.isNotEmpty) + UniversalImage( + sn.getAttachmentUrl(_publisher!.banner), + fit: BoxFit.cover, + height: imageHeight, + width: _appBarWidth, + cacheHeight: imageHeight, + cacheWidth: _appBarWidth, + ) + else + Container( + color: Theme.of(context).colorScheme.surfaceContainer, + ), + Positioned( + top: 0, + left: 0, + right: 0, + height: 56 + MediaQuery.of(context).padding.top, + child: ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur( + sigmaX: _appBarBlur, + sigmaY: _appBarBlur, + ), + child: Container( + color: Colors.black.withOpacity( + clampDouble(_appBarBlur * 0.1, 0, 0.5), + ), ), ), ), ), - ), - ], - ) - : null, + ], + ) + : null, + ), ), if (_publisher != null) SliverToBoxAdapter(