Skip to content

Commit

Permalink
Merge branch '2623-new-onboarding' of github.com:bitmark-inc/autonomy…
Browse files Browse the repository at this point in the history
…-client into 2623-new-onboarding
  • Loading branch information
phuocbitmark committed Aug 29, 2024
2 parents cf187c8 + b1da605 commit e5a9b0d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 44 deletions.
13 changes: 4 additions & 9 deletions lib/service/canvas_client_service_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CanvasClientServiceV2 {

Future<Pair<CanvasDevice, CheckDeviceStatusReply>?> addQrDevice(
CanvasDevice device) async {
final deviceStatus = await _getDeviceStatus(device, shouldShowError: false);
final deviceStatus = await _getDeviceStatus(device);
if (deviceStatus != null) {
await _db.save(device, device.deviceId);
unawaited(connectToDevice(device));
Expand Down Expand Up @@ -235,14 +235,9 @@ class CanvasClientServiceV2 {
Future<Pair<CanvasDevice, CheckDeviceStatusReply>?> _getDeviceStatus(
CanvasDevice device,
{bool shouldShowError = true}) async {
try {
final status = await _getDeviceCastingStatus(device,
shouldShowError: shouldShowError);
return Pair(device, status);
} catch (e) {
log.info('CanvasClientService: _getDeviceStatus error: $e');
return null;
}
final status =
await _getDeviceCastingStatus(device, shouldShowError: shouldShowError);
return Pair(device, status);
}

Future<void> sendKeyBoard(List<CanvasDevice> devices, int code) async {
Expand Down
74 changes: 39 additions & 35 deletions lib/service/deeplink_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,41 @@ class DeeplinkServiceImpl extends DeeplinkService {
});
final device = CanvasDevice.fromJson(payload);
final canvasClient = injector<CanvasClientServiceV2>();
final result = await canvasClient.addQrDevice(device);
final isSuccessful = result != null;
if (!_navigationService.context.mounted) {
return;
}
if (CustomRouteObserver.currentRoute?.settings.name ==
AppRouter.scanQRPage) {
/// in case scan when open scanQRPage,
/// scan with navigation home page does not go to this flow
_navigationService.goBack(result: result);
if (!isSuccessful) {
await _navigationService.showCannotConnectTv();
} else {
try {
final result = await canvasClient.addQrDevice(device);
final isSuccessful = result != null;
if (!_navigationService.context.mounted) {
return;
}
if (CustomRouteObserver.currentRoute?.settings.name ==
AppRouter.scanQRPage) {
/// in case scan when open scanQRPage,
/// scan with navigation home page does not go to this flow
_navigationService.goBack(result: result);
if (!isSuccessful) {
await _navigationService.showCannotConnectTv();
} else {
showInfoNotification(
const Key('connected_to_canvas'),
'connected_to_display'.tr(),
addOnTextSpan: [
TextSpan(
text: device.name,
style: Theme.of(_navigationService.context)
.textTheme
.ppMori400FFYellow14
.copyWith(color: AppColor.feralFileLightBlue),
)
],
frontWidget: SvgPicture.asset(
'assets/images/checkbox_icon.svg',
width: 24,
),
);
}
break;
}
if (isSuccessful) {
showInfoNotification(
const Key('connected_to_canvas'),
'connected_to_display'.tr(),
Expand All @@ -463,29 +485,11 @@ class DeeplinkServiceImpl extends DeeplinkService {
width: 24,
),
);
} else {
await _navigationService.showCannotConnectTv();
}
break;
}
if (isSuccessful) {
showInfoNotification(
const Key('connected_to_canvas'),
'connected_to_display'.tr(),
addOnTextSpan: [
TextSpan(
text: device.name,
style: Theme.of(_navigationService.context)
.textTheme
.ppMori400FFYellow14
.copyWith(color: AppColor.feralFileLightBlue),
)
],
frontWidget: SvgPicture.asset(
'assets/images/checkbox_icon.svg',
width: 24,
),
);
} else {
await _navigationService.showCannotConnectTv();
} catch (e) {
log.info('[DeeplinkService] feralfile_display error $e');
}

case 'InstantPurchase':
Expand Down

0 comments on commit e5a9b0d

Please sign in to comment.