Skip to content

Commit 21ad22a

Browse files
committed
Initial dump
1 parent 6bd04b7 commit 21ad22a

38 files changed

+3687
-1
lines changed

.travis.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: generic
2+
3+
notifications:
4+
slack:
5+
rooms:
6+
- nozeio:LIFY1Jtkx0FRcLq3u1WliHRZ
7+
- zeeql:odi4PEJUdmDPkBfjhHIaSdrS
8+
- apacheexpress:9z2IfvxZfENp0TFmiYCgyUKz
9+
10+
matrix:
11+
include:
12+
- os: osx
13+
osx_image: xcode8.3
14+
- os: osx
15+
osx_image: xcode9 - fails decodable in testSchemaWithInlineArrayToMany
16+
- os: osx
17+
osx_image: xcode9.2
18+
- os: osx
19+
osx_image: xcode9.3beta
20+
21+
script:
22+
- make

Info.plist

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>LSMinimumSystemVersion</key>
24+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
25+
<key>NSHumanReadableCopyright</key>
26+
<string>Copyright © 2018 ZeeZide GmbH. All rights reserved.</string>
27+
<key>NSPrincipalClass</key>
28+
<string>NSApplication</string>
29+
</dict>
30+
</plist>

LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2018 ZeeZide GmbH
2+
All rights reserved.
3+
4+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
7+
NONINFRINGEMENT.
8+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
9+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
10+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
11+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
12+
THE SOFTWARE.
13+

Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Makefile
2+
# Copyright © 2018 ZeeZide GmbH. All rights reserved.
3+
4+
PACKAGE_NAME = swift-progress
5+
6+
include config.make
7+
8+
all : $(SWIFT_PROGRESS_BUILD_RESULT)
9+
10+
clean :
11+
rm -rf build
12+
13+
distclean : clean
14+
15+
install : all
16+
$(MKDIR_P) $(BINARY_INSTALL_DIR)/
17+
$(INSTALL) $(SWIFT_PROGRESS_BUILD_RESULT) $(BINARY_INSTALL_DIR)/
18+
19+
uninstall :
20+
$(UNINSTALL) $(BINARY_INSTALL_DIR)/swift-progress
21+
22+
# rules
23+
24+
$(SWIFT_PROGRESS_BUILD_RESULT) :
25+
xcodebuild -target $(PACKAGE_NAME) -configuration $(CONFIGURATION)

README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
# swift-progress
1+
<h2>swift-progress
2+
<img src="http://zeezide.com/img/SwiftXcodePkgIcon128.png"
3+
align="right" width="128" height="128" />
4+
</h2>
5+
6+
![Swift4](https://img.shields.io/badge/swift-4-blue.svg)
7+
![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat)
8+
![Travis](https://travis-ci.org/SwiftXcode/swift-progress.svg?branch=master)
9+
10+
Visualize SPM progress in a window.
11+
12+
### Who
13+
14+
Brought to you by the
15+
[The Always Right Institute](http://www.alwaysrightinstitute.com)
16+
and
17+
[ZeeZide](http://zeezide.de).
18+
We like
19+
[feedback](https://twitter.com/ar_institute),
20+
GitHub stars,
21+
cool [contract work](http://zeezide.com/en/services/services.html),
22+
presumably any form of praise you can think of.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// UXToolbarStatusView.h
3+
// swift-progress
4+
//
5+
// Created by Helge Hess on 01.03.18.
6+
// Copyright © 2018 ZeeZide. All rights reserved.
7+
//
8+
9+
@import Cocoa;
10+
11+
@interface UXToolbarStatusView : NSView
12+
13+
- (NSTextField *)textField;
14+
- (NSProgressIndicator *)spinner;
15+
- (NSImageView *)imageView;
16+
17+
#pragma mark Spinner
18+
19+
- (void)startSpinner;
20+
- (void)stopSpinner;
21+
- (void)fullstopSpinner; // reset retain count
22+
23+
#pragma mark Title
24+
25+
- (void)setStringValue:(NSString *)_value;
26+
- (NSString *)stringValue;
27+
28+
@end
+197
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
//
2+
// UXToolbarStatusView.m
3+
// swift-progress
4+
//
5+
// Created by Helge Hess on 01.03.18.
6+
// Copyright © 2016-2018 ZeeZide. All rights reserved.
7+
//
8+
9+
@import QuartzCore;
10+
11+
#import "UXToolbarStatusView.h"
12+
#import "UXViewFactory.h"
13+
14+
@implementation UXToolbarStatusView
15+
{
16+
NSTextField *_tf;
17+
NSImageView *_iv;
18+
NSProgressIndicator *_pi;
19+
20+
NSUInteger spinnerCount;
21+
}
22+
23+
const CGFloat ZZToolbarCornerRadius = 4.0;
24+
25+
+ (BOOL)requiresConstraintBasedLayout {
26+
return YES;
27+
}
28+
29+
- (NSColor *)bottomColor {
30+
return [NSColor colorWithCalibratedRed:0.929 green:0.929 blue:0.929 alpha:1];
31+
}
32+
- (NSColor *)topColor {
33+
return [NSColor colorWithCalibratedRed:1 green:1 blue:1 alpha:1];
34+
}
35+
36+
- (id)initWithFrame:(NSRect)frameRect {
37+
if ((self = [super initWithFrame:frameRect])) {
38+
self.wantsLayer = YES;
39+
self.layer.masksToBounds = YES;
40+
self.layer.cornerRadius = ZZToolbarCornerRadius;
41+
self.layer.borderWidth = 0.5;
42+
self.layer.borderColor = [NSColor lightGrayColor].CGColor;
43+
44+
CAGradientLayer *gradient = [CAGradientLayer layer];
45+
gradient.frame = self.bounds;
46+
gradient.colors = @[(id)self.topColor.CGColor,(id)self.bottomColor.CGColor];
47+
gradient.autoresizingMask = (NSViewWidthSizable | NSViewHeightSizable);
48+
[self.layer addSublayer:gradient];
49+
50+
[self _zzCreateSubviews];
51+
[self _zzCreateConstraints];
52+
}
53+
return self;
54+
}
55+
- (id)init {
56+
// 23 seems to be right, not sure. 26 is better for small spinner
57+
// return [self initWithFrame:NSMakeRect(0, 0, 320, 26)];
58+
// Xcode 8b size is 24px - also, buttons are always 24px high!
59+
// 25 seems to align properly with buttons.
60+
return [self initWithFrame:NSMakeRect(0, 0, 320, 25)];
61+
}
62+
63+
- (NSProgressIndicator *)makeProgressIndicator {
64+
NSProgressIndicator *v;
65+
66+
v = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0,0,42,42)];
67+
v.translatesAutoresizingMaskIntoConstraints = NO;
68+
69+
v.indeterminate = YES;
70+
v.displayedWhenStopped = NO;
71+
v.bezeled = NO;
72+
v.controlSize = NSControlSizeSmall; // NSMiniControlSize;
73+
v.style = NSProgressIndicatorBarStyle;
74+
75+
return v;
76+
}
77+
78+
- (void)_zzCreateSubviews {
79+
#if 0
80+
self->_iv = [[NSImageView alloc] initWithFrame:ZZInitialSize];
81+
self->_iv.translatesAutoresizingMaskIntoConstraints = NO;
82+
#endif
83+
84+
// @"ZeeCore | Build ZeeCore: Succeeded"
85+
UXViewFactory *vf = [UXViewFactory defaultViewFactory];
86+
self->_tf = [vf makeLabel:@""];
87+
88+
self->_tf.cell.lineBreakMode = NSLineBreakByTruncatingTail;
89+
self->_tf.cell.wraps = NO;
90+
self->_tf.cell.usesSingleLineMode = YES;
91+
92+
self->_tf.alignment = NSTextAlignmentLeft;
93+
self->_tf.translatesAutoresizingMaskIntoConstraints = NO;
94+
self->_tf.font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
95+
self->_tf.textColor = [NSColor blackColor];
96+
97+
self->_pi = [self makeProgressIndicator];
98+
99+
if (self->_iv) [self addSubview:self->_iv];
100+
if (self->_tf) [self addSubview:self->_tf];
101+
if (self->_pi) [self addSubview:self->_pi];
102+
103+
#if 0 // TESTING
104+
[self->_pi startAnimation:nil];
105+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)),
106+
dispatch_get_main_queue(), ^{
107+
[self->_pi stopAnimation:nil];
108+
});
109+
#endif
110+
}
111+
112+
static inline NSArray *vfl(NSString *_vfl, NSDictionary *_views) {
113+
return [NSLayoutConstraint constraintsWithVisualFormat:_vfl
114+
options:0 metrics:nil views:_views];
115+
}
116+
117+
- (void)_zzCreateConstraints {
118+
NSDictionary *nv = self->_iv
119+
? @{ @"image": self->_iv, @"title": self->_tf, @"progress": self->_pi }
120+
: @{ @"title": self->_tf, @"progress": self->_pi };
121+
122+
NSMutableArray *constraints = [NSMutableArray arrayWithCapacity:8];
123+
124+
/* horizontal */
125+
126+
if (self->_iv)
127+
[constraints addObjectsFromArray:vfl(@"H:|-[image]-[title]-|", nv)];
128+
else
129+
[constraints addObjectsFromArray:vfl(@"H:|-10-[title]-|", nv)];
130+
131+
[constraints addObjectsFromArray:vfl(@"H:|[progress]|", nv)];
132+
133+
[_tf setContentHuggingPriority:230
134+
forOrientation:NSLayoutConstraintOrientationHorizontal];
135+
136+
/* vertical */
137+
// TODO: bulk activate
138+
if (self->_iv)
139+
[constraints addObject:[_iv.centerYAnchor constraintEqualToAnchor:self.centerYAnchor]];
140+
141+
[constraints addObject:[_tf.centerYAnchor constraintEqualToAnchor:self.centerYAnchor]];
142+
143+
[constraints addObjectsFromArray:vfl(@"V:[progress(==3)]|", nv)];
144+
145+
[NSLayoutConstraint activateConstraints:constraints];
146+
}
147+
148+
#pragma mark Children
149+
150+
- (NSTextField *)textField {
151+
return self->_tf;
152+
}
153+
154+
- (NSImageView *)imageView {
155+
return self->_iv;
156+
}
157+
158+
- (NSProgressIndicator *)spinner {
159+
return self->_pi;
160+
}
161+
162+
163+
#pragma mark Spinner
164+
165+
- (void)startSpinner {
166+
if (self->spinnerCount == 0) {
167+
[self->_pi startAnimation:self];
168+
//self->_refreshButton.hidden = YES;
169+
//self->_tbView.imageView.hidden = YES;
170+
}
171+
self->spinnerCount++;
172+
}
173+
- (void)stopSpinner {
174+
if (self->spinnerCount == 0) return;
175+
176+
self->spinnerCount--;
177+
if (self->spinnerCount == 0) {
178+
[self->_pi stopAnimation:self];
179+
//self->_refreshButton.hidden = NO;
180+
}
181+
}
182+
- (void)fullstopSpinner {
183+
self->spinnerCount = 0;
184+
[self->_pi stopAnimation:self];
185+
}
186+
187+
#pragma mark Title
188+
189+
- (void)setStringValue:(NSString *)_value {
190+
self->_tf.stringValue = _value;
191+
}
192+
- (NSString *)stringValue {
193+
return self->_tf.stringValue;
194+
}
195+
196+
@end
197+

Sources/Core/UI/Views/UXViewFactory.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// ZzViewControllerFactory.h
3+
// swift-progress
4+
//
5+
// Created by Helge Hess on 27.02.18.
6+
// Copyright © 2018 ZeeZide GmbH. All rights reserved.
7+
//
8+
9+
@import Cocoa;
10+
11+
typedef NSView UXView;
12+
typedef NSTextField UXLabel;
13+
typedef NSProgressIndicator UXSpinner;
14+
typedef NSScrollView UXScrollView;
15+
typedef NSTableView UXTableView;
16+
typedef NSImage UXImage;
17+
typedef NSImageView UXImageView;
18+
typedef NSColor UXColor;
19+
typedef NSTextView UXTextView;
20+
21+
@interface UXViewFactory : NSObject
22+
23+
+ (UXViewFactory *)defaultViewFactory;
24+
25+
- (__kindof UXView *)make:(Class)_class with:(void (^)(__kindof UXView *))block;
26+
27+
- (UXLabel *)makeLabel:(id)value;
28+
- (UXSpinner *)makeSpinner;
29+
- (UXScrollView *)makeTableView:(void (^)(NSTableView *view))block;
30+
- (UXView *)makeTextView:(void (^)(UXTextView *))block;
31+
- (UXView *)makeTextView;
32+
- (UXView *)makeVisualEffectsSeeThroughContainer;
33+
34+
@end
35+
36+
@interface NSViewController(Zz)
37+
- (UXViewFactory *)zz;
38+
@end
39+

0 commit comments

Comments
 (0)