Skip to content

Commit

Permalink
Feature: Configure dark and tinted mode icons for iOS 18+ (#569)
Browse files Browse the repository at this point in the history
* Add support for iOS dark and tinted icons

* Fix location of Contents.json file

* Fix location of Contents.json file

* Fix generation of Contents.json file

* Prevent ios-marketing idiom from getting dark and tinted variants

* Split Contents.json types in legacy and new variants

* Add tests

* Add ability to desaturate tinted iOS images

* Add documentation and template file for iOS dark and tinted icons
  • Loading branch information
KevinHaendel authored Sep 21, 2024
1 parent 006cb1e commit 93a697f
Show file tree
Hide file tree
Showing 10 changed files with 460 additions and 187 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ foreground of the Android 13+ themed icon. For more information see [Android Ada
- `icon/path/here.png`: This will generate a new launcher icons for the platform with the name you specify, without removing the old default existing Flutter launcher icon.
- `image_path_ios`: The location of the icon image file specific for iOS platform (optional - if not defined then the image_path is used)
- `remove_alpha_ios`: Removes alpha channel for IOS icons
- `image_path_ios_dark_transparent`: The location of the dark mode icon image file specific for iOS 18+ platform. *Note: Apple recommends this icon to be transparent. For more information see [Apple Human Interface Guidelines for App Icons](https://developer.apple.com/design/human-interface-guidelines/app-icons#iOS-iPadOS)*
- `image_path_ios_tinted_grayscale`: The location of the tinted mode icon image file specific for iOS 18+ platform. *Note: This icon should be an grayscale image. Use `desaturate_tinted_to_grayscale_ios: true` to automatically desaturate the image provided here.*
- `desaturate_tinted_to_grayscale_ios`: Automatically desaturates tinted mode icon image to grayscale, *defaults to false*
- `background_color_ios`: The color (in the format "#RRGGBB") to be used as the background when removing the alpha channel. It is used only when the `remove_alpha_ios` property is set to true. (optional - if not defined then `#ffffff` is used)

### Web
Expand Down
3 changes: 3 additions & 0 deletions bin/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ flutter_launcher_icons:
ios: true
# image_path_ios: "assets/icon/icon.png"
remove_alpha_channel_ios: true
# image_path_ios_dark_transparent: "assets/icon/icon_dark.png"
# image_path_ios_tinted_grayscale: "assets/icon/icon_tinted.png"
# desaturate_tinted_to_grayscale_ios: true
web:
generate: true
Expand Down
15 changes: 15 additions & 0 deletions lib/config/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ class Config {
this.ios = false,
this.imagePathAndroid,
this.imagePathIOS,
this.imagePathIOSDarkTransparent,
this.imagePathIOSTintedGrayscale,
this.adaptiveIconForeground,
this.adaptiveIconBackground,
this.adaptiveIconMonochrome,
this.minSdkAndroid = constants.androidDefaultAndroidMinSDK,
this.removeAlphaIOS = false,
this.desaturateTintedToGrayscaleIOS = false,
this.backgroundColorIOS = '#ffffff',
this.webConfig,
this.windowsConfig,
Expand Down Expand Up @@ -117,6 +120,14 @@ class Config {
@JsonKey(name: 'image_path_ios')
final String? imagePathIOS;

/// IOS image_path_ios_dark_transparent
@JsonKey(name: 'image_path_ios_dark_transparent')
final String? imagePathIOSDarkTransparent;

/// IOS image_path_ios_tinted_grayscale
@JsonKey(name: 'image_path_ios_tinted_grayscale')
final String? imagePathIOSTintedGrayscale;

/// android adaptive_icon_foreground image
@JsonKey(name: 'adaptive_icon_foreground')
final String? adaptiveIconForeground;
Expand All @@ -137,6 +148,10 @@ class Config {
@JsonKey(name: 'remove_alpha_ios')
final bool removeAlphaIOS;

/// IOS desaturate_tinted_to_grayscale
@JsonKey(name: 'desaturate_tinted_to_grayscale_ios')
final bool desaturateTintedToGrayscaleIOS;

/// IOS background_color_ios
@JsonKey(name: 'background_color_ios')
final String backgroundColorIOS;
Expand Down
20 changes: 18 additions & 2 deletions lib/config/config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config/windows_config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 93a697f

Please sign in to comment.