|
11 | 11 |
|
12 | 12 | NSString *const SHOW_NOTICE = @"showNotice";
|
13 | 13 | NSString *const SHOW_TILE_URL_MANAGER =@"showTileURLManager";
|
| 14 | +NSString *const CONTACT_US = @"contactUs"; |
14 | 15 |
|
15 | 16 | @interface MCSettingsViewController ()
|
16 | 17 | @property (nonatomic, strong) NSMutableArray *cellArray;
|
@@ -225,6 +226,21 @@ - (void)initCellArray {
|
225 | 226 | }
|
226 | 227 | [bottomCells addObject:_zoomSwitchCell];
|
227 | 228 |
|
| 229 | + MCButtonCell *contactUsButtonCell = [self.tableView dequeueReusableCellWithIdentifier:@"buttonCell"]; |
| 230 | + [contactUsButtonCell setButtonLabel:@"Contact Us"]; |
| 231 | + contactUsButtonCell.action = CONTACT_US; |
| 232 | + contactUsButtonCell.delegate = self; |
| 233 | + |
| 234 | + [contactUsButtonCell useSecondaryColors]; |
| 235 | + |
| 236 | + UIImage *envelopeIcon = [UIImage systemImageNamed:@"envelope.fill"]; |
| 237 | + [contactUsButtonCell.button setImage:envelopeIcon forState:UIControlStateNormal]; |
| 238 | + |
| 239 | + contactUsButtonCell.button.tintColor = contactUsButtonCell.button.titleLabel.textColor; |
| 240 | + |
| 241 | + contactUsButtonCell.button.imageEdgeInsets = UIEdgeInsetsMake(0, -4, 0, 4); |
| 242 | + [bottomCells addObject:contactUsButtonCell]; |
| 243 | + |
228 | 244 | MCButtonCell *showNoticesButtonCell = [self.tableView dequeueReusableCellWithIdentifier:@"buttonCell"];
|
229 | 245 | [showNoticesButtonCell setButtonLabel:@"About MapCache"];
|
230 | 246 | showNoticesButtonCell.action = SHOW_NOTICE;
|
@@ -551,13 +567,27 @@ - (void) switchChanged:(id)sender {
|
551 | 567 |
|
552 | 568 | }
|
553 | 569 |
|
| 570 | +- (void)openMailClient { |
| 571 | + NSString *email = @"[email protected]"; |
| 572 | + NSString *encoded = [NSString stringWithFormat:@"mailto:%@", email]; |
| 573 | + NSString *escaped = [encoded stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; |
| 574 | + NSURL *url = [NSURL URLWithString:escaped]; |
| 575 | + |
| 576 | + if ([[UIApplication sharedApplication] canOpenURL:url]) { |
| 577 | + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; |
| 578 | + } else { |
| 579 | + NSLog(@"Cannot open mail client"); |
| 580 | + } |
| 581 | +} |
554 | 582 |
|
555 | 583 | #pragma mark - ButtonCell delegate
|
556 | 584 | - (void)performButtonAction:(NSString *)action {
|
557 | 585 | if ([action isEqualToString:SHOW_NOTICE]) {
|
558 | 586 | [self.settingsDelegate showNoticeAndAttributeView];
|
559 | 587 | } else if ([action isEqualToString:SHOW_TILE_URL_MANAGER]) {
|
560 | 588 | [self.settingsDelegate showTileURLManager];
|
| 589 | + } else if ([action isEqualToString:CONTACT_US]) { |
| 590 | + [self openMailClient]; |
561 | 591 | }
|
562 | 592 | }
|
563 | 593 |
|
|
0 commit comments