-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support generating android adaptive icons
- Loading branch information
Showing
14 changed files
with
251 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'adaptive_icon.g.dart'; | ||
|
||
@JsonSerializable(anyMap: true, createToJson: false) | ||
class AdaptiveIcon { | ||
final String foreground; | ||
final String background; | ||
|
||
AdaptiveIcon({required this.foreground, required this.background}); | ||
|
||
factory AdaptiveIcon.fromJson(Map<String, dynamic> json) => | ||
_$AdaptiveIconFromJson(json); | ||
} |
19 changes: 19 additions & 0 deletions
19
lib/src/parser/models/flavors/android/adaptive_icon.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
lib/src/processors/android/icons/android_adaptive_icon_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter_flavorizr/src/parser/models/flavorizr.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/image_resizer_processor.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/queue_processor.dart'; | ||
import 'package:flutter_flavorizr/src/utils/constants.dart'; | ||
import 'package:sprintf/sprintf.dart'; | ||
|
||
class AndroidAdaptiveIconProcessor extends QueueProcessor { | ||
String foregroundSource; | ||
String backgroundSource; | ||
String flavorName; | ||
String folder; | ||
Size size; | ||
|
||
AndroidAdaptiveIconProcessor( | ||
this.foregroundSource, | ||
this.backgroundSource, | ||
this.flavorName, | ||
this.folder, | ||
this.size, { | ||
required Flavorizr config, | ||
}) : super([ | ||
ImageResizerProcessor( | ||
foregroundSource, | ||
sprintf(K.androidAdaptiveIconForegroundPath, [flavorName, folder]), | ||
size, | ||
config: config, | ||
), | ||
ImageResizerProcessor( | ||
backgroundSource, | ||
sprintf(K.androidAdaptiveIconBackgroundPath, [flavorName, folder]), | ||
size, | ||
config: config, | ||
), | ||
], config: config); | ||
|
||
@override | ||
String toString() => 'AndroidAdaptiveIconProcessor'; | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/src/processors/android/icons/android_adaptive_icon_xml_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:flutter_flavorizr/src/parser/models/flavorizr.dart'; | ||
import 'package:flutter_flavorizr/src/processors/android/icons/android_generate_iclauncher_xml_processor.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/new_file_string_processor.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/queue_processor.dart'; | ||
import 'package:flutter_flavorizr/src/utils/constants.dart'; | ||
import 'package:sprintf/sprintf.dart'; | ||
|
||
class AndroidAdaptiveIconXmlProcessor extends QueueProcessor { | ||
AndroidAdaptiveIconXmlProcessor( | ||
String? flavorName, { | ||
required Flavorizr config, | ||
}) : super( | ||
[ | ||
NewFileStringProcessor( | ||
sprintf(K.androidAdaptiveIconXmlPath, [flavorName]), | ||
AndroidGenerateIclauncherXmlProcessor(config: config), | ||
config: config, | ||
), | ||
], | ||
config: config, | ||
); | ||
|
||
@override | ||
String toString() => 'AndroidAdaptiveIconXmlProcessor'; | ||
} |
45 changes: 45 additions & 0 deletions
45
lib/src/processors/android/icons/android_adaptive_icons_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:flutter_flavorizr/src/parser/models/flavorizr.dart'; | ||
import 'package:flutter_flavorizr/src/processors/android/icons/android_adaptive_icon_processor.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/image_resizer_processor.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/queue_processor.dart'; | ||
|
||
class AndroidAdaptiveIconsProcessor extends QueueProcessor { | ||
static const _entries = { | ||
'drawable-mdpi': Size(width: 108, height: 108), | ||
'drawable-hdpi': Size(width: 162, height: 162), | ||
'drawable-xhdpi': Size(width: 216, height: 216), | ||
'drawable-xxhdpi': Size(width: 324, height: 324), | ||
'drawable-xxxhdpi': Size(width: 432, height: 432), | ||
}; | ||
|
||
String foregroundSource; | ||
String backgroundSource; | ||
String flavorName; | ||
|
||
AndroidAdaptiveIconsProcessor( | ||
this.foregroundSource, | ||
this.backgroundSource, | ||
this.flavorName, { | ||
required Flavorizr config, | ||
}) : super( | ||
_entries.map( | ||
(folder, size) { | ||
return MapEntry( | ||
folder, | ||
AndroidAdaptiveIconProcessor( | ||
foregroundSource, | ||
backgroundSource, | ||
flavorName, | ||
folder, | ||
size, | ||
config: config, | ||
), | ||
); | ||
}, | ||
).values, | ||
config: config, | ||
); | ||
|
||
@override | ||
String toString() => 'AndroidAdaptiveIconsProcessor'; | ||
} |
22 changes: 22 additions & 0 deletions
22
lib/src/processors/android/icons/android_generate_iclauncher_xml_processor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter_flavorizr/src/parser/models/flavorizr.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/string_processor.dart'; | ||
|
||
class AndroidGenerateIclauncherXmlProcessor extends StringProcessor { | ||
AndroidGenerateIclauncherXmlProcessor({ | ||
required Flavorizr config, | ||
}) : super( | ||
config: config, | ||
); | ||
|
||
@override | ||
String execute() { | ||
return '<?xml version="1.0" encoding="utf-8"?>' | ||
'<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">' | ||
'<background android:drawable="@drawable/ic_launcher_background" />' | ||
'<foreground android:drawable="@drawable/ic_launcher_foreground" />' | ||
'</adaptive-icon>'; | ||
} | ||
|
||
@override | ||
String toString() => 'AndroidGenerateIclauncherXmlProcessor'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters