【问题标题】:How to make a loading with a progress bar in code Push?如何在代码推送中使用进度条进行加载?
【发布时间】:2022-11-07 17:37:51
【问题描述】:

大家好,我正在尝试在代码推送中进行样式更新。 我希望应用程序遵循以下步骤:

  1. 当更新开始时,我想显示加载;
  2. 当更新正在更新时,我想显示一个带有文本(“正在更新”)的屏幕,并在其下方显示一个带有更新百分比的进度条;

    在我的代码中,我在 App.tsx 中插入 codepush 更新,并尝试仅在开关状态正常但没有正常工作时显示控制台日志。

    预先感谢您的帮助,我很抱歉,但我没有完全理解 codepush 文档。

    这是我的代码:

    import React, {useEffect} from 'react';
    import Navigation from './navigation';
    import codePush from 'react-native-code-push';
    import {StatusBar} from 'react-native';
    
    export default function App() {
      useEffect(() => {
        const codePushStatusDidChange = (status: any) => {
          switch (status) {
            case codePush.SyncStatus.CHECKING_FOR_UPDATE:
              console.log('Checking for updates.');
              break;
            case codePush.SyncStatus.DOWNLOADING_PACKAGE:
              console.log('Downloading package.');
              break;
            case codePush.SyncStatus.INSTALLING_UPDATE:
              console.log('Installing update.');
              break;
            case codePush.SyncStatus.UP_TO_DATE:
              console.log('Up-to-date.');
              break;
            case codePush.SyncStatus.UPDATE_INSTALLED:
              console.log('Update installed.');
              break;
          }
        };
    
        const codePushDownloadDidProgress = (progress: {
          receivedBytes: string;
          totalBytes: string;
        }) => {
          console.log(
            progress.receivedBytes + ' of ' + progress.totalBytes + ' received.',
          );
        };
        const syncImmediate = () => {
          console.log('synced');
          codePush.sync(
            {
              checkFrequency: codePush.CheckFrequency.ON_APP_START,
              installMode: codePush.InstallMode.IMMEDIATE,
              updateDialog: {
                appendReleaseDescription: true,
                optionalUpdateMessage: 'Updates here..',
                title: 'New Updates',
                optionalInstallButtonLabel: 'Yes',
                optionalIgnoreButtonLabel: 'No',
              },
            },
            codePushStatusDidChange,
            codePushDownloadDidProgress,
          );
        };
        syncImmediate();
      });
      return (
        <>
          <Navigation />
        </>
      );
    }
    
    App = codePush(App);
    

【问题讨论】:

    标签: typescript react-native code-push react-native-code-push


    【解决方案1】:

    你可以想到python包tqdm Project PyPi and examples

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-04
      • 2018-12-25
      • 2013-12-04
      • 1970-01-01
      相关资源
      最近更新 更多