Skip to content

Commit

Permalink
chore: v0.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkOSullivan94 committed Apr 19, 2023
1 parent d314ca8 commit 33f4188
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 51 deletions.
2 changes: 1 addition & 1 deletion bin/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void _generateConfigFile(File configFile) {

const _configFileTemplate = '''
# flutter pub run flutter_launcher_icons
flutter_icons:
flutter_launcher_icons:
image_path: "assets/icon/icon.png"
android: "launcher_icon"
Expand Down
2 changes: 1 addition & 1 deletion example/flavors/flutter_launcher_icons-development.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flutter_icons:
flutter_launcher_icons:
android: true
ios: true
image_path: "assets/launcher_icon/demo-icon-dev.png"
2 changes: 1 addition & 1 deletion example/flavors/flutter_launcher_icons-integration.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flutter_icons:
flutter_launcher_icons:
android: true
ios: true
image_path: "assets/launcher_icon/demo-icon-int.png"
2 changes: 1 addition & 1 deletion example/flavors/flutter_launcher_icons-production.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flutter_icons:
flutter_launcher_icons:
android: true
ios: true
image_path: "assets/launcher_icon/demo-icon.png"
16 changes: 5 additions & 11 deletions lib/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import 'dart:io';

import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/constants.dart';
import 'package:flutter_launcher_icons/constants.dart' as constants;
import 'package:flutter_launcher_icons/custom_exceptions.dart';
import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/utils.dart' as utils;
import 'package:flutter_launcher_icons/xml_templates.dart' as xml_template;
import 'package:image/image.dart';
Expand Down Expand Up @@ -95,10 +95,8 @@ void createAdaptiveIcons(
utils.printStatus('Creating adaptive icons Android');

// Retrieve the necessary Flutter Launcher Icons configuration from the pubspec.yaml file
final String? backgroundConfig =
config.adaptiveIconBackground;
final String? foregroundImagePath =
config.adaptiveIconForeground;
final String? backgroundConfig = config.adaptiveIconBackground;
final String? foregroundImagePath = config.adaptiveIconForeground;
if (backgroundConfig == null || foregroundImagePath == null) {
throw const InvalidConfigException(errorMissingImagePath);
}
Expand Down Expand Up @@ -161,9 +159,7 @@ void createAdaptiveIconMipmapXmlFile(
) {
if (config.isCustomAndroidFile) {
File(
constants.androidAdaptiveXmlFolder(flavor) +
config.android +
'.xml',
constants.androidAdaptiveXmlFolder(flavor) + config.android + '.xml',
).create(recursive: true).then((File adaptiveIcon) {
adaptiveIcon.writeAsString(xml_template.icLauncherXml);
});
Expand Down Expand Up @@ -205,9 +201,7 @@ void _createAdaptiveBackgrounds(
// FILE LOCATED HERE: res/mipmap-anydpi/{icon-name-from-yaml-config}.xml
if (config.isCustomAndroidFile) {
File(
constants.androidAdaptiveXmlFolder(flavor) +
config.android +
'.xml',
constants.androidAdaptiveXmlFolder(flavor) + config.android + '.xml',
).create(recursive: true).then((File adaptiveIcon) {
adaptiveIcon.writeAsString(xml_template.icLauncherDrawableBackgroundXml);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import 'dart:convert';
import 'dart:io';

import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/constants.dart';
import 'package:flutter_launcher_icons/custom_exceptions.dart';
import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/utils.dart';
import 'package:image/image.dart';

Expand Down
6 changes: 3 additions & 3 deletions lib/macos/macos_icon_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class MacOSIconGenerator extends IconGenerator {
if (macOSConfig.imagePath == null && context.config.imagePath == null) {
context.logger
..verbose({
'flutter_icons.macos.image_path': macOSConfig.imagePath,
'flutter_icons.image_path': context.config.imagePath,
'flutter_launcher_icons.macos.image_path': macOSConfig.imagePath,
'flutter_launcher_icons.image_path': context.config.imagePath,
})
..error(
'Missing image_path. Either provide "flutter_icons.macos.image_path" or "flutter_icons.image_path"',
'Missing image_path. Either provide "flutter_launcher_icons.macos.image_path" or "flutter_launcher_icons.image_path"',
);

return false;
Expand Down
14 changes: 6 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import 'dart:io';
import 'package:args/args.dart';
import 'package:flutter_launcher_icons/abs/icon_generator.dart';
import 'package:flutter_launcher_icons/android.dart' as android_launcher_icons;
import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/constants.dart' as constants;
import 'package:flutter_launcher_icons/constants.dart';
import 'package:flutter_launcher_icons/custom_exceptions.dart';
import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/ios.dart' as ios_launcher_icons;
import 'package:flutter_launcher_icons/logger.dart';
import 'package:flutter_launcher_icons/macos/macos_icon_generator.dart';
import 'package:flutter_launcher_icons/macos/macos_icon_template.dart';
import 'package:flutter_launcher_icons/web/web_icon_generator.dart';
import 'package:flutter_launcher_icons/windows/windows_icon_generator.dart';
import 'package:path/path.dart' as path;
Expand Down Expand Up @@ -172,11 +171,10 @@ Config? loadConfigFileFromArgResults(
ArgResults argResults,
) {
final String prefixPath = argResults[prefixOption];
final flutterLauncherIconsConfigs =
Config.loadConfigFromPath(
argResults[fileOption],
prefixPath,
) ??
Config.loadConfigFromPubSpec(prefixPath);
final flutterLauncherIconsConfigs = Config.loadConfigFromPath(
argResults[fileOption],
prefixPath,
) ??
Config.loadConfigFromPubSpec(prefixPath);
return flutterLauncherIconsConfigs;
}
2 changes: 1 addition & 1 deletion test/all_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:test/test.dart';

import 'abs/icon_generator_test.dart' as icon_generator_test;
import 'android_test.dart' as android_test;
import 'flutter_launcher_icons_config_test.dart' as fli_config;
import 'config_test.dart' as fli_config;
import 'macos/macos_icon_generator_test.dart' as macos_icons_gen_test;
import 'macos/macos_icon_template_test.dart' as macos_template_test;
import 'main_test.dart' as main_test;
Expand Down
11 changes: 4 additions & 7 deletions test/android_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:io';

import 'package:flutter_launcher_icons/android.dart' as android;
import 'package:flutter_launcher_icons/constants.dart';
import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/constants.dart';
import 'package:test/test.dart';

// unit tests for android.dart
Expand Down Expand Up @@ -35,8 +35,7 @@ void main() {
'ios': true
};
expect(
Config.fromJson(flutterIconsConfig)
.isCustomAndroidFile,
Config.fromJson(flutterIconsConfig).isCustomAndroidFile,
isFalse,
);

Expand All @@ -46,8 +45,7 @@ void main() {
'ios': true
};
expect(
Config.fromJson(flutterIconsNewIconConfig)
.isCustomAndroidFile,
Config.fromJson(flutterIconsNewIconConfig).isCustomAndroidFile,
isTrue,
);
});
Expand All @@ -60,8 +58,7 @@ void main() {
'ios': true
};
expect(
Config.fromJson(flutterIconsNewIconConfig)
.getImagePathAndroid(),
Config.fromJson(flutterIconsNewIconConfig).getImagePathAndroid(),
equals('assets/images/icon-android.png'),
);
});
Expand Down
2 changes: 1 addition & 1 deletion test/config/test_pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dev_dependencies:
flutter_launcher_icons:
path: ../../

flutter_icons:
flutter_launcher_icons:
image_path: "assets/images/icon-710x599.png"
android: true # can specify file name here e.g. "ic_launcher"
ios: true # can specify file name here e.g. "My-Launcher-Icon"
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:flutter_launcher_icons/custom_exceptions.dart';
import 'package:flutter_launcher_icons/config/config.dart';
import 'package:flutter_launcher_icons/custom_exceptions.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d;

import './templates.dart' as templates;

void main() {
group('FlutterLauncherIconsConfig', () {
group('Config', () {
late String prefixPath;
setUpAll(() {
prefixPath = path.join(d.sandbox, 'fli_test');
Expand Down Expand Up @@ -98,8 +98,7 @@ void main() {
group('#loadConfigFromTestPubSpec', () {
test('should return valid configs', () {
const String path = 'test/config/test_pubspec.yaml';
final configs =
Config.loadConfigFromPath(path, '.');
final configs = Config.loadConfigFromPath(path, '.');
expect(configs, isNotNull);
const String imagePath = 'assets/images/icon-710x599.png';
expect(configs!.imagePath, equals(imagePath));
Expand Down Expand Up @@ -132,8 +131,7 @@ void main() {
]).create();
});
test('should return valid configs', () {
final configs =
Config.loadConfigFromPubSpec(prefixPath);
final configs = Config.loadConfigFromPubSpec(prefixPath);
expect(configs, isNotNull);
// android configs
expect(configs!.android, isTrue);
Expand Down
7 changes: 4 additions & 3 deletions test/main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ void main() {
tearDown(() {
Directory.current = currentDirectory;
});

test('default', () async {
await setCurrentDirectory('default');
await File('flutter_launcher_icons.yaml').writeAsString('''
flutter_icons:
flutter_launcher_icons:
android: true
ios: false
''');
Expand All @@ -70,7 +71,7 @@ flutter_icons:
test('default_use_pubspec', () async {
await setCurrentDirectory('pubspec_only');
await File('pubspec.yaml').writeAsString('''
flutter_icons:
flutter_launcher_icons:
android: true
ios: false
''');
Expand All @@ -88,7 +89,7 @@ flutter_icons:
test('custom', () async {
await setCurrentDirectory('custom');
await File('custom.yaml').writeAsString('''
flutter_icons:
flutter_launcher_icons:
android: true
ios: true
''');
Expand Down
12 changes: 6 additions & 6 deletions test/templates.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fliConfigTemplate = r'''
flutter_icons:
flutter_launcher_icons:
android: true
ios: true
image_path: "assets/images/icon-128x128.png"
Expand Down Expand Up @@ -28,7 +28,7 @@ flutter_icons:
const flavorFLIConfigTemplate = fliConfigTemplate;

const fliWebConfig = r'''
flutter_icons:
flutter_launcher_icons:
web:
generate: true
image_path: "app_icon.png" # filepath
Expand All @@ -39,15 +39,15 @@ flutter_icons:
''';

const fliWindowsConfig = r'''
flutter_icons:
flutter_launcher_icons:
windows:
generate: true
image_path: "app_icon.png"
icon_size: 48
''';

const invalidfliConfigTemplate = r'''
# flutter_icons
# flutter_launcher_icons
android: true
ios: true
image_path: "assets/images/icon-128x128.png"
Expand Down Expand Up @@ -103,7 +103,7 @@ flutter:
- asset: fonts/TrajanPro_Bold.ttf
weight: 700
flutter_icons:
flutter_launcher_icons:
android: true
ios: true
image_path: "assets/images/icon-128x128.png"
Expand Down Expand Up @@ -167,7 +167,7 @@ flutter:
- asset: fonts/TrajanPro_Bold.ttf
weight: 700
flutter_icons:
flutter_launcher_icons:
android: true
invalid_indented_key_key
ios: true
Expand Down

0 comments on commit 33f4188

Please sign in to comment.