Skip to content

Commit 223af48

Browse files
committed
Added circles to indicate transaction with < 6 confirmations
1 parent da4ab48 commit 223af48

4 files changed

Lines changed: 94 additions & 1 deletion

File tree

BitStore.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
9A9D588819D484C900EA940A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9A9D588A19D484C900EA940A /* Localizable.strings */; };
9696
9A9D588E19D4867400EA940A /* AccountActionButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D588D19D4867400EA940A /* AccountActionButton.m */; };
9797
9A9D588F19D4867700EA940A /* AccountActionButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D588D19D4867400EA940A /* AccountActionButton.m */; };
98+
9A9D589219D4BDD200EA940A /* CircleIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D589119D4BDD200EA940A /* CircleIndicator.m */; };
9899
9AA466BC1972D82A00A7B562 /* Color.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AA466BB1972D82A00A7B562 /* Color.m */; };
99100
9AA6C44C1986FAFA0035A430 /* HTAutocompleteTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AA6C44B1986FAFA0035A430 /* HTAutocompleteTextField.m */; };
100101
9AAAC41E19D092FE00994EB6 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AAAC41D19D092FE00994EB6 /* NotificationCenter.framework */; };
@@ -320,6 +321,8 @@
320321
9A9D588B19D484CE00EA940A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
321322
9A9D588C19D4867400EA940A /* AccountActionButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccountActionButton.h; sourceTree = "<group>"; };
322323
9A9D588D19D4867400EA940A /* AccountActionButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AccountActionButton.m; sourceTree = "<group>"; };
324+
9A9D589019D4BDD200EA940A /* CircleIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircleIndicator.h; sourceTree = "<group>"; };
325+
9A9D589119D4BDD200EA940A /* CircleIndicator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CircleIndicator.m; sourceTree = "<group>"; };
323326
9AA466BA1972D82A00A7B562 /* Color.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Color.h; sourceTree = "<group>"; };
324327
9AA466BB1972D82A00A7B562 /* Color.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Color.m; sourceTree = "<group>"; };
325328
9AA6C44A1986FAFA0035A430 /* HTAutocompleteTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTAutocompleteTextField.h; sourceTree = "<group>"; };
@@ -851,6 +854,8 @@
851854
9ABC072A1983174100EC87A3 /* AmountView.h */,
852855
9ABC072B1983174100EC87A3 /* AmountView.m */,
853856
9ABC072D1983175300EC87A3 /* AmountViewDelegate.h */,
857+
9A9D589019D4BDD200EA940A /* CircleIndicator.h */,
858+
9A9D589119D4BDD200EA940A /* CircleIndicator.m */,
854859
);
855860
path = Views;
856861
sourceTree = "<group>";
@@ -1127,6 +1132,7 @@
11271132
9A67A77F1950D70A001FCE32 /* Address.m in Sources */,
11281133
9A67A7821950D70A001FCE32 /* ContactList.m in Sources */,
11291134
9A1DAECB197C305400BB9DF7 /* ChangeUnitViewController.m in Sources */,
1135+
9A9D589219D4BDD200EA940A /* CircleIndicator.m in Sources */,
11301136
9A9D588319D1F73800EA940A /* SharedUser.m in Sources */,
11311137
9AFC4A14197F0F8400EAF46B /* KeysViewController.m in Sources */,
11321138
9A67A75E1950D70A001FCE32 /* ContactsNavigationController.m in Sources */,

BitStore/Cells/TransactionCell.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import "ContactHelper.h"
1616
#import "ContactListListener.h"
1717
#import "Unit.h"
18+
#import "CircleIndicator.h"
1819

1920
@interface TransactionCell () <ExchangeListener, ContactListListener>
2021
@end
@@ -26,6 +27,7 @@ @implementation TransactionCell {
2627
UILabel* _personLabel;
2728
UILabel* _valueLabel;
2829
UILabel* _dateLabel;
30+
CircleIndicator* _circleIndicator;
2931
}
3032

3133
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
@@ -44,8 +46,14 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4446
_dateLabel.font = [UIFont systemFontOfSize:11];
4547
_dateLabel.textAlignment = NSTextAlignmentRight;
4648
_dateLabel.textColor = [UIColor colorWithWhite:0.65 alpha:1.0];
49+
_dateLabel.hidden = YES;
4750
[self addSubview:_dateLabel];
4851

52+
_circleIndicator = [[CircleIndicator alloc] initWithCircles:6];
53+
_circleIndicator.frame = CGRectMake(self.frame.size.width - 90, 30, 80, 20);
54+
_circleIndicator.hidden = YES;
55+
[self addSubview:_circleIndicator];
56+
4957
[[ExchangeHelper instance] addExchangeListener:self];
5058
[[ContactHelper instance] addContactListListener:self];
5159

@@ -83,8 +91,12 @@ - (void)updateValues {
8391
_personLabel.text = [_contactList displayTextForAddress:address];
8492
_valueLabel.text = [_exchange.unit valueForSatoshi:_transaction.total];
8593
if (_transaction.confirmations < 6) {
86-
_dateLabel.text = @"Pending";
94+
_circleIndicator.hidden = NO;
95+
_dateLabel.hidden = YES;
96+
[_circleIndicator setFilledCircles:_transaction.confirmations];
8797
} else {
98+
_circleIndicator.hidden = YES;
99+
_dateLabel.hidden = NO;
88100
_dateLabel.text = _transaction.date.dateTimeAgo;
89101
}
90102
}

BitStore/Views/CircleIndicator.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// CircleIndicator.h
3+
// BitStore
4+
//
5+
// Created by Dylan Marriott on 25/09/14.
6+
// Copyright (c) 2014 Dylan Marriott. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface CircleIndicator : UIView
12+
13+
- (id)initWithCircles:(int)numberOfCircles;
14+
- (void)setFilledCircles:(int)filledCircles;
15+
16+
- (id)init UNAVAILABLE_ATTRIBUTE;
17+
- (instancetype)initWithFrame:(CGRect)frame UNAVAILABLE_ATTRIBUTE;
18+
19+
@end

BitStore/Views/CircleIndicator.m

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// CircleIndicator.m
3+
// BitStore
4+
//
5+
// Created by Dylan Marriott on 25/09/14.
6+
// Copyright (c) 2014 Dylan Marriott. All rights reserved.
7+
//
8+
9+
#import "CircleIndicator.h"
10+
11+
static CGFloat circleRadius = 4;
12+
13+
@implementation CircleIndicator {
14+
NSMutableArray* _circleViews;
15+
}
16+
17+
- (id)initWithCircles:(int)numberOfCircles {
18+
if (self = [super init]) {
19+
_circleViews = [NSMutableArray array];
20+
for (int i = 0; i < numberOfCircles; i++) {
21+
UIView* circle = [[UIView alloc] init];
22+
circle.layer.cornerRadius = circleRadius;
23+
circle.layer.borderColor = [UIColor colorWithWhite:0.6 alpha:1.0].CGColor;
24+
circle.layer.borderWidth = 0.5f;
25+
circle.backgroundColor = [UIColor clearColor];
26+
[_circleViews addObject:circle];
27+
[self addSubview:circle];
28+
}
29+
}
30+
return self;
31+
}
32+
33+
- (void)setFilledCircles:(int)filledCircles {
34+
NSAssert(filledCircles <= _circleViews.count, @"Can't fill more circles than provided.");
35+
NSAssert(filledCircles >= 0, @"Can't fill < 0 circles.");
36+
37+
for (int i = 0; i < filledCircles; i++) {
38+
UIView* circle = [_circleViews objectAtIndex:_circleViews.count - i - 1];
39+
circle.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1.0];
40+
}
41+
for (int i = filledCircles; i < _circleViews.count; i++) {
42+
UIView* circle = [_circleViews objectAtIndex:_circleViews.count - i - 1];
43+
circle.backgroundColor = [UIColor clearColor];
44+
}
45+
}
46+
47+
- (void)layoutSubviews {
48+
[super layoutSubviews];
49+
CGFloat space = (self.bounds.size.width - (circleRadius * 2 * _circleViews.count)) / (_circleViews.count - 1);
50+
for (int i = 0; i < _circleViews.count; i++) {
51+
UIView* circle = [_circleViews objectAtIndex:i];
52+
circle.frame = CGRectMake(i * (space + circleRadius * 2), self.bounds.size.height / 2 - circleRadius, circleRadius * 2, circleRadius * 2);
53+
}
54+
}
55+
56+
@end

0 commit comments

Comments
 (0)