From 13831f909f3f9631510122f8727c5c84a6d4276e Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 1 Apr 2020 21:56:51 +0400 Subject: [PATCH] Wallet-related changes --- Wallet.makefile | 58 ++----------- Wallet/README.md | 50 ++--------- extract_wallet_source.py | 26 ++---- .../Sources/WalletReceiveScreen.swift | 86 ++++++++++++------- wallet_env.sh | 12 +++ 5 files changed, 85 insertions(+), 147 deletions(-) diff --git a/Wallet.makefile b/Wallet.makefile index b2d9c44ab0..d58b1d5f1b 100644 --- a/Wallet.makefile +++ b/Wallet.makefile @@ -1,28 +1,7 @@ -include Utils.makefile - APP_VERSION="1.0" CORE_COUNT=$(shell sysctl -n hw.logicalcpu) CORE_COUNT_MINUS_ONE=$(shell expr ${CORE_COUNT} \- 1) -WALLET_BUCK_OPTIONS=\ - --config custom.appVersion="1.0" \ - --config custom.developmentCodeSignIdentity="${DEVELOPMENT_CODE_SIGN_IDENTITY}" \ - --config custom.distributionCodeSignIdentity="${DISTRIBUTION_CODE_SIGN_IDENTITY}" \ - --config custom.developmentTeam="${DEVELOPMENT_TEAM}" \ - --config custom.baseApplicationBundleId="${WALLET_BUNDLE_ID}" \ - --config custom.buildNumber="${BUILD_NUMBER}" \ - --config custom.entitlementsApp="${WALLET_ENTITLEMENTS_APP}" \ - --config custom.developmentProvisioningProfileApp="${WALLET_DEVELOPMENT_PROVISIONING_PROFILE_APP}" \ - --config custom.distributionProvisioningProfileApp="${WALLET_DISTRIBUTION_PROVISIONING_PROFILE_APP}" \ - --config custom.apiId="${API_ID}" \ - --config custom.apiHash="${API_HASH}" \ - --config custom.appCenterId="0" \ - --config custom.isInternalBuild="${IS_INTERNAL_BUILD}" \ - --config custom.isAppStoreBuild="${IS_APPSTORE_BUILD}" \ - --config custom.appStoreId="${APPSTORE_ID}" \ - --config custom.appSpecificUrlScheme="${APP_SPECIFIC_URL_SCHEME}" \ - --config buildfile.name=BUCK - BAZEL=$(shell which bazel) ifneq ($(BAZEL_CACHE_DIR),) @@ -42,37 +21,10 @@ BAZEL_OPT_FLAGS=\ --swiftcopt=-whole-module-optimization \ --swiftcopt='-num-threads' --swiftcopt='16' \ -wallet_deps: check_env - $(BUCK) query "deps(//Wallet:AppPackage)" --output-attribute buck.type \ - ${WALLET_BUCK_OPTIONS} ${BUCK_RELEASE_OPTIONS} +kill_xcode: + killall Xcode || true -wallet_project: check_env kill_xcode - $(BUCK) project //Wallet:workspace --config custom.mode=project ${WALLET_BUCK_OPTIONS} ${BUCK_DEBUG_OPTIONS} - open Wallet/WalletWorkspace.xcworkspace - -build_wallet: check_env - $(BUCK) build \ - //Wallet:AppPackage#iphoneos-arm64,iphoneos-armv7 \ - //Wallet:Wallet#dwarf-and-dsym,iphoneos-arm64,iphoneos-armv7 \ - //submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \ - //submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared,iphoneos-arm64,iphoneos-armv7 \ - //submodules/AsyncDisplayKit:AsyncDisplayKit#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \ - //submodules/AsyncDisplayKit:AsyncDisplayKit#shared,iphoneos-arm64,iphoneos-armv7 \ - //submodules/Display:Display#dwarf-and-dsym,shared,iphoneos-arm64,iphoneos-armv7 \ - //submodules/Display:Display#shared,iphoneos-arm64,iphoneos-armv7 \ - ${WALLET_BUCK_OPTIONS} ${BUCK_RELEASE_OPTIONS} ${BUCK_THREADS_OPTIONS} ${BUCK_CACHE_OPTIONS} - -wallet_package: - PACKAGE_DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \ - PACKAGE_CODE_SIGN_IDENTITY="${DISTRIBUTION_CODE_SIGN_IDENTITY}" \ - PACKAGE_PROVISIONING_PROFILE_APP="${WALLET_DISTRIBUTION_PROVISIONING_PROFILE_APP}" \ - PACKAGE_ENTITLEMENTS_APP="Wallet/${WALLET_ENTITLEMENTS_APP}" \ - PACKAGE_BUNDLE_ID="${WALLET_BUNDLE_ID}" \ - sh package_app.sh iphoneos-arm64,iphoneos-armv7 $(BUCK) "wallet" $(WALLET_BUCK_OPTIONS) ${BUCK_RELEASE_OPTIONS} - -wallet_app: build_wallet wallet_package - -bazel_wallet_debug_arm64: +wallet_app_debug_arm64: WALLET_APP_VERSION="${APP_VERSION}" \ build-system/prepare-build.sh Wallet distribution "${BAZEL}" build Wallet/Wallet ${BAZEL_CACHE_FLAGS} ${BAZEL_COMMON_FLAGS} ${BAZEL_DEBUG_FLAGS} \ @@ -81,7 +33,7 @@ bazel_wallet_debug_arm64: --watchos_cpus=armv7k,arm64_32 \ --verbose_failures -bazel_wallet: +wallet_app: WALLET_APP_VERSION="${APP_VERSION}" \ build-system/prepare-build.sh Wallet distribution "${BAZEL}" build Wallet/Wallet ${BAZEL_CACHE_FLAGS} ${BAZEL_COMMON_FLAGS} ${BAZEL_OPT_FLAGS} \ @@ -95,7 +47,7 @@ bazel_wallet_prepare_development_build: BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \ build-system/prepare-build.sh Wallet development -bazel_wallet_project: kill_xcode bazel_wallet_prepare_development_build +wallet_project: kill_xcode bazel_wallet_prepare_development_build WALLET_APP_VERSION="${APP_VERSION}" \ BAZEL_CACHE_DIR="${BAZEL_CACHE_DIR}" \ build-system/generate-xcode-project.sh Wallet diff --git a/Wallet/README.md b/Wallet/README.md index fc0c50909a..67ecc83239 100644 --- a/Wallet/README.md +++ b/Wallet/README.md @@ -2,62 +2,26 @@ This is the source code and build instructions for a TON Testnet Wallet implementation for iOS. -1. Install Xcode 11.1 +1. Install Xcode 11.4 ``` -https://apps.apple.com/ae/app/xcode/id497799835?mt=12 +https://apps.apple.com/app/xcode/id497799835 ``` Make sure to launch Xcode at least once and set up command-line tools paths (Xcode — Preferences — Locations — Command Line Tools) -2. Install Homebrew - -``` -/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` -3. Install the required tools - -``` -brew tap AdoptOpenJDK/openjdk -brew cask install adoptopenjdk8 -brew install cmake ant -``` - -4. Build Buck - -``` -mkdir -p $HOME/buck_source -cd tools/buck-build -sh ./prepare_buck_source.sh $HOME/buck_source -``` - -5. Now you can build Wallet application (IPA) +2. Build the app (IPA) Note: It is recommended to use an artifact cache to optimize build speed. Prepend any of the following commands with ``` -BUCK_DIR_CACHE="path/to/existing/directory" +BAZEL_CACHE_DIR="path/to/existing/directory" ``` ``` -BUCK="$HOME/buck_source/buck/buck-out/gen/programs/buck.pex" \ - BUILD_NUMBER=30 \ - DISTRIBUTION_CODE_SIGN_IDENTITY="iPhone Distribution: XXXXXXX (XXXXXXXXXX)" \ - DEVELOPMENT_TEAM="XXXXXXXXXX" WALLET_BUNDLE_ID="wallet.bundle.id" \ - WALLET_DISTRIBUTION_PROVISIONING_PROFILE_APP="wallet distribution provisioning profile name" \ - CODESIGNING_SOURCE_DATA_PATH="$HOME/wallet_codesigning" \ - sh Wallet/example_wallet_env.sh make -f Wallet.makefile wallet_app +sh wallet_env.sh make wallet_app ``` -6. If needed, generate Xcode project +3. If needed, generate Xcode project ``` -BUCK="$HOME/buck_source/buck/buck-out/gen/programs/buck.pex" \ - BUILD_NUMBER=30 \ - DEVELOPMENT_CODE_SIGN_IDENTITY="iPhone Developer: XXXXXXX (XXXXXXXXXX)" \ - DISTRIBUTION_CODE_SIGN_IDENTITY="iPhone Distribution: XXXXXXX (XXXXXXXXXX)" \ - DEVELOPMENT_TEAM="XXXXXXXXXX" WALLET_BUNDLE_ID="wallet.bundle.id" \ - WALLET_DEVELOPMENT_PROVISIONING_PROFILE_APP="wallet development provisioning profile name" \ - WALLET_DISTRIBUTION_PROVISIONING_PROFILE_APP="wallet distribution provisioning profile name" \ - CODESIGNING_SOURCE_DATA_PATH="$HOME/wallet_codesigning" \ - sh Wallet/example_wallet_env.sh make -f Wallet.makefile wallet_project +sh wallet_env.sh make wallet_project ``` - diff --git a/extract_wallet_source.py b/extract_wallet_source.py index 025e79bc3f..b7d22657ba 100644 --- a/extract_wallet_source.py +++ b/extract_wallet_source.py @@ -39,22 +39,6 @@ def clean_copy_files(dir, destination_dir): continue mkdir_p(destination_dir + "/" + dir_path) -def clean_files(base_dir, dirs, files): - for file in files: - if file == '.DS_Store': - os.remove(base_dir + '/' + file) - for dir in dirs: - if re.match('.*\\.xcodeproj', dir) or re.match('.*\\.xcworkspace', dir): - shutil.rmtree(base_dir + '/' + dir, ignore_errors=True) - -def clean_dep_files(base_dir, dirs, files): - for file in files: - if re.match('^\\.git$', file) or re.match('^.*/\\.git$', file): - os.remove(base_dir + '/' + file) - for dir in dirs: - if re.match('^\\.git$', dir) or re.match('^.*/\\.git$', dir): - shutil.rmtree(base_dir + '/' + dir, ignore_errors=True) - if len(sys.argv) != 2: print('Usage: extract_wallet_source.py destination') sys.exit(1) @@ -96,13 +80,15 @@ additional_paths = [ "build-system/copy-provisioning-profiles-Wallet.sh", "build-system/prepare-build-variables-Wallet.sh", ".bazelrc", - "Utils.makefile", - "Wallet.makefile", "wallet_env.sh", ] for file_path in additional_paths: if os.path.isdir(file_path): - clean_copy_files(file_path, destination + '/' + file_path) + clean_copy_files(file_path, destination + "/" + file_path) else: - shutil.copy(file_path, destination + '/' + file_path) + shutil.copy(file_path, destination + "/" + file_path) + +shutil.copy("Wallet.makefile", destination + "/" + "Makefile") +shutil.copy("Wallet/README.md", destination + "/" + "README.md") + diff --git a/submodules/WalletUI/Sources/WalletReceiveScreen.swift b/submodules/WalletUI/Sources/WalletReceiveScreen.swift index 8415854ac9..4032cd31fc 100644 --- a/submodules/WalletUI/Sources/WalletReceiveScreen.swift +++ b/submodules/WalletUI/Sources/WalletReceiveScreen.swift @@ -170,7 +170,7 @@ private final class WalletReceiveScreenNode: ViewControllerTracingNode { self.textNode = ImmediateTextNode() self.textNode.textAlignment = .center - self.textNode.maximumNumberOfLines = 3 + self.textNode.maximumNumberOfLines = 5 self.qrImageNode = TransformImageNode() self.qrImageNode.clipsToBounds = true @@ -287,33 +287,6 @@ private final class WalletReceiveScreenNode: ViewControllerTracingNode { func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: ContainedViewLayoutTransition) { self.validLayout = (layout, navigationHeight) - var insets = layout.insets(options: []) - insets.top += navigationHeight - let inset: CGFloat = 22.0 - - let textSize = self.textNode.updateLayout(CGSize(width: layout.size.width - inset * 2.0, height: CGFloat.greatestFiniteMagnitude)) - let textFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - textSize.width) / 2.0), y: insets.top + 24.0), size: textSize) - transition.updateFrame(node: self.textNode, frame: textFrame) - - let makeImageLayout = self.qrImageNode.asyncLayout() - - let imageSide: CGFloat = 215.0 - let imageSize = CGSize(width: imageSide, height: imageSide) - let imageApply = makeImageLayout(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: nil)) - - let _ = imageApply() - - let imageFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - imageSize.width) / 2.0), y: textFrame.maxY + 20.0), size: imageSize) - transition.updateFrame(node: self.qrImageNode, frame: imageFrame) - transition.updateFrame(node: self.qrButtonNode, frame: imageFrame) - - if let qrCodeSize = self.qrCodeSize { - let (_, cutoutFrame, _) = qrCodeCutout(size: qrCodeSize, dimensions: imageSize, scale: nil) - self.qrIconNode.updateLayout(size: cutoutFrame.size) - transition.updateBounds(node: self.qrIconNode, bounds: CGRect(origin: CGPoint(), size: cutoutFrame.size)) - transition.updatePosition(node: self.qrIconNode, position: imageFrame.center.offsetBy(dx: 0.0, dy: -1.0)) - } - if self.urlTextNode.attributedText?.string.isEmpty ?? true { var url = urlForMode(self.mode) if case .receive = self.mode { @@ -335,18 +308,69 @@ private final class WalletReceiveScreenNode: ViewControllerTracingNode { self.urlTextNode.attributedText = NSAttributedString(string: sliced, font: addressFont, textColor: self.presentationData.theme.list.itemPrimaryTextColor, paragraphAlignment: .justified) } - let addressInset: CGFloat = 12.0 - let urlTextSize = self.urlTextNode.updateLayout(CGSize(width: layout.size.width - addressInset * 2.0, height: CGFloat.greatestFiniteMagnitude)) - transition.updateFrame(node: self.urlTextNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - urlTextSize.width) / 2.0), y: imageFrame.maxY + 23.0), size: urlTextSize)) + var insets = layout.insets(options: []) + insets.top += navigationHeight + let inset: CGFloat = 22.0 let buttonSideInset: CGFloat = 16.0 let bottomInset = insets.bottom + 10.0 let buttonWidth = layout.size.width - buttonSideInset * 2.0 let buttonHeight: CGFloat = 50.0 + let textSize = self.textNode.updateLayout(CGSize(width: layout.size.width - inset * 2.0, height: CGFloat.greatestFiniteMagnitude)) + + let addressInset: CGFloat = 12.0 + let urlTextSize = self.urlTextNode.updateLayout(CGSize(width: layout.size.width - addressInset * 2.0, height: CGFloat.greatestFiniteMagnitude)) + var buttonOffset: CGFloat = 0.0 if let _ = self.secondaryButtonNode.attributedTitle(for: .normal) { buttonOffset = -60.0 + } + + let imageSide: CGFloat = 215.0 + let imageSize = CGSize(width: imageSide, height: imageSide) + + let buttonTopEdge = layout.size.height - bottomInset - buttonHeight + buttonOffset + + var topTextSpacing: CGFloat = 24.0 + var imageSpacing: CGFloat = 20.0 + var urlSpacing: CGFloat = 23.0 + + var contentHeight: CGFloat = insets.top + contentHeight += topTextSpacing + textSize.height + contentHeight += imageSpacing + imageSide + contentHeight += urlSpacing + urlTextSize.height + + if contentHeight >= buttonTopEdge - 10.0 { + let factor: CGFloat = 0.5 + topTextSpacing = floor(topTextSpacing * factor * 0.3) + imageSpacing = floor(imageSpacing * factor) + urlSpacing = floor(urlSpacing * factor) + } + + let textFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - textSize.width) / 2.0), y: insets.top + topTextSpacing), size: textSize) + transition.updateFrame(node: self.textNode, frame: textFrame) + + let makeImageLayout = self.qrImageNode.asyncLayout() + + let imageApply = makeImageLayout(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: nil)) + + let _ = imageApply() + + let imageFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - imageSize.width) / 2.0), y: textFrame.maxY + imageSpacing), size: imageSize) + transition.updateFrame(node: self.qrImageNode, frame: imageFrame) + transition.updateFrame(node: self.qrButtonNode, frame: imageFrame) + + if let qrCodeSize = self.qrCodeSize { + let (_, cutoutFrame, _) = qrCodeCutout(size: qrCodeSize, dimensions: imageSize, scale: nil) + self.qrIconNode.updateLayout(size: cutoutFrame.size) + transition.updateBounds(node: self.qrIconNode, bounds: CGRect(origin: CGPoint(), size: cutoutFrame.size)) + transition.updatePosition(node: self.qrIconNode, position: imageFrame.center.offsetBy(dx: 0.0, dy: -1.0)) + } + + transition.updateFrame(node: self.urlTextNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - urlTextSize.width) / 2.0), y: imageFrame.maxY + urlSpacing), size: urlTextSize)) + + if let _ = self.secondaryButtonNode.attributedTitle(for: .normal) { self.secondaryButtonNode.frame = CGRect(x: floor((layout.size.width - buttonWidth) / 2.0), y: layout.size.height - bottomInset - buttonHeight, width: buttonWidth, height: buttonHeight) } diff --git a/wallet_env.sh b/wallet_env.sh index 1ec7b2a210..fad3729ac4 100755 --- a/wallet_env.sh +++ b/wallet_env.sh @@ -50,6 +50,18 @@ if [ "$WALLET_DISTRIBUTION_PROVISIONING_PROFILE_APP" == "" ]; then exit 1 fi +if [ "$CODESIGNING_DATA_PATH" == "" ]; then + echo "Set CODESIGNING_DATA_PATH to the path to a folder containing valid provisioning profiles corresponding to the chosen bundle ID ($WALLET_BUNDLE_ID)" + echo "Example: export CODESIGNING_DATA_PATH=\"\$HOME/wallet-provisioning-profiles\"" + exit 1 +fi + +if [ "$BUILD_NUMBER" == "" ]; then + echo "Set BUILD_NUMBER to a number that will be used as a version string for the build" + echo "Example: export BUILD_NUMBER=100" + exit 1 +fi + export DEVELOPMENT_CODE_SIGN_IDENTITY="$DEVELOPMENT_CODE_SIGN_IDENTITY" export DISTRIBUTION_CODE_SIGN_IDENTITY="$DISTRIBUTION_CODE_SIGN_IDENTITY" export WALLET_DEVELOPMENT_TEAM="$WALLET_DEVELOPMENT_TEAM"