From 14222d7bd0b60d0305f9d55e6d91d855fcff4774 Mon Sep 17 00:00:00 2001 From: Andrew Son <24321494+Andoran90@users.noreply.github.com> Date: Sun, 1 Sep 2024 07:18:02 +0500 Subject: [PATCH] IOS-7677 markdown support (#3734) --- .../DescriptionBottomSheetView.swift | 11 +++++++++- TangemApp.xcodeproj/project.pbxproj | 17 ++++++++++++++++ .../xcshareddata/swiftpm/Package.resolved | 20 ++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/Tangem/UIComponents/DescriptionBottomSheet/DescriptionBottomSheetView.swift b/Tangem/UIComponents/DescriptionBottomSheet/DescriptionBottomSheetView.swift index 99c429e8ea..3c31b06b79 100644 --- a/Tangem/UIComponents/DescriptionBottomSheet/DescriptionBottomSheetView.swift +++ b/Tangem/UIComponents/DescriptionBottomSheet/DescriptionBottomSheetView.swift @@ -7,6 +7,7 @@ // import SwiftUI +import MarkdownUI struct DescriptionBottomSheetInfo: Identifiable, Equatable { let id: UUID = .init() @@ -46,7 +47,8 @@ struct DescriptionBottomSheetView: View { .padding(.vertical, 12) } - Text(info.description) + Markdown { info.description } + .markdownSoftBreakMode(.lineBreak) .frame(maxWidth: .infinity, alignment: .topLeading) .style(Fonts.Regular.callout, color: Colors.Text.primary1) .fixedSize(horizontal: false, vertical: true) @@ -61,3 +63,10 @@ extension DescriptionBottomSheetView: SelfSizingBottomSheetContent, Setupable { map { $0.sheetHeight = binding } } } + +#Preview { + DescriptionBottomSheetView(info: .init( + title: "About Ethereum", + description: "Ethereum network is a blockchain network.\n- Ethereum is an open-source platform for decentralized applications.\n- It aims to create a world computer for building applications in a decentralized manner.\n- Supports smart contracts allowing developers to program digital value.\n- Examples of dapps include tokens, NFTs, DeFi apps, lending protocols, and decentralized exchanges.\n- Transactions and smart contract executions require Gas fees, paid in Ether (ETH).\n- Gas measures the computational effort needed for operations, with fees fluctuating based on network demand.\n\n• Tether (USDT) is a stablecoin pegged to the U.S. dollar. \n • It offers stability in the volatile crypto market. \n• Issued by Tether Limited, governed by British Virgin Islands laws.\n• Used on exchanges like Bitfinex for trading cryptocurrencies.\n• Facilitates quick and cheap fiat movement in exchanges.\n• No transaction fees, but conversion fees apply on Tether.to.\n• Supports Ethereum network; ending support on EOS, Algorand, and others." + )) +} diff --git a/TangemApp.xcodeproj/project.pbxproj b/TangemApp.xcodeproj/project.pbxproj index 0ed441824b..2302f422e2 100644 --- a/TangemApp.xcodeproj/project.pbxproj +++ b/TangemApp.xcodeproj/project.pbxproj @@ -532,6 +532,7 @@ B0AF2DF82B1DF42D001A8696 /* PendingExpressTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF2DF72B1DF42D001A8696 /* PendingExpressTransaction.swift */; }; B0AF9BFB2C32D01200EC5830 /* TokenMarketsDetailsView+Skeletons.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0AF9BF92C32D01200EC5830 /* TokenMarketsDetailsView+Skeletons.swift */; }; B0B09BCF295B54FB001D6BA4 /* WalletConnectSessionsStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0B09BCE295B54FB001D6BA4 /* WalletConnectSessionsStorage.swift */; }; + B0B11A082C787FE70018A2A6 /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = B0B11A072C787FE70018A2A6 /* MarkdownUI */; }; B0B2DF6026E1FD5400BC0934 /* AnimatedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0B2DF5F26E1FD5400BC0934 /* AnimatedView.swift */; }; B0B335D229FA89EE00E2082E /* BalanceFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0B335D129FA89EE00E2082E /* BalanceFormatter.swift */; }; B0B335DC29FA948F00E2082E /* FakeTokenItemInfoProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0B335DB29FA948F00E2082E /* FakeTokenItemInfoProvider.swift */; }; @@ -3747,6 +3748,7 @@ buildActionMask = 2147483647; files = ( B6E298CF2C5D9CC3004336BC /* DGCharts in Frameworks */, + B0B11A082C787FE70018A2A6 /* MarkdownUI in Frameworks */, B6C1BE6D2B6C2F4E008FE5A0 /* secp256k1 in Frameworks */, EF2D9C9B2BBDA87D0055C485 /* TangemFoundation.framework in Frameworks */, EF9E29A82B4F0C9900418559 /* TangemExpress.framework in Frameworks */, @@ -9885,6 +9887,7 @@ B620FC9F2C5D326D00AD0FD1 /* DGCharts */, B620FCAD2C5D337900AD0FD1 /* DGCharts */, B6E298CE2C5D9CC3004336BC /* DGCharts */, + B0B11A072C787FE70018A2A6 /* MarkdownUI */, ); productName = "Tangem Tap"; productReference = 5D3F77C224BF56D800E8695B /* Tangem.app */; @@ -10160,6 +10163,7 @@ 0A81B38C2BB3018E0008F21C /* XCRemoteSwiftPackageReference "ZIPFoundation" */, 0ABC61132C410AFD00065EBA /* XCRemoteSwiftPackageReference "tweetnacl-swiftwrap" */, B6E298CD2C5D9CC2004336BC /* XCRemoteSwiftPackageReference "DGCharts" */, + B0B11A062C787FE70018A2A6 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */, ); productRefGroup = 5D3F77C324BF56D800E8695B /* Products */; projectDirPath = ""; @@ -18086,6 +18090,14 @@ minimumVersion = 1.1.0; }; }; + B0B11A062C787FE70018A2A6 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/gonzalezreal/swift-markdown-ui"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.4.0; + }; + }; B6C1BE6B2B6C2F4E008FE5A0 /* XCRemoteSwiftPackageReference "secp256k1.swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/GigaBitcoin/secp256k1.swift.git"; @@ -18123,6 +18135,11 @@ package = 0ABC61132C410AFD00065EBA /* XCRemoteSwiftPackageReference "tweetnacl-swiftwrap" */; productName = TweetNacl; }; + B0B11A072C787FE70018A2A6 /* MarkdownUI */ = { + isa = XCSwiftPackageProductDependency; + package = B0B11A062C787FE70018A2A6 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */; + productName = MarkdownUI; + }; B620FC9F2C5D326D00AD0FD1 /* DGCharts */ = { isa = XCSwiftPackageProductDependency; productName = DGCharts; diff --git a/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved b/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4b96b17cc9..80d0af90b1 100644 --- a/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "075de3e24c2b843c7ca823c45d9a9eb94d54bca81938a008551eefd90553cf5f", + "originHash" : "b28913ecd789c4712900743ff0a5e2709f20a88cfbdf046c9516a04cdd85d340", "pins" : [ { "identity" : "anyasyncsequence", @@ -82,6 +82,15 @@ "version" : "0.1.2-tangem3" } }, + { + "identity" : "networkimage", + "kind" : "remoteSourceControl", + "location" : "https://github.com/gonzalezreal/NetworkImage", + "state" : { + "revision" : "7aff8d1b31148d32c5933d75557d42f6323ee3d1", + "version" : "6.0.0" + } + }, { "identity" : "potentcodables", "kind" : "remoteSourceControl", @@ -163,6 +172,15 @@ "version" : "1.5.4" } }, + { + "identity" : "swift-markdown-ui", + "kind" : "remoteSourceControl", + "location" : "https://github.com/gonzalezreal/swift-markdown-ui", + "state" : { + "revision" : "55441810c0f678c78ed7e2ebd46dde89228e02fc", + "version" : "2.4.0" + } + }, { "identity" : "swift-nio", "kind" : "remoteSourceControl",