@arcblock/did-connect-react 3.3.4 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Connect/components/back-button.js +13 -12
- package/lib/Connect/components/login-item/connect-provider-list.js +187 -158
- package/lib/Connect/components/login-item/mobile-login-item.js +42 -40
- package/lib/Connect/components/login-item/wallet-login-options.js +109 -0
- package/lib/Connect/components/login-item/web-login-item.js +64 -59
- package/lib/Connect/contexts/state.js +66 -63
- package/lib/Connect/index.js +286 -264
- package/lib/package.json.js +1 -1
- package/package.json +5 -5
- package/src/Connect/components/back-button.jsx +3 -2
- package/src/Connect/components/login-item/connect-provider-list.jsx +133 -97
- package/src/Connect/components/login-item/mobile-login-item.jsx +3 -1
- package/src/Connect/components/login-item/wallet-login-options.jsx +116 -0
- package/src/Connect/components/login-item/web-login-item.jsx +10 -2
- package/src/Connect/contexts/state.jsx +5 -0
- package/src/Connect/index.jsx +77 -41
package/src/Connect/index.jsx
CHANGED
|
@@ -98,6 +98,8 @@ function Connect({
|
|
|
98
98
|
selectedPlugin,
|
|
99
99
|
blocklet,
|
|
100
100
|
masterBlocklet,
|
|
101
|
+
showWalletOptions,
|
|
102
|
+
setShowWalletOptions,
|
|
101
103
|
} = useStateContext();
|
|
102
104
|
const { state, generate, cancelWhenScanned } = useToken({
|
|
103
105
|
action,
|
|
@@ -292,24 +294,29 @@ function Connect({
|
|
|
292
294
|
// 防止二维码抖动,使用 useCreation 进行缓存
|
|
293
295
|
const qrcode = useCreation(() => {
|
|
294
296
|
const backgroundColor = theme.mode === 'dark' ? theme.palette.grey[600] : 'white';
|
|
297
|
+
|
|
298
|
+
let qrcodeSize = hideChooseList ? 240 - getSpacingNumber(3) * 2 : 196 - getSpacingNumber(2) * 2;
|
|
299
|
+
let padding = hideChooseList ? 3 : 2;
|
|
300
|
+
// 如果显示钱包登录,将 download tips 移动到顶部,调整间距,增加二维码的尺寸和内边距
|
|
301
|
+
if (showWalletOptions) {
|
|
302
|
+
padding = 1;
|
|
303
|
+
qrcodeSize += getSpacingNumber(padding) * 2;
|
|
304
|
+
}
|
|
295
305
|
return (
|
|
296
306
|
<Box
|
|
307
|
+
className="did-connect__qrcode"
|
|
297
308
|
sx={{
|
|
298
|
-
p:
|
|
309
|
+
p: padding,
|
|
299
310
|
width: (hideChooseList ? 240 : 196) + getSpacingNumber(1) * 2,
|
|
300
311
|
height: (hideChooseList ? 240 : 196) + getSpacingNumber(1) * 2,
|
|
301
312
|
}}>
|
|
302
313
|
{state.url ? (
|
|
303
314
|
<QRCode
|
|
304
315
|
data={urlWithParams}
|
|
305
|
-
size={
|
|
316
|
+
size={qrcodeSize}
|
|
306
317
|
sx={{
|
|
307
|
-
width:
|
|
308
|
-
|
|
309
|
-
getSpacingNumber(1) * 2,
|
|
310
|
-
height:
|
|
311
|
-
(hideChooseList ? 240 - getSpacingNumber(3) * 2 : 196 - getSpacingNumber(2) * 2) +
|
|
312
|
-
getSpacingNumber(1) * 2,
|
|
318
|
+
width: qrcodeSize + getSpacingNumber(1) * 2,
|
|
319
|
+
height: qrcodeSize + getSpacingNumber(1) * 2,
|
|
313
320
|
flex: 1,
|
|
314
321
|
backgroundColor,
|
|
315
322
|
p: 1,
|
|
@@ -345,7 +352,7 @@ function Connect({
|
|
|
345
352
|
)}
|
|
346
353
|
</Box>
|
|
347
354
|
);
|
|
348
|
-
}, [urlWithParams, hideChooseList]);
|
|
355
|
+
}, [urlWithParams, hideChooseList, showWalletOptions]);
|
|
349
356
|
|
|
350
357
|
const didConnectFlexDirection = useCreation(() => {
|
|
351
358
|
if (hideChooseList) {
|
|
@@ -357,6 +364,60 @@ function Connect({
|
|
|
357
364
|
return 'row';
|
|
358
365
|
}, [hideChooseList, isInitSmallView, hideQRCode]);
|
|
359
366
|
|
|
367
|
+
const qrcodeContent = useCreation(() => {
|
|
368
|
+
if (!qrcode) return null;
|
|
369
|
+
return (
|
|
370
|
+
<Box
|
|
371
|
+
sx={{
|
|
372
|
+
display: 'flex',
|
|
373
|
+
alignItems: 'center',
|
|
374
|
+
overflowX: 'auto',
|
|
375
|
+
overflowY: 'visible',
|
|
376
|
+
maxWidth: '100%',
|
|
377
|
+
margin: 'auto',
|
|
378
|
+
}}>
|
|
379
|
+
<Box
|
|
380
|
+
sx={{
|
|
381
|
+
fontSize: 0,
|
|
382
|
+
position: 'relative',
|
|
383
|
+
...(showWalletOptions
|
|
384
|
+
? {
|
|
385
|
+
mt: hideChooseList ? 4 : 2.5,
|
|
386
|
+
mb: hideChooseList ? 0 : 0,
|
|
387
|
+
}
|
|
388
|
+
: {
|
|
389
|
+
mb: hideChooseList ? 4 : 2.5,
|
|
390
|
+
mt: 0,
|
|
391
|
+
}),
|
|
392
|
+
}}>
|
|
393
|
+
{qrcode}
|
|
394
|
+
<Box
|
|
395
|
+
sx={{
|
|
396
|
+
position: 'absolute',
|
|
397
|
+
color: 'text.secondary',
|
|
398
|
+
fontSize: 12,
|
|
399
|
+
zIndex: 1,
|
|
400
|
+
whiteSpace: 'nowrap',
|
|
401
|
+
...(showWalletOptions
|
|
402
|
+
? {
|
|
403
|
+
top: hideChooseList ? -8 : -4,
|
|
404
|
+
transform: 'translateY(-100%)',
|
|
405
|
+
}
|
|
406
|
+
: {
|
|
407
|
+
bottom: hideChooseList ? -8 : -4,
|
|
408
|
+
transform: 'translateY(100%)',
|
|
409
|
+
}),
|
|
410
|
+
left: 0,
|
|
411
|
+
right: 0,
|
|
412
|
+
textAlign: 'center',
|
|
413
|
+
}}>
|
|
414
|
+
{t('scanWithWallet1')} <DownloadTips /> {t('scanWithWallet2')}
|
|
415
|
+
</Box>
|
|
416
|
+
</Box>
|
|
417
|
+
</Box>
|
|
418
|
+
);
|
|
419
|
+
}, [qrcode, hideChooseList, showWalletOptions]);
|
|
420
|
+
|
|
360
421
|
const fallbackContent = (
|
|
361
422
|
<Box
|
|
362
423
|
className="did-connect__body"
|
|
@@ -372,37 +433,7 @@ function Connect({
|
|
|
372
433
|
}}>
|
|
373
434
|
{!showStatus && !hideQRCode ? (
|
|
374
435
|
<>
|
|
375
|
-
|
|
376
|
-
sx={{
|
|
377
|
-
display: 'flex',
|
|
378
|
-
alignItems: 'center',
|
|
379
|
-
overflowX: 'auto',
|
|
380
|
-
overflowY: 'visible',
|
|
381
|
-
maxWidth: '100%',
|
|
382
|
-
margin: 'auto',
|
|
383
|
-
}}>
|
|
384
|
-
<Box
|
|
385
|
-
sx={{
|
|
386
|
-
fontSize: 0,
|
|
387
|
-
position: 'relative',
|
|
388
|
-
mb: hideChooseList ? 4 : 2.5,
|
|
389
|
-
}}>
|
|
390
|
-
{qrcode}
|
|
391
|
-
<Box
|
|
392
|
-
sx={{
|
|
393
|
-
position: 'absolute',
|
|
394
|
-
color: 'text.secondary',
|
|
395
|
-
fontSize: 12,
|
|
396
|
-
bottom: hideChooseList ? 8 : 4,
|
|
397
|
-
transform: 'translateY(100%)',
|
|
398
|
-
left: 0,
|
|
399
|
-
right: 0,
|
|
400
|
-
textAlign: 'center',
|
|
401
|
-
}}>
|
|
402
|
-
{t('scanWithWallet1')} <DownloadTips /> {t('scanWithWallet2')}
|
|
403
|
-
</Box>
|
|
404
|
-
</Box>
|
|
405
|
-
</Box>
|
|
436
|
+
{qrcodeContent}
|
|
406
437
|
{hideChooseList ? null : (
|
|
407
438
|
<Box>
|
|
408
439
|
<Divider
|
|
@@ -450,6 +481,7 @@ function Connect({
|
|
|
450
481
|
baseUrl={baseUrl}
|
|
451
482
|
customItems={customItems}
|
|
452
483
|
providerList={providerList}
|
|
484
|
+
qrcode={qrcodeContent}
|
|
453
485
|
/>
|
|
454
486
|
</Box>
|
|
455
487
|
</Box>
|
|
@@ -466,6 +498,8 @@ function Connect({
|
|
|
466
498
|
contentResult = fallbackContent;
|
|
467
499
|
}
|
|
468
500
|
|
|
501
|
+
const containerWidth = hideQRCode || showStatus ? DID_CONNECT_SMALL_WIDTH : DID_CONNECT_MEDIUM_WIDTH;
|
|
502
|
+
|
|
469
503
|
return (
|
|
470
504
|
<Box
|
|
471
505
|
ref={rootRef}
|
|
@@ -479,7 +513,7 @@ function Connect({
|
|
|
479
513
|
maxWidth: '100%',
|
|
480
514
|
width:
|
|
481
515
|
// eslint-disable-next-line no-nested-ternary
|
|
482
|
-
mode === 'drawer' ? '100%' :
|
|
516
|
+
mode === 'drawer' ? '100%' : showWalletOptions ? containerWidth - 20 : containerWidth,
|
|
483
517
|
transition: 'width 0.2s ease-in-out',
|
|
484
518
|
margin: 'auto',
|
|
485
519
|
p: 3,
|
|
@@ -492,6 +526,8 @@ function Connect({
|
|
|
492
526
|
description={messages.scan}
|
|
493
527
|
extraContent={extraContent}
|
|
494
528
|
disableSwitchApp={disableSwitchApp}
|
|
529
|
+
showWalletOptions={showWalletOptions}
|
|
530
|
+
onBack={() => setShowWalletOptions(false)}
|
|
495
531
|
/>
|
|
496
532
|
<AutoHeight initHeight={24 + 16 + 32}>{contentResult}</AutoHeight>
|
|
497
533
|
<DIDConnectFooter currentAppInfo={currentAppInfo} currentAppColor={currentAppColor} />
|