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';
|
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()
|
@JsonSerializable()
|
||||||
@HiveType(typeId: 3)
|
@HiveType(typeId: 3)
|
||||||
class ServerPrivateInfo {
|
class ServerPrivateInfo {
|
||||||
|
|||||||
@@ -58,9 +58,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
late MediaQueryData _media;
|
late MediaQueryData _media;
|
||||||
final List<String> _cardsOrder = [];
|
final List<String> _cardsOrder = [];
|
||||||
|
|
||||||
|
final _settings = Stores.setting;
|
||||||
final _netSortType = ValueNotifier(_NetSortType.device);
|
final _netSortType = ValueNotifier(_NetSortType.device);
|
||||||
late final _collapse = Stores.setting.collapseUIDefault.fetch();
|
late final _collapse = _settings.collapseUIDefault.fetch();
|
||||||
late final _textFactor = TextScaler.linear(Stores.setting.textFactor.fetch());
|
late final _textFactor = TextScaler.linear(_settings.textFactor.fetch());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
@@ -71,7 +72,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
final order = Stores.setting.detailCardOrder.fetch();
|
final order = _settings.detailCardOrder.fetch();
|
||||||
order.removeWhere((e) => !ServerDetailCards.names.contains(e));
|
order.removeWhere((e) => !ServerDetailCards.names.contains(e));
|
||||||
_cardsOrder.addAll(order);
|
_cardsOrder.addAll(order);
|
||||||
}
|
}
|
||||||
@@ -92,12 +93,9 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
|
|
||||||
Widget _buildMainPage(Server si) {
|
Widget _buildMainPage(Server si) {
|
||||||
final buildFuncs = !Stores.setting.moveServerFuncs.fetch();
|
final buildFuncs = !Stores.setting.moveServerFuncs.fetch();
|
||||||
final logoUrl = si.spi.custom?.logoUrl ??
|
final logo = _buildLogo(si);
|
||||||
Stores.setting.serverLogoUrl.fetch().selfIfNotNullEmpty;
|
|
||||||
final buildLogo = logoUrl != null;
|
|
||||||
final children = [
|
final children = [
|
||||||
if (buildLogo)
|
logo,
|
||||||
_buildLogo(logoUrl, si.status.more[StatusCmdType.sys]?.dist),
|
|
||||||
if (buildFuncs) ServerFuncBtns(spi: widget.spi),
|
if (buildFuncs) ServerFuncBtns(spi: widget.spi),
|
||||||
];
|
];
|
||||||
for (final card in _cardsOrder) {
|
for (final card in _cardsOrder) {
|
||||||
@@ -141,12 +139,17 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildLogo(String logoUrl, Dist? dist) {
|
Widget _buildLogo(Server si) {
|
||||||
if (dist != null) {
|
var logoUrl = si.spi.custom?.logoUrl ??
|
||||||
logoUrl = logoUrl
|
_settings.serverLogoUrl.fetch().selfIfNotNullEmpty;
|
||||||
.replaceFirst('{DIST}', dist.name)
|
if (logoUrl == null) return UIs.placeholder;
|
||||||
.replaceFirst('{BRIGHT}', context.isDark ? 'dark' : 'light');
|
|
||||||
}
|
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(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 13),
|
padding: const EdgeInsets.symmetric(vertical: 13),
|
||||||
child: ExtendedImage.network(
|
child: ExtendedImage.network(
|
||||||
|
|||||||
Reference in New Issue
Block a user