Skip to content
This repository was archived by the owner on Jun 3, 2022. It is now read-only.

Commit 4c1114e

Browse files
author
Andres Ugarte
committed
Mostly work on RMXCellTextInput
1 parent 92d952d commit 4c1114e

14 files changed

+109
-65
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![remixer](https://cdn.rawgit.com/material-foundation/material-remixer/master/docs/assets/lockup_remixer_icon_horizontal_dark_small.svg)
22

3-
Remixer helps teams use and refine design specs by providing an abstraction for these values that is accessible and configurable from both inside and outside the app itself.
3+
Remixer helps teams use and refine design specs by providing an abstraction for these values that is accessible and configurable from both inside and outside the app itself.
44

55
This SDK for iOS is currently in development.
66

@@ -73,13 +73,13 @@ Note that we currently support only RMXStorageModeLocal as RMXStorageModeCloud i
7373

7474
- (BOOL)application:(UIApplication *)application
7575
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
76-
76+
7777
// Create the window
7878
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
7979

8080
// Start Remixer
8181
[RMXRemixer startInMode:RMXStorageModeLocal];
82-
82+
8383
// Create the root view controller and set it in the window
8484
self.window.rootViewController = [[UIViewController alloc] init];
8585
[self.window makeKeyAndVisible];
@@ -105,7 +105,7 @@ Now you can add Remixer variables in your view controller classes as follows:
105105
_box = [[UIView alloc] initWithFrame:CGRectMake(50, 150, 80, 80)];
106106
_box.backgroundColor = [UIColor redColor];
107107
[self.view addSubview:_box];
108-
108+
109109
// Add a color variable to control the background color.
110110
// Note: You can set possibleValues to limit it to certain colors.
111111
[RMXColorVariable

examples/objc/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ PODS:
2323
- GoogleToolboxForMac/Defines (2.1.0)
2424
- GoogleToolboxForMac/NSData+zlib (2.1.0):
2525
- GoogleToolboxForMac/Defines (= 2.1.0)
26-
- Remixer/Core (1.0.0)
27-
- Remixer/Firebase (1.0.0):
28-
- Firebase/Core
29-
- Firebase/Database
26+
- Remixer/Core (0.5.2)
27+
- Remixer/Firebase (0.5.2):
28+
- Firebase/Core (~> 3.8)
29+
- Firebase/Database (~> 3.1)
3030
- Remixer/Core
3131

3232
DEPENDENCIES:
@@ -45,7 +45,7 @@ SPEC CHECKSUMS:
4545
GoogleInterchangeUtilities: d5bc4d88d5b661ab72f9d70c58d02ca8c27ad1f7
4646
GoogleSymbolUtilities: 631ee17048aa5e9ab133470d768ea997a5ef9b96
4747
GoogleToolboxForMac: 2b2596cbb7186865e98cadf2b1e262d851c2b168
48-
Remixer: 6083bf76ba904c8e7dfa38acb2834cdad4b49838
48+
Remixer: d358089aa00e0b780ae0710a2b356b0c7d36016a
4949

5050
PODFILE CHECKSUM: d1a9444e2abc793509b33eccd75ed4aaad6d17bf
5151

examples/objc/RemixerExample/ColorDemoViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ - (void)viewDidLoad {
3838
[RMXColorVariable
3939
colorVariableWithKey:@"boxBgColor"
4040
defaultValue:[UIColor redColor]
41-
possibleValues:@[[UIColor redColor], [UIColor blueColor], [UIColor greenColor]]
41+
possibleValues:@[ [UIColor redColor], [UIColor blueColor], [UIColor greenColor] ]
4242
updateBlock:^(RMXColorVariable *_Nonnull variable, UIColor *selectedValue) {
4343
_box.backgroundColor = selectedValue;
4444
}];

examples/objc/RemixerExample/FontViewController.m

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,40 @@ - (void)viewDidLoad {
3030
[super viewDidLoad];
3131
self.view.backgroundColor = [UIColor whiteColor];
3232

33-
_fontLabel =
34-
[[UILabel alloc] initWithFrame:CGRectMake(0, 100, CGRectGetWidth(self.view.bounds), 40)];
33+
_fontLabel = [[UILabel alloc] initWithFrame:CGRectZero];
34+
_fontLabel.numberOfLines = 0;
3535
_fontLabel.textAlignment = NSTextAlignmentCenter;
3636
[self.view addSubview:_fontLabel];
3737

38+
[RMXStringVariable stringVariableWithKey:@"labelText"
39+
defaultValue:@"This is a customizable label"
40+
updateBlock:^(RMXStringVariable *variable, NSString *selectedValue) {
41+
_fontLabel.text = selectedValue;
42+
[self.view setNeedsLayout];
43+
}];
44+
3845
NSArray<NSString *> *fontNames = @[
3946
@"System", @"AvenirNext-Bold", @"Baskerville-SemiBold", @"Courier",
4047
@"Futura-CondensedExtraBold", @"Helvetica-Light", @"SnellRoundhand"
4148
];
4249
[RMXStringVariable
43-
stringVariableWithKey:@"font"
50+
stringVariableWithKey:@"labelFont"
4451
defaultValue:fontNames[1]
45-
// possibleValues:fontNames
46-
updateBlock:^(RMXStringVariable *variable, NSString *selectedValue) {
47-
NSString *fontName = selectedValue;
48-
_fontLabel.text = fontName;
52+
possibleValues:fontNames
53+
updateBlock:^(RMXStringVariable *variable, NSString *selectedFontName) {
54+
_fontLabel.font =
55+
[UIFont fontWithName:selectedFontName size:_fontLabel.font.pointSize];
56+
[self.view setNeedsLayout];
4957
}];
5058
}
5159

60+
- (void)viewWillLayoutSubviews {
61+
[super viewWillLayoutSubviews];
62+
63+
CGSize labelSize = [_fontLabel sizeThatFits:CGRectInset(self.view.bounds, 20, 100).size];
64+
_fontLabel.frame = CGRectMake(20, 100, self.view.bounds.size.width - 40, labelSize.height);
65+
}
66+
5267
- (void)viewWillDisappear:(BOOL)animated {
5368
[super viewWillDisappear:animated];
5469
[RMXRemixer removeAllVariables];

examples/objc/RemixerExample/SpinningBoxViewController.m

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,22 @@ - (void)viewDidLoad {
6161

6262
// Set box2 animation to be twice as fast.
6363
presentationLayer = _box2.layer.presentationLayer;
64-
angle =
65-
[[presentationLayer valueForKeyPath:@"transform.rotation.z"] floatValue];
64+
angle = [[presentationLayer valueForKeyPath:@"transform.rotation.z"] floatValue];
6665
animation.fromValue = [NSNumber numberWithFloat:angle];
6766
animation.toValue = [NSNumber numberWithFloat:angle + M_PI * 2.0];
6867
animation.duration = MAX(2.0 - (selectedValue * 2), 0.1);
6968
[_box2.layer addAnimation:animation forKey:@"spinning"];
7069
}];
7170

72-
[RMXBooleanVariable
73-
booleanVariableWithKey:@"slowAnimations"
74-
defaultValue:NO
75-
updateBlock:^(RMXBooleanVariable *variable, BOOL selectedValue) {
76-
CALayer *layer = self.view.layer;
77-
layer.timeOffset =
78-
[layer convertTime:CACurrentMediaTime() fromLayer:nil];
79-
layer.beginTime = CACurrentMediaTime();
80-
layer.speed = selectedValue ? 0.2 : 1;
81-
}];
71+
[RMXBooleanVariable booleanVariableWithKey:@"slowAnimations"
72+
defaultValue:NO
73+
updateBlock:^(RMXBooleanVariable *variable, BOOL selectedValue) {
74+
CALayer *layer = self.view.layer;
75+
layer.timeOffset =
76+
[layer convertTime:CACurrentMediaTime() fromLayer:nil];
77+
layer.beginTime = CACurrentMediaTime();
78+
layer.speed = selectedValue ? 0.2 : 1;
79+
}];
8280
}
8381

8482
- (void)viewWillDisappear:(BOOL)animated {

src/core/RMXRemixer.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ + (void)start {
9191
if (instance.storageMode == RMXStorageModeLocal) {
9292
instance.storage = [[RMXLocalStorageController alloc] init];
9393
} else {
94-
#ifdef REMIXER_CLOUD_FIREBASE
94+
#ifdef REMIXER_CLOUD_FIREBASE
9595
instance.storage = [[RMXFirebaseStorageController alloc] init];
96-
#else
96+
#else
9797
instance.storage = [[RMXLocalStorageController alloc] init];
98-
// TODO(chuga): Print out a warning.
99-
#endif
98+
// TODO(chuga): Print out a warning.
99+
#endif
100100
}
101101
[instance.storage setup];
102102
[instance.storage startObservingUpdates];

src/core/UI/RMXOverlayViewController.m

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
#import "RMXCellButton.h"
2424
#import "RMXCellColorList.h"
25+
#import "RMXCellColorPicker.h"
2526
#import "RMXCellSegmented.h"
2627
#import "RMXCellSlider.h"
2728
#import "RMXCellStepper.h"
2829
#import "RMXCellSwitch.h"
2930
#import "RMXCellTextInput.h"
30-
#import "RMXCellColorPicker.h"
3131
#import "RMXCellTextPicker.h"
3232
#import "RMXOverlayNavigationBar.h"
3333
#import "RMXOverlayView.h"
@@ -41,7 +41,8 @@
4141
@interface RMXOverlayViewController () <UITableViewDataSource,
4242
UITableViewDelegate,
4343
UIGestureRecognizerDelegate,
44-
RMXOverlayViewDelegate>
44+
RMXOverlayViewDelegate,
45+
RMXCellDelegate>
4546
@property(nonatomic, strong) RMXOverlayView *view;
4647
@end
4748

@@ -65,6 +66,7 @@ - (void)viewDidLoad {
6566

6667
self.view.tableView.dataSource = self;
6768
self.view.tableView.delegate = self;
69+
self.view.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
6870

6971
[self.view.tableView registerClass:[RMXCellButton class]
7072
forCellReuseIdentifier:NSStringFromClass([RMXCellButton class])];
@@ -203,10 +205,11 @@ - (void)maximizePanel {
203205
}
204206

205207
- (void)dismissOverlay:(id)sender {
206-
[self dismissOptionsViewWithCompletion:nil];
208+
[self dismissOverlayWithCompletion:nil];
207209
}
208210

209-
- (void)dismissOptionsViewWithCompletion:(void (^)(BOOL finished))completion {
211+
- (void)dismissOverlayWithCompletion:(void (^)(BOOL finished))completion {
212+
[self.view endEditing:YES];
210213
[UIView animateWithDuration:0.2
211214
animations:^{
212215
[self.view hidePanel];
@@ -229,7 +232,7 @@ - (void)sendEmailInvite:(id)sender {
229232
[RMXRemixer sendEmailInvite];
230233
}
231234

232-
#pragma mark - <UITableViewDataSource>
235+
#pragma mark - UITableViewDataSource
233236

234237
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
235238
return [_content count];
@@ -241,15 +244,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView
241244
NSString *identifier = [self cellIdentifierForVariable:variable];
242245
RMXCell *cell = (RMXCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
243246
cell.variable = variable;
247+
cell.delegate = self;
244248
return cell;
245249
}
246250

251+
#pragma mark - UITableViewDelegate
252+
247253
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
248254
RMXVariable *variable = _content[indexPath.row];
249255
return [[self cellClassForVariable:variable] cellHeight];
250256
}
251257

252-
#pragma mark - <RMXOverlayViewDelegate>
258+
#pragma mark - RMXOverlayViewDelegate
253259

254260
- (void)touchStartedAtPoint:(CGPoint)point withEvent:(UIEvent *)event {
255261
// No-op.
@@ -259,6 +265,12 @@ - (BOOL)shouldCapturePointOutsidePanel:(CGPoint)point {
259265
return self.presentedViewController != nil;
260266
}
261267

268+
#pragma mark - RMXCellDelegate
269+
270+
- (void)cellRequestedFullScreenOverlay:(RMXCell *)cell {
271+
[self maximizePanel];
272+
}
273+
262274
#pragma mark - Private
263275

264276
- (Class)cellClassForVariable:(RMXVariable *)variable {

src/core/UI/cells/RMXCell.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@
2121

2222
NS_ASSUME_NONNULL_BEGIN
2323

24+
@class RMXCell;
25+
2426
/** Minimal height for the cell. */
2527
extern const CGFloat RMXCellHeightMinimal;
2628

2729
/** Larger height for the cell. */
2830
extern const CGFloat RMXCellHeightLarge;
2931

32+
@protocol RMXCellDelegate <NSObject>
33+
34+
- (void)cellRequestedFullScreenOverlay:(RMXCell *)cell;
35+
36+
@end
37+
3038
/**
3139
The RMXCell class provides table view cell that should be subclassed for specific Variable
3240
model types.
@@ -39,6 +47,9 @@ extern const CGFloat RMXCellHeightLarge;
3947
/** The Variable this cell is controlling. */
4048
@property(nonatomic, weak) RMXVariable *variable;
4149

50+
/** The delegate for this cell. */
51+
@property(nonatomic, weak) id<RMXCellDelegate> delegate;
52+
4253
/** The height of this cell. Subclasses should override. */
4354
+ (CGFloat)cellHeight;
4455

src/core/UI/cells/RMXCellColorPicker.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ - (void)layoutSubviews {
9191
[_button sizeToFit];
9292
_button.frame =
9393
CGRectMake(CGRectGetWidth(self.controlViewWrapper.frame) - CGRectGetWidth(_button.frame),
94-
kButtonTopOffset,
95-
CGRectGetWidth(_button.frame),
96-
CGRectGetHeight(_button.frame));
94+
kButtonTopOffset, CGRectGetWidth(_button.frame), CGRectGetHeight(_button.frame));
9795
}
9896

9997
- (void)prepareForReuse {

src/core/UI/cells/RMXCellTextInput.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
Copyright 2016-present Google Inc. All Rights Reserved.
3-
3+
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
7-
7+
88
http://www.apache.org/licenses/LICENSE-2.0
9-
9+
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,7 @@
2121
NS_ASSUME_NONNULL_BEGIN
2222

2323
/** Provides a table view cell that has a text field. */
24-
@interface RMXCellTextInput: RMXCell
24+
@interface RMXCellTextInput : RMXCell
2525

2626
@property(nonatomic, weak) RMXStringVariable *variable;
2727

0 commit comments

Comments
 (0)