DataPickerState.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2021 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. // Dictionary Key indicating whether multiple selection is enabled.
  18. extern NSString * const kMultipleSelectKey;
  19. // Dictionary Key for the array of elements to be shown.
  20. extern NSString * const kElementsKey;
  21. // Dictionary Key for the label of each element.
  22. extern NSString * const kLabelKey;
  23. // Dictionary Key for the short label for each element (Optional).
  24. extern NSString * const kShortLabelKey;
  25. // Dictionary Key to indicate whether a particular element should be selected by default (Optional).
  26. extern NSString * const kSelectedKey;
  27. // DataPickerState objects keep track of the list of available cells and set
  28. // of selected cells that are being used in a DataPickerViewController object.
  29. @interface DataPickerState : NSObject
  30. // An ordered list of cell labels (NSStrings) to select from
  31. @property(strong, nonatomic) NSArray *cellLabels;
  32. // A set of the labels of the selected cells (NSStrings).
  33. @property(strong, nonatomic) NSMutableSet *selectedCells;
  34. // Determines if multiple cells can be checked.
  35. @property(assign, nonatomic) BOOL multipleSelectEnabled;
  36. // Initializes a DataPickerState to collect its data from
  37. // the provided dictionary. The assumption about the provided
  38. // dictionary is that it obeys the structure:
  39. // dict[@"multiple-select"] - BOOL that represents whether multiple of the
  40. // elements can be simultaneously selected.
  41. // dict[@"elements"] - Array that contains the list of cell items to be shown.
  42. // dict[@"elements"][index] - Dictionary that contains properties for each cell.
  43. // dict[@"elements"][index][@"label"] - String storing the label of the cell.
  44. // dict[@"elements"][index][@"selected"] - BOOL for whether the cell begins as
  45. // selected. If this property is not
  46. // set, then we default to NO.
  47. - (id)initWithDictionary:(NSDictionary *)dict;
  48. @end