diff --git a/lib/data/model/server/server_private_info.dart b/lib/data/model/server/server_private_info.dart index 842a8ab2..f2e9327d 100644 --- a/lib/data/model/server/server_private_info.dart +++ b/lib/data/model/server/server_private_info.dart @@ -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 { @@ -71,7 +76,7 @@ class ServerPrivateInfo { factory ServerPrivateInfo.fromJson(Map json) => _$ServerPrivateInfoFromJson(json); - + Map toJson() => _$ServerPrivateInfoToJson(this); String toJsonString() => json.encode(toJson()); diff --git a/lib/view/page/server/detail/view.dart b/lib/view/page/server/detail/view.dart index e13a88ee..5d50bb2f 100644 --- a/lib/view/page/server/detail/view.dart +++ b/lib/view/page/server/detail/view.dart @@ -58,9 +58,10 @@ class _ServerDetailPageState extends State late MediaQueryData _media; final List _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 @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 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 ); } - 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(