diff --git a/Signal/Images.xcassets/ic_dark_theme_off.imageset/Contents.json b/Signal/Images.xcassets/ic_dark_theme_off.imageset/Contents.json new file mode 100644 index 000000000..b61a86768 --- /dev/null +++ b/Signal/Images.xcassets/ic_dark_theme_off.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "dark-theme-off-24@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "dark-theme-off-24@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "dark-theme-off-24@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@1x.png b/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@1x.png new file mode 100644 index 000000000..78d8d6869 Binary files /dev/null and b/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@1x.png differ diff --git a/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@2x.png b/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@2x.png new file mode 100644 index 000000000..f63cd9b30 Binary files /dev/null and b/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@2x.png differ diff --git a/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@3x.png b/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@3x.png new file mode 100644 index 000000000..10824a121 Binary files /dev/null and b/Signal/Images.xcassets/ic_dark_theme_off.imageset/dark-theme-off-24@3x.png differ diff --git a/Signal/Images.xcassets/ic_dark_theme_on.imageset/Contents.json b/Signal/Images.xcassets/ic_dark_theme_on.imageset/Contents.json new file mode 100644 index 000000000..419eeeb08 --- /dev/null +++ b/Signal/Images.xcassets/ic_dark_theme_on.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "dark-theme-on-24@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "dark-theme-on-24@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "dark-theme-on-24@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@1x.png b/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@1x.png new file mode 100644 index 000000000..1ff344e0a Binary files /dev/null and b/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@1x.png differ diff --git a/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@2x.png b/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@2x.png new file mode 100644 index 000000000..fbdf614dd Binary files /dev/null and b/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@2x.png differ diff --git a/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@3x.png b/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@3x.png new file mode 100644 index 000000000..a82283feb Binary files /dev/null and b/Signal/Images.xcassets/ic_dark_theme_on.imageset/dark-theme-on-24@3x.png differ diff --git a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m index c9f8f93d6..dd341c3a9 100644 --- a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m @@ -195,15 +195,6 @@ NS_ASSUME_NONNULL_BEGIN } [contents addSection:censorshipSection]; - OWSTableSection *themeSection = [OWSTableSection new]; - themeSection.headerTitle = NSLocalizedString(@"THEME_SECTION", nil); - [themeSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_DARK_THEME", - @"Label for setting that enables dark theme.") - isOn:[Theme isDarkThemeEnabled] - target:weakSelf - selector:@selector(didToggleThemeSwitch:)]]; - [contents addSection:themeSection]; - self.contents = contents; } @@ -285,13 +276,6 @@ NS_ASSUME_NONNULL_BEGIN [self updateTableContents]; } -- (void)didToggleThemeSwitch:(UISwitch *)sender -{ - [Theme setIsDarkThemeEnabled:sender.isOn]; - - [self updateTableContents]; -} - @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m index 7383bc3dd..63c0084d3 100644 --- a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m @@ -85,7 +85,7 @@ [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(dismissWasPressed:)]; - + [self updateRightBarButtonForTheme]; [self observeNotifications]; self.title = NSLocalizedString(@"SETTINGS_NAV_BAR_TITLE", @"Title for settings activity"); @@ -467,6 +467,44 @@ [RegistrationUtils showReregistrationUIFromViewController:self]; } +#pragma mark - Dark Theme + +- (UIBarButtonItem *)darkThemeBarButton +{ + UIBarButtonItem *barButtonItem; + if (Theme.isDarkThemeEnabled) { + barButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_dark_theme_on"] + style:UIBarButtonItemStylePlain + target:self + action:@selector(didPressDisableDarkTheme:)]; + } else { + barButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_dark_theme_off"] + style:UIBarButtonItemStylePlain + target:self + action:@selector(didPressEnableDarkTheme:)]; + } + return barButtonItem; +} + +- (void)didPressEnableDarkTheme:(id)sender +{ + [Theme setIsDarkThemeEnabled:YES]; + [self updateRightBarButtonForTheme]; + [self updateTableContents]; +} + +- (void)didPressDisableDarkTheme:(id)sender +{ + [Theme setIsDarkThemeEnabled:NO]; + [self updateRightBarButtonForTheme]; + [self updateTableContents]; +} + +- (void)updateRightBarButtonForTheme +{ + self.navigationItem.rightBarButtonItem = [self darkThemeBarButton]; +} + #pragma mark - Socket Status Notifications - (void)observeNotifications