mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
This PR is dependent on https://github.com/material-components/material-components-ios/pull/6035. And there is no new API change on MDCChipTextField class level. This PR is meant to solve the problem mentioned in https://github.com/material-components/material-components-ios/pull/6035 -> "Enabling scrolling of the Chips and the remaining alignment issues will be resolved in followup PRs." The issues it solves: (1) Alignment (a way to adjust it also) (2) clear button (3) the coupling issue with apple's leftView in the original PR. Screenshots:   
53 lines
1.7 KiB
Objective-C
53 lines
1.7 KiB
Objective-C
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import "MaterialChips.h"
|
|
|
|
@class MDCChipTextFieldScrollView;
|
|
|
|
@protocol MDCChipTextFieldScrollViewDelegate <NSObject, UIScrollViewDelegate>
|
|
|
|
// TODO: delegate methods to handle touch event
|
|
|
|
@end
|
|
|
|
@protocol MDCChipTextFieldScrollViewDataSource <NSObject>
|
|
|
|
- (NSInteger)numberOfChipsInScrollView:(nonnull MDCChipTextFieldScrollView *)scrollView;
|
|
- (nullable MDCChipView *)scrollView:(nonnull MDCChipTextFieldScrollView *)scrollView
|
|
chipForIndex:(NSInteger)index;
|
|
|
|
@end
|
|
|
|
@interface MDCChipTextFieldScrollView : UIScrollView
|
|
|
|
@property(nonatomic, weak, nullable) id<MDCChipTextFieldScrollViewDelegate> delegate;
|
|
@property(nonatomic, weak, nullable) id<MDCChipTextFieldScrollViewDataSource> dataSource;
|
|
|
|
/**
|
|
The spacing between chips in this scroll view.
|
|
*/
|
|
@property(nonatomic) CGFloat chipSpacing;
|
|
|
|
- (void)scrollToLeft;
|
|
- (void)scrollToRight;
|
|
|
|
// TODO: remove these methods if we decide to go with data source. Needs revisit.
|
|
- (void)appendChipView:(nonnull MDCChipView *)chipView;
|
|
- (void)removeChipView:(nonnull MDCChipView *)chipView;
|
|
|
|
@end
|