Skip to content

Commit

Permalink
fix: update variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Feb 16, 2024
1 parent 8ee58be commit 25d0ea5
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 42 deletions.
10 changes: 5 additions & 5 deletions lib/bloc/gebura/gebura_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GeburaBloc extends Bloc<GeburaEvent, GeburaState> {

GeburaBloc(this._api, this._repo) : super(GeburaState()) {
on<GeburaInitEvent>((event, emit) async {
if (state.purchasedApps == null) {
if (state.purchasedAppInfos == null) {
add(GeburaPurchasedAppInfosLoadEvent());
add(GeburaScanLocalLibraryEvent());
}
Expand All @@ -44,14 +44,14 @@ class GeburaBloc extends Bloc<GeburaEvent, GeburaState> {
return;
}
emit(GeburaPurchasedAppsLoadState(
state.copyWith(purchasedApps: resp.getData().appInfos),
state.copyWith(purchasedAppInfos: resp.getData().appInfos),
EventStatus.success,
msg: resp.error));
}, transformer: droppable());

on<GeburaSetPurchasedAppInfoIndexEvent>((event, emit) async {
final newState = state.copyWith();
newState.selectedPurchasedAppIndex = event.index;
newState.selectedPurchasedAppInfoIndex = event.index;
emit(newState);
});

Expand Down Expand Up @@ -357,10 +357,10 @@ class GeburaBloc extends Bloc<GeburaEvent, GeburaState> {
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,
));
Expand Down
32 changes: 16 additions & 16 deletions lib/bloc/gebura/gebura_state.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of 'gebura_bloc.dart';

class GeburaState {
late List<AppInfoMixed>? purchasedApps;
late int? selectedPurchasedAppIndex;
late List<AppInfoMixed>? purchasedAppInfos;
late int? selectedPurchasedAppInfoIndex;

late Map<InternalID, List<AppInfo>>? storeApps;
late Map<InternalID, List<AppInfo>>? storeAppInfos;
late Map<InternalID, AppRunState>? runState;

late String? localLibraryState;
Expand All @@ -14,9 +14,9 @@ class GeburaState {
late List<String>? localSteamLibraryFolders;

GeburaState({
this.purchasedApps,
this.selectedPurchasedAppIndex,
this.storeApps,
this.purchasedAppInfos,
this.selectedPurchasedAppInfoIndex,
this.storeAppInfos,
this.runState,
this.localLibraryState,
this.localSteamScanResult,
Expand All @@ -26,9 +26,9 @@ class GeburaState {
});

GeburaState copyWith({
List<AppInfoMixed>? purchasedApps,
int? selectedPurchasedAppIndex,
Map<InternalID, List<AppInfo>>? storeApps,
List<AppInfoMixed>? purchasedAppInfos,
int? selectedPurchasedAppInfoIndex,
Map<InternalID, List<AppInfo>>? storeAppInfos,
Map<InternalID, AppRunState>? runState,
String? localLibraryState,
SteamScanResult? localSteamScanResult,
Expand All @@ -37,10 +37,10 @@ class GeburaState {
List<String>? 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,
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/bloc/main_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -190,6 +191,7 @@ class MainBloc extends Bloc<MainEvent, MainState> {
RegisterDeviceRequest(
deviceInfo: DeviceInfo(
deviceName: _deviceInfo.deviceName,
systemType: PlatformHelper.getSystemType(),
systemVersion: _deviceInfo.systemVersion,
clientName: _packageInfo.appName,
clientSourceCodeAddress: clientSourceCodeUrl,
Expand Down
13 changes: 13 additions & 0 deletions lib/common/platform.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
}
}
}
9 changes: 7 additions & 2 deletions lib/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ Future<ClientDeviceInfo> 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');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,12 @@ GoRouter getRouter(MainBloc mainBloc, ApiHelper apiHelper) {
if (context
.read<GeburaBloc>()
.state
.selectedPurchasedAppIndex !=
.selectedPurchasedAppInfoIndex !=
null) {
return AppRoutes.geburaLibraryDetail(context
.read<GeburaBloc>()
.state
.selectedPurchasedAppIndex!)
.selectedPurchasedAppInfoIndex!)
.toString();
} else {
return AppRoutes.geburaLibrary.toString();
Expand Down
6 changes: 4 additions & 2 deletions lib/view/layout/overlapping_panels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ class OverlappingPanelsState extends State<OverlappingPanels>
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<double> tween = Tween<double>(begin: translate, end: goal);

Expand Down
5 changes: 3 additions & 2 deletions lib/view/pages/gebura/gebura_library_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ class GeburaLibraryDetailPage extends StatelessWidget {
}
},
builder: (context, state) {
final app = state.purchasedApps![index];
final app = state.purchasedAppInfos![index];
final setting =
context.read<GeburaBloc>().getAppLauncherSetting(app.id);
final runState =
state.runState != null && state.runState!.containsKey(app.id)
? 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<GeburaBloc>().add(GeburaFetchBoundAppInfosEvent(app.id));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/view/pages/gebura/gebura_library_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 10 additions & 8 deletions lib/view/pages/gebura/gebura_nav.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GeburaNav extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<GeburaBloc, GeburaState>(builder: (context, state) {
if (state.purchasedApps == null) {
if (state.purchasedAppInfos == null) {
context.read<GeburaBloc>().add(GeburaInitEvent());
}

Expand Down Expand Up @@ -59,7 +59,7 @@ class GeburaNav extends StatelessWidget {
},
title: const Text('Library'),
selected: function == 'library' &&
state.selectedPurchasedAppIndex == null,
state.selectedPurchasedAppInfoIndex == null,
),
SpacingHelper.defaultDivider,
Expanded(
Expand All @@ -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<GeburaBloc>().add(
GeburaSetPurchasedAppInfoIndexEvent(i));
Expand Down
5 changes: 3 additions & 2 deletions lib/view/pages/gebura/gebura_store_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions lib/view/pages/server_select_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ class ServerSelectOverlayState extends State<ServerSelectOverlay>
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: ExtendedNetworkImageProvider(
''),
image: ExtendedNetworkImageProvider(''),
fit: BoxFit.cover,
),
),
Expand Down

0 comments on commit 25d0ea5

Please sign in to comment.