mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: hide logo if distribution == null (#536)
This commit is contained in:
@@ -11,7 +11,12 @@ import 'package:server_box/data/model/app/error.dart';
|
||||
|
||||
part 'server_private_info.g.dart';
|
||||
|
||||
/// In former version, it's called `ServerPrivateInfo`.
|
||||
/// In the first version, it's called `ServerPrivateInfo` which was designed to
|
||||
/// store the private information of a server.
|
||||
///
|
||||
/// Some params named as `spi` in the codebase which is the abbreviation of `ServerPrivateInfo`.
|
||||
///
|
||||
/// Nowaday, more fields are added to this class, but the name is still the same.
|
||||
@JsonSerializable()
|
||||
@HiveType(typeId: 3)
|
||||
class ServerPrivateInfo {
|
||||
|
||||
@@ -58,9 +58,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
late MediaQueryData _media;
|
||||
final List<String> _cardsOrder = [];
|
||||
|
||||
final _settings = Stores.setting;
|
||||
final _netSortType = ValueNotifier(_NetSortType.device);
|
||||
late final _collapse = Stores.setting.collapseUIDefault.fetch();
|
||||
late final _textFactor = TextScaler.linear(Stores.setting.textFactor.fetch());
|
||||
late final _collapse = _settings.collapseUIDefault.fetch();
|
||||
late final _textFactor = TextScaler.linear(_settings.textFactor.fetch());
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
@@ -71,7 +72,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final order = Stores.setting.detailCardOrder.fetch();
|
||||
final order = _settings.detailCardOrder.fetch();
|
||||
order.removeWhere((e) => !ServerDetailCards.names.contains(e));
|
||||
_cardsOrder.addAll(order);
|
||||
}
|
||||
@@ -92,12 +93,9 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
|
||||
Widget _buildMainPage(Server si) {
|
||||
final buildFuncs = !Stores.setting.moveServerFuncs.fetch();
|
||||
final logoUrl = si.spi.custom?.logoUrl ??
|
||||
Stores.setting.serverLogoUrl.fetch().selfIfNotNullEmpty;
|
||||
final buildLogo = logoUrl != null;
|
||||
final logo = _buildLogo(si);
|
||||
final children = [
|
||||
if (buildLogo)
|
||||
_buildLogo(logoUrl, si.status.more[StatusCmdType.sys]?.dist),
|
||||
logo,
|
||||
if (buildFuncs) ServerFuncBtns(spi: widget.spi),
|
||||
];
|
||||
for (final card in _cardsOrder) {
|
||||
@@ -141,12 +139,17 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLogo(String logoUrl, Dist? dist) {
|
||||
if (dist != null) {
|
||||
logoUrl = logoUrl
|
||||
.replaceFirst('{DIST}', dist.name)
|
||||
.replaceFirst('{BRIGHT}', context.isDark ? 'dark' : 'light');
|
||||
}
|
||||
Widget _buildLogo(Server si) {
|
||||
var logoUrl = si.spi.custom?.logoUrl ??
|
||||
_settings.serverLogoUrl.fetch().selfIfNotNullEmpty;
|
||||
if (logoUrl == null) return UIs.placeholder;
|
||||
|
||||
final dist = si.status.more[StatusCmdType.sys]?.dist;
|
||||
if (dist == null) return UIs.placeholder;
|
||||
|
||||
logoUrl = logoUrl
|
||||
.replaceFirst('{DIST}', dist.name)
|
||||
.replaceFirst('{BRIGHT}', context.isDark ? 'dark' : 'light');
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 13),
|
||||
child: ExtendedImage.network(
|
||||
|
||||
Reference in New Issue
Block a user