mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-05 20:16:25 +03:00
Jump to add account screen from accounts list
This commit is contained in:
parent
6c2f69b800
commit
510917bd8b
@ -32,6 +32,8 @@
|
||||
2C8A09C6267513FC00993638 /* Agent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8A09C5267513FC00993638 /* Agent.swift */; };
|
||||
2C8A09D42675184700993638 /* Window.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8A09D32675184700993638 /* Window.swift */; };
|
||||
2C8A09D726751A0C00993638 /* WalletConnect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8A09D626751A0C00993638 /* WalletConnect.swift */; };
|
||||
2C8A09DF267579EA00993638 /* AccountsListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8A09DE267579EA00993638 /* AccountsListViewController.swift */; };
|
||||
2C8A09E326757FC000993638 /* AccountCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8A09E226757FC000993638 /* AccountCellView.swift */; };
|
||||
88745B0F4DEE1F60AD0F02C3 /* Pods_Encrypted_Ink.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3704D7F64179CCDCE2E8C783 /* Pods_Encrypted_Ink.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -65,6 +67,8 @@
|
||||
2C8A09C5267513FC00993638 /* Agent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Agent.swift; sourceTree = "<group>"; };
|
||||
2C8A09D32675184700993638 /* Window.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Window.swift; sourceTree = "<group>"; };
|
||||
2C8A09D626751A0C00993638 /* WalletConnect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnect.swift; sourceTree = "<group>"; };
|
||||
2C8A09DE267579EA00993638 /* AccountsListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsListViewController.swift; sourceTree = "<group>"; };
|
||||
2C8A09E226757FC000993638 /* AccountCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountCellView.swift; sourceTree = "<group>"; };
|
||||
3704D7F64179CCDCE2E8C783 /* Pods_Encrypted_Ink.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Encrypted_Ink.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -167,6 +171,8 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2C1995412674C4B900A8E370 /* ImportViewController.swift */,
|
||||
2C8A09DE267579EA00993638 /* AccountsListViewController.swift */,
|
||||
2C8A09E226757FC000993638 /* AccountCellView.swift */,
|
||||
2C1995452674C4BA00A8E370 /* Main.storyboard */,
|
||||
);
|
||||
path = Screens;
|
||||
@ -326,6 +332,7 @@
|
||||
0DB729162674E2DB0011F7A1 /* EIP712SimpleValue.swift in Sources */,
|
||||
0DB729122674E2DB0011F7A1 /* EIP712ParameterEncoder.swift in Sources */,
|
||||
2C8A09D726751A0C00993638 /* WalletConnect.swift in Sources */,
|
||||
2C8A09E326757FC000993638 /* AccountCellView.swift in Sources */,
|
||||
0DB729202674E2DB0011F7A1 /* EIP712Domain.swift in Sources */,
|
||||
0DB729182674E2DB0011F7A1 /* EIP712Signer.swift in Sources */,
|
||||
0DB729192674E2DB0011F7A1 /* EIP712TypedData.swift in Sources */,
|
||||
@ -339,6 +346,7 @@
|
||||
0DB7291E2674E2DB0011F7A1 /* EIP712Signable.swift in Sources */,
|
||||
0DB7291C2674E2DB0011F7A1 /* EIP712Value.swift in Sources */,
|
||||
2C1995562674D0F300A8E370 /* Ethereum.swift in Sources */,
|
||||
2C8A09DF267579EA00993638 /* AccountsListViewController.swift in Sources */,
|
||||
2C1995742674E80E00A8E370 /* NearbyConnectivity.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -18,6 +18,7 @@ struct AccountsService {
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
// TODO: checksum address
|
||||
let address = addressBytes.toPrefixedHexString()
|
||||
let account = Account(privateKey: privateKey, address: address)
|
||||
var accounts = getAccounts()
|
||||
|
23
Encrypted Ink/Screens/AccountCellView.swift
Normal file
23
Encrypted Ink/Screens/AccountCellView.swift
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright © 2021 Encrypted Ink. All rights reserved.
|
||||
|
||||
import Cocoa
|
||||
import BlockiesSwift
|
||||
|
||||
class AccountCellView: NSTableRowView {
|
||||
|
||||
@IBOutlet weak var addressImageView: NSImageView! {
|
||||
didSet {
|
||||
addressImageView.wantsLayer = true
|
||||
addressImageView.layer?.cornerRadius = 15
|
||||
addressImageView.layer?.masksToBounds = true
|
||||
}
|
||||
}
|
||||
@IBOutlet weak var addressTextField: NSTextField!
|
||||
|
||||
func setup(address: String) {
|
||||
addressImageView.image = Blockies(seed: address).createImage()
|
||||
let without0x = address.dropFirst(2)
|
||||
addressTextField.stringValue = without0x.prefix(4) + "..." + without0x.suffix(4)
|
||||
}
|
||||
|
||||
}
|
54
Encrypted Ink/Screens/AccountsListViewController.swift
Normal file
54
Encrypted Ink/Screens/AccountsListViewController.swift
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright © 2021 Encrypted Ink. All rights reserved.
|
||||
|
||||
import Cocoa
|
||||
|
||||
class AccountsListViewController: NSViewController {
|
||||
|
||||
private var accounts = AccountsService.getAccounts()
|
||||
|
||||
@IBOutlet weak var titleLabel: NSTextField!
|
||||
@IBOutlet weak var tableView: NSTableView! {
|
||||
didSet {
|
||||
tableView.delegate = self
|
||||
tableView.dataSource = self
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
@IBAction func addButtonTapped(_ sender: NSButton) {
|
||||
if let importViewController = storyboard?.instantiateController(withIdentifier: "ImportViewController") as? ImportViewController {
|
||||
view.window?.contentViewController = importViewController
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension AccountsListViewController: NSTableViewDelegate {
|
||||
|
||||
func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
|
||||
// TODO: jump somewhere else
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension AccountsListViewController: NSTableViewDataSource {
|
||||
|
||||
func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|
||||
let rowView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("AccountCellView"), owner: self) as? AccountCellView
|
||||
rowView?.setup(address: accounts[row].address)
|
||||
return rowView
|
||||
}
|
||||
|
||||
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
|
||||
return 50
|
||||
}
|
||||
|
||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||
return accounts.count
|
||||
}
|
||||
|
||||
}
|
@ -684,11 +684,11 @@
|
||||
<!--Window Controller-->
|
||||
<scene sceneID="R2V-B0-nI4">
|
||||
<objects>
|
||||
<windowController storyboardIdentifier="ImportViewController" showSeguePresentationStyle="single" id="B8D-0N-5wS" sceneMemberID="viewController">
|
||||
<windowController showSeguePresentationStyle="single" id="B8D-0N-5wS" sceneMemberID="viewController">
|
||||
<window key="window" title="Encrypted Ink" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" tabbingMode="disallowed" id="IQv-IB-iLA">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
|
||||
<rect key="contentRect" x="561" y="393" width="250" height="350"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
|
||||
</connections>
|
||||
@ -704,7 +704,7 @@
|
||||
<!--Import View Controller-->
|
||||
<scene sceneID="hIz-AP-VOD">
|
||||
<objects>
|
||||
<viewController id="XfG-lQ-9wD" customClass="ImportViewController" customModule="Encrypted_Ink" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<viewController storyboardIdentifier="ImportViewController" id="XfG-lQ-9wD" customClass="ImportViewController" customModule="Encrypted_Ink" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" id="m2S-Jp-Qdl">
|
||||
<rect key="frame" x="0.0" y="0.0" width="250" height="350"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
@ -762,5 +762,134 @@ DQ
|
||||
</objects>
|
||||
<point key="canvasLocation" x="75" y="740"/>
|
||||
</scene>
|
||||
<!--Accounts List View Controller-->
|
||||
<scene sceneID="o7E-xn-hDh">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="AccountsListViewController" id="29s-Rd-OUf" customClass="AccountsListViewController" customModule="Encrypted_Ink" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" id="Yjc-Zm-uZY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="251" height="350"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="dkh-kG-EFj">
|
||||
<rect key="frame" x="54" y="292" width="144" height="34"/>
|
||||
<textFieldCell key="cell" controlSize="large" selectable="YES" alignment="center" title="Accounts" id="9No-vQ-vBK">
|
||||
<font key="font" metaFont="systemHeavy" size="29"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="40" horizontalPageScroll="10" verticalLineScroll="40" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="7bs-Kr-ija">
|
||||
<rect key="frame" x="0.0" y="0.0" width="251" height="272"/>
|
||||
<clipView key="contentView" id="RjU-hi-SHx">
|
||||
<rect key="frame" x="1" y="1" width="249" height="270"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="40" rowSizeStyle="automatic" viewBased="YES" id="glA-FK-Kdd">
|
||||
<rect key="frame" x="0.0" y="0.0" width="249" height="270"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<size key="intercellSpacing" width="17" height="0.0"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
||||
<tableColumns>
|
||||
<tableColumn width="237" minWidth="40" maxWidth="1000" id="Usc-6R-O3H">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="ieT-MJ-hVX">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="AccountCellView" id="Lp1-Zy-70c" customClass="AccountCellView" customModule="Encrypted_Ink" customModuleProvider="target">
|
||||
<rect key="frame" x="8" y="0.0" width="232" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="pdB-jS-gKE">
|
||||
<rect key="frame" x="64" y="5" width="30" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="30" id="Dmm-fG-F82"/>
|
||||
<constraint firstAttribute="height" constant="30" id="MNb-Zm-mjg"/>
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSApplicationIcon" id="RY9-3f-d0k"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="15"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sef-hl-iPV">
|
||||
<rect key="frame" x="98" y="8" width="62" height="25"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Label" id="2a6-9c-AzV">
|
||||
<font key="font" metaFont="systemBold" size="21"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="sef-hl-iPV" firstAttribute="leading" secondItem="pdB-jS-gKE" secondAttribute="trailing" constant="6" id="dOe-pb-lgM"/>
|
||||
<constraint firstItem="sef-hl-iPV" firstAttribute="centerY" secondItem="Lp1-Zy-70c" secondAttribute="centerY" id="gLs-yM-ovd"/>
|
||||
<constraint firstItem="sef-hl-iPV" firstAttribute="centerX" secondItem="Lp1-Zy-70c" secondAttribute="centerX" constant="13" id="l4c-Hs-Xss"/>
|
||||
<constraint firstItem="pdB-jS-gKE" firstAttribute="centerY" secondItem="Lp1-Zy-70c" secondAttribute="centerY" id="wKS-vz-pVO"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="addressImageView" destination="pdB-jS-gKE" id="Feb-Zz-q1a"/>
|
||||
<outlet property="addressTextField" destination="sef-hl-iPV" id="aGb-wC-t98"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
</tableView>
|
||||
</subviews>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="IT1-B8-OHF">
|
||||
<rect key="frame" x="-100" y="-100" width="238" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="1fG-vB-QGH">
|
||||
<rect key="frame" x="224" y="17" width="15" height="102"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ngQ-Bn-Kwd">
|
||||
<rect key="frame" x="206" y="299" width="33" height="21"/>
|
||||
<buttonCell key="cell" type="inline" bezelStyle="inline" image="plus" catalog="system" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" state="on" imageScaling="proportionallyDown" inset="2" id="JVh-da-a0h">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="systemBold" size="21"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="addButtonTapped:" target="29s-Rd-OUf" id="MKz-Ok-RUY"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="ngQ-Bn-Kwd" firstAttribute="leading" secondItem="dkh-kG-EFj" secondAttribute="trailing" constant="10" id="2jH-ov-jln"/>
|
||||
<constraint firstItem="7bs-Kr-ija" firstAttribute="leading" secondItem="Yjc-Zm-uZY" secondAttribute="leading" id="3n0-jB-KwV"/>
|
||||
<constraint firstAttribute="trailing" secondItem="7bs-Kr-ija" secondAttribute="trailing" id="6m3-S7-WJp"/>
|
||||
<constraint firstItem="ngQ-Bn-Kwd" firstAttribute="centerY" secondItem="dkh-kG-EFj" secondAttribute="centerY" id="Fx3-l2-Ire"/>
|
||||
<constraint firstAttribute="trailing" secondItem="ngQ-Bn-Kwd" secondAttribute="trailing" constant="12" id="Ln4-b5-NfT"/>
|
||||
<constraint firstItem="dkh-kG-EFj" firstAttribute="top" secondItem="Yjc-Zm-uZY" secondAttribute="top" constant="24" id="oaa-yR-g0U"/>
|
||||
<constraint firstItem="dkh-kG-EFj" firstAttribute="centerX" secondItem="Yjc-Zm-uZY" secondAttribute="centerX" id="qoF-Dr-xWA"/>
|
||||
<constraint firstItem="7bs-Kr-ija" firstAttribute="top" secondItem="dkh-kG-EFj" secondAttribute="bottom" constant="20" id="w9v-GA-ZtN"/>
|
||||
<constraint firstAttribute="bottom" secondItem="7bs-Kr-ija" secondAttribute="bottom" id="zCE-cx-u4r"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="tableView" destination="glA-FK-Kdd" id="9aW-Qr-UuF"/>
|
||||
<outlet property="titleLabel" destination="dkh-kG-EFj" id="xDn-bP-HWG"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<customObject id="JTb-7y-Jwq" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="400" y="740"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="NSApplicationIcon" width="32" height="32"/>
|
||||
<image name="plus" catalog="system" width="14" height="13"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
@ -16,6 +16,8 @@ class ImportViewController: NSViewController {
|
||||
}
|
||||
|
||||
@IBAction func actionButtonTapped(_ sender: Any) {
|
||||
AccountsService.addAccount(privateKey: textField.stringValue)
|
||||
|
||||
// TODO: open accounts list
|
||||
|
||||
WalletConnect.shared.connect(link: globalLink, address: "0xCf60CC6E4AD79187E7eBF62e0c21ae3a343180B2") { connected in
|
||||
@ -23,9 +25,13 @@ class ImportViewController: NSViewController {
|
||||
// use connected value
|
||||
}
|
||||
|
||||
if let accounts = storyboard?.instantiateController(withIdentifier: "AccountsListViewController") as? AccountsListViewController {
|
||||
view.window?.contentViewController = accounts
|
||||
}
|
||||
|
||||
// TODO: show spinner
|
||||
Window.closeAll()
|
||||
Window.activateSafari()
|
||||
// Window.closeAll()
|
||||
// Window.activateSafari()
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user