From 25d0ea53734c1ce9ca5215f4a4237bacc94f5da8 Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Fri, 16 Feb 2024 17:56:26 +0000 Subject: [PATCH] fix: update variable names --- lib/bloc/gebura/gebura_bloc.dart | 10 +++--- lib/bloc/gebura/gebura_state.dart | 32 +++++++++---------- lib/bloc/main_bloc.dart | 2 ++ lib/common/platform.dart | 13 ++++++++ lib/init.dart | 9 ++++-- lib/route.dart | 4 +-- lib/view/layout/overlapping_panels.dart | 6 ++-- .../pages/gebura/gebura_library_detail.dart | 5 +-- .../pages/gebura/gebura_library_overview.dart | 2 +- lib/view/pages/gebura/gebura_nav.dart | 18 ++++++----- .../pages/gebura/gebura_store_detail.dart | 5 +-- lib/view/pages/server_select_overlay.dart | 3 +- 12 files changed, 67 insertions(+), 42 deletions(-) diff --git a/lib/bloc/gebura/gebura_bloc.dart b/lib/bloc/gebura/gebura_bloc.dart index 66a66c3..5beb280 100644 --- a/lib/bloc/gebura/gebura_bloc.dart +++ b/lib/bloc/gebura/gebura_bloc.dart @@ -26,7 +26,7 @@ class GeburaBloc extends Bloc { GeburaBloc(this._api, this._repo) : super(GeburaState()) { on((event, emit) async { - if (state.purchasedApps == null) { + if (state.purchasedAppInfos == null) { add(GeburaPurchasedAppInfosLoadEvent()); add(GeburaScanLocalLibraryEvent()); } @@ -44,14 +44,14 @@ class GeburaBloc extends Bloc { return; } emit(GeburaPurchasedAppsLoadState( - state.copyWith(purchasedApps: resp.getData().appInfos), + state.copyWith(purchasedAppInfos: resp.getData().appInfos), EventStatus.success, msg: resp.error)); }, transformer: droppable()); on((event, emit) async { final newState = state.copyWith(); - newState.selectedPurchasedAppIndex = event.index; + newState.selectedPurchasedAppInfoIndex = event.index; emit(newState); }); @@ -357,10 +357,10 @@ class GeburaBloc extends Bloc { msg: resp.error)); return; } - final storeApps = state.storeApps ?? {}; + final storeApps = state.storeAppInfos ?? {}; storeApps[event.appID] = resp.getData().appInfos; emit(GeburaFetchBoundAppsState( - state.copyWith(storeApps: storeApps), + state.copyWith(storeAppInfos: storeApps), EventStatus.success, msg: resp.error, )); diff --git a/lib/bloc/gebura/gebura_state.dart b/lib/bloc/gebura/gebura_state.dart index fab0a95..8d1b86d 100644 --- a/lib/bloc/gebura/gebura_state.dart +++ b/lib/bloc/gebura/gebura_state.dart @@ -1,10 +1,10 @@ part of 'gebura_bloc.dart'; class GeburaState { - late List? purchasedApps; - late int? selectedPurchasedAppIndex; + late List? purchasedAppInfos; + late int? selectedPurchasedAppInfoIndex; - late Map>? storeApps; + late Map>? storeAppInfos; late Map? runState; late String? localLibraryState; @@ -14,9 +14,9 @@ class GeburaState { late List? localSteamLibraryFolders; GeburaState({ - this.purchasedApps, - this.selectedPurchasedAppIndex, - this.storeApps, + this.purchasedAppInfos, + this.selectedPurchasedAppInfoIndex, + this.storeAppInfos, this.runState, this.localLibraryState, this.localSteamScanResult, @@ -26,9 +26,9 @@ class GeburaState { }); GeburaState copyWith({ - List? purchasedApps, - int? selectedPurchasedAppIndex, - Map>? storeApps, + List? purchasedAppInfos, + int? selectedPurchasedAppInfoIndex, + Map>? storeAppInfos, Map? runState, String? localLibraryState, SteamScanResult? localSteamScanResult, @@ -37,10 +37,10 @@ class GeburaState { List? localSteamLibraryFolders, }) { return GeburaState( - purchasedApps: purchasedApps ?? this.purchasedApps, - selectedPurchasedAppIndex: - selectedPurchasedAppIndex ?? this.selectedPurchasedAppIndex, - storeApps: storeApps ?? this.storeApps, + purchasedAppInfos: purchasedAppInfos ?? this.purchasedAppInfos, + selectedPurchasedAppInfoIndex: + selectedPurchasedAppInfoIndex ?? this.selectedPurchasedAppInfoIndex, + storeAppInfos: storeAppInfos ?? this.storeAppInfos, runState: runState ?? this.runState, localLibraryState: localLibraryState ?? this.localLibraryState, localSteamScanResult: localSteamScanResult ?? this.localSteamScanResult, @@ -52,9 +52,9 @@ class GeburaState { } void _from(GeburaState other) { - purchasedApps = other.purchasedApps; - selectedPurchasedAppIndex = other.selectedPurchasedAppIndex; - storeApps = other.storeApps; + purchasedAppInfos = other.purchasedAppInfos; + selectedPurchasedAppInfoIndex = other.selectedPurchasedAppInfoIndex; + storeAppInfos = other.storeAppInfos; runState = other.runState; localLibraryState = other.localLibraryState; localSteamScanResult = other.localSteamScanResult; diff --git a/lib/bloc/main_bloc.dart b/lib/bloc/main_bloc.dart index 99d1ffd..a45d1a4 100644 --- a/lib/bloc/main_bloc.dart +++ b/lib/bloc/main_bloc.dart @@ -11,6 +11,7 @@ import 'package:tuihub_protos/librarian/sephirah/v1/tiphereth.pb.dart'; import 'package:tuihub_protos/librarian/v1/common.pb.dart'; import '../common/bloc_event_status_mixin.dart'; +import '../common/platform.dart'; import '../consts.dart'; import '../model/common_model.dart'; import '../model/tiphereth_model.dart'; @@ -190,6 +191,7 @@ class MainBloc extends Bloc { RegisterDeviceRequest( deviceInfo: DeviceInfo( deviceName: _deviceInfo.deviceName, + systemType: PlatformHelper.getSystemType(), systemVersion: _deviceInfo.systemVersion, clientName: _packageInfo.appName, clientSourceCodeAddress: clientSourceCodeUrl, diff --git a/lib/common/platform.dart b/lib/common/platform.dart index fb43e33..8171f1d 100644 --- a/lib/common/platform.dart +++ b/lib/common/platform.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:tuihub_protos/librarian/sephirah/v1/tiphereth.pb.dart'; import 'package:universal_io/io.dart' as io; final class PlatformHelper { @@ -29,4 +30,16 @@ final class PlatformHelper { static bool isWeb() { return kIsWeb; } + + static SystemType getSystemType() { + if (isAndroid()) { + return SystemType.SYSTEM_TYPE_ANDROID; + } else if (isWindows()) { + return SystemType.SYSTEM_TYPE_WINDOWS; + } else if (isWeb()) { + return SystemType.SYSTEM_TYPE_WEB; + } else { + return SystemType.SYSTEM_TYPE_UNSPECIFIED; + } + } } diff --git a/lib/init.dart b/lib/init.dart index 153a8f4..0ac28b4 100644 --- a/lib/init.dart +++ b/lib/init.dart @@ -100,10 +100,15 @@ Future genClientDeviceInfo() async { } else if (PlatformHelper.isWindowsApp()) { final windowsInfo = await deviceInfo.windowsInfo; return ClientDeviceInfo( - '', '${windowsInfo.productName} ${windowsInfo.displayVersion}'); + windowsInfo.computerName, + '${windowsInfo.productName} ${windowsInfo.displayVersion}', + ); } else if (PlatformHelper.isWeb()) { final webInfo = await deviceInfo.webBrowserInfo; - return ClientDeviceInfo('', webInfo.browserName.toString()); + return ClientDeviceInfo( + webInfo.browserName.toString(), + webInfo.appVersion.toString(), + ); } else { return const ClientDeviceInfo('unknown', 'unknown'); } diff --git a/lib/route.dart b/lib/route.dart index 50e5b66..d440527 100644 --- a/lib/route.dart +++ b/lib/route.dart @@ -409,12 +409,12 @@ GoRouter getRouter(MainBloc mainBloc, ApiHelper apiHelper) { if (context .read() .state - .selectedPurchasedAppIndex != + .selectedPurchasedAppInfoIndex != null) { return AppRoutes.geburaLibraryDetail(context .read() .state - .selectedPurchasedAppIndex!) + .selectedPurchasedAppInfoIndex!) .toString(); } else { return AppRoutes.geburaLibrary.toString(); diff --git a/lib/view/layout/overlapping_panels.dart b/lib/view/layout/overlapping_panels.dart index e8e9f32..130f991 100644 --- a/lib/view/layout/overlapping_panels.dart +++ b/lib/view/layout/overlapping_panels.dart @@ -120,10 +120,12 @@ class OverlappingPanelsState extends State if (widget.left == null && goal > 0) goal = 0; if (widget.right == null && goal < 0) goal = 0; - if (!widget.gestureLeft && gestureEnd && goal > 0 && lastTranslate <= 0) + if (!widget.gestureLeft && gestureEnd && goal > 0 && lastTranslate <= 0) { goal = 0; - if (!widget.gestureRight && gestureEnd && goal < 0 && lastTranslate >= 0) + } + if (!widget.gestureRight && gestureEnd && goal < 0 && lastTranslate >= 0) { goal = 0; + } final Tween tween = Tween(begin: translate, end: goal); diff --git a/lib/view/pages/gebura/gebura_library_detail.dart b/lib/view/pages/gebura/gebura_library_detail.dart index 5759e02..2ca514c 100644 --- a/lib/view/pages/gebura/gebura_library_detail.dart +++ b/lib/view/pages/gebura/gebura_library_detail.dart @@ -27,7 +27,7 @@ class GeburaLibraryDetailPage extends StatelessWidget { } }, builder: (context, state) { - final app = state.purchasedApps![index]; + final app = state.purchasedAppInfos![index]; final setting = context.read().getAppLauncherSetting(app.id); final runState = @@ -35,7 +35,8 @@ class GeburaLibraryDetailPage extends StatelessWidget { ? state.runState![app.id] : null; if (firstBuild && - (state.storeApps == null || state.storeApps![app.id] == null)) { + (state.storeAppInfos == null || + state.storeAppInfos![app.id] == null)) { firstBuild = false; context.read().add(GeburaFetchBoundAppInfosEvent(app.id)); } diff --git a/lib/view/pages/gebura/gebura_library_overview.dart b/lib/view/pages/gebura/gebura_library_overview.dart index 119e4d4..6ff1fcf 100644 --- a/lib/view/pages/gebura/gebura_library_overview.dart +++ b/lib/view/pages/gebura/gebura_library_overview.dart @@ -17,7 +17,7 @@ class GeburaLibraryOverview extends StatelessWidget { if (firstBuild) { firstBuild = false; } - final apps = state.purchasedApps ?? []; + final apps = state.purchasedAppInfos ?? []; final localLibraryState = state.localLibraryState ?? ''; return Scaffold( body: Column( diff --git a/lib/view/pages/gebura/gebura_nav.dart b/lib/view/pages/gebura/gebura_nav.dart index 11011c0..d5c88b2 100644 --- a/lib/view/pages/gebura/gebura_nav.dart +++ b/lib/view/pages/gebura/gebura_nav.dart @@ -18,7 +18,7 @@ class GeburaNav extends StatelessWidget { @override Widget build(BuildContext context) { return BlocBuilder(builder: (context, state) { - if (state.purchasedApps == null) { + if (state.purchasedAppInfos == null) { context.read().add(GeburaInitEvent()); } @@ -59,7 +59,7 @@ class GeburaNav extends StatelessWidget { }, title: const Text('Library'), selected: function == 'library' && - state.selectedPurchasedAppIndex == null, + state.selectedPurchasedAppInfoIndex == null, ), SpacingHelper.defaultDivider, Expanded( @@ -70,15 +70,17 @@ class GeburaNav extends StatelessWidget { physics: physics, child: Column( children: [ - if (state.purchasedApps != null && - state.purchasedApps!.isNotEmpty) - for (var i = 0, app = state.purchasedApps![i]; - i < state.purchasedApps!.length; + if (state.purchasedAppInfos != null && + state.purchasedAppInfos!.isNotEmpty) + for (var i = 0, app = state.purchasedAppInfos![i]; + i < state.purchasedAppInfos!.length; i++, - app = state.purchasedApps!.elementAtOrNull(i) ?? + app = state.purchasedAppInfos! + .elementAtOrNull(i) ?? AppInfoMixed()) RailTile( - selected: i == state.selectedPurchasedAppIndex, + selected: + i == state.selectedPurchasedAppInfoIndex, onTap: () { context.read().add( GeburaSetPurchasedAppInfoIndexEvent(i)); diff --git a/lib/view/pages/gebura/gebura_store_detail.dart b/lib/view/pages/gebura/gebura_store_detail.dart index 7ddfd46..3cc47b6 100644 --- a/lib/view/pages/gebura/gebura_store_detail.dart +++ b/lib/view/pages/gebura/gebura_store_detail.dart @@ -26,7 +26,8 @@ class GeburaStoreDetail extends StatelessWidget { msg = state.msg ?? msg; } }, builder: (context, state) { - final apps = state.storeApps != null ? state.storeApps![appID] : null; + final apps = + state.storeAppInfos != null ? state.storeAppInfos![appID] : null; final app = apps != null ? mixAppInfo(apps) : null; if (firstBuild && apps == null) { firstBuild = false; @@ -114,7 +115,7 @@ class GeburaStoreDetail extends StatelessWidget { padding: const EdgeInsets.all(16), child: Row( children: [ - if (state.purchasedApps?.contains(app) ?? + if (state.purchasedAppInfos?.contains(app) ?? false) const ElevatedButton( onPressed: null, diff --git a/lib/view/pages/server_select_overlay.dart b/lib/view/pages/server_select_overlay.dart index cbbfba7..23ab191 100644 --- a/lib/view/pages/server_select_overlay.dart +++ b/lib/view/pages/server_select_overlay.dart @@ -133,8 +133,7 @@ class ServerSelectOverlayState extends State body: Container( decoration: BoxDecoration( image: DecorationImage( - image: ExtendedNetworkImageProvider( - ''), + image: ExtendedNetworkImageProvider(''), fit: BoxFit.cover, ), ),