Skip to content

Commit

Permalink
feature: Generate App Icons (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
defuncart authored Jan 5, 2025
1 parent 4696e6d commit d8488de
Show file tree
Hide file tree
Showing 41 changed files with 130 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Lint
run: flutter analyze
- name: Unit tests
run: flutter test
run: flutter test --exclude-tags app_store_screenshots
build-Android:
name: Build Android
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ app.*.map.json
# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

# l10n
# Local Assets
assets_dev/app_icons/android_icon_foreground.png
assets_dev/app_icons/app_icon.png
assets_dev/fonts/
assets_dev/l10n/

# FVM Version Cache
Expand Down
Binary file modified android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets_dev/app_icon/android_foreground.png
Binary file not shown.
Binary file removed assets_dev/app_icon/iOS.png
Binary file not shown.
File renamed without changes
5 changes: 5 additions & 0 deletions bin/app_icon_generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

fvm flutter test test/design_assets --update-goldens --tags app_store_screenshots

fvm dart run flutter_launcher_icons
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
app_store_screenshots:
dependency: "direct dev"
description:
path: "."
ref: main
resolved-ref: ffbbccf68e133cc82469dc9ad9bf42de2bf0b13f
url: "https://github.com/defuncart/app_store_screenshots"
source: git
version: "0.0.1"
arb_generator:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -105,6 +114,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.8"
device_frame:
dependency: transitive
description:
name: device_frame
sha256: d031a06f5d6f4750009672db98a5aa1536aa4a231713852469ce394779a23d75
url: "https://pub.dev"
source: hosted
version: "1.2.0"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -174,6 +191,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
freezed_annotation:
dependency: transitive
description:
name: freezed_annotation
sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
url: "https://pub.dev"
source: hosted
version: "2.4.4"
get_it:
dependency: "direct main"
description:
Expand All @@ -182,6 +207,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.0.3"
golden_toolkit:
dependency: transitive
description:
name: golden_toolkit
sha256: "8f74adab33154fe7b731395782797021f97d2edc52f7bfb85ff4f1b5c4a215f0"
url: "https://pub.dev"
source: hosted
version: "0.15.0"
hive:
dependency: "direct main"
description:
Expand Down
18 changes: 11 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ dev_dependencies:
arb_generator:
flutter_lints:
flutter_launcher_icons:
app_store_screenshots:
git:
url: https://github.com/defuncart/app_store_screenshots
ref: main

flutter:
uses-material-design: true
Expand All @@ -48,15 +52,15 @@ arb_generator:
flutter_icons:
android: true
ios: true
image_path_android: "assets_dev/app_icon/android_old.png"
image_path_ios: "assets_dev/app_icon/ios.png"
image_path: "assets_dev/app_icons/app_icon.png"
image_path_android: "assets_dev/app_icons/android_old.png"
adaptive_icon_background: "#E2E3D1"
adaptive_icon_foreground: "assets_dev/app_icon/android_foreground.png"
adaptive_icon_foreground: "assets_dev/app_icons/android_icon_foreground.png"
web:
generate: true
image_path: "assets_dev/app_icon/ios.png"
background_color: "#e2e3d1"
theme_color: "#e2e3d1"
image_path: "assets_dev/app_icons/app_icon.png"
background_color: "#E2E3D1"
theme_color: "#E2E3D1"
macos:
generate: true
image_path: "assets_dev/app_icon/ios.png"
image_path: "assets_dev/app_icons/app_icon.png"
74 changes: 74 additions & 0 deletions test/design_assets/generate_app_icons_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import 'package:app_store_screenshots/app_store_screenshots.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shogi_proverbs/configs/app_themes.dart';

const _fontName = 'NotoSans';

void main() {
setUp(() async {
await loadFont(
path: 'assets_dev/fonts/NotoSansJP-RegularLite.otf',
name: _fontName,
);
});

generateAppIcon(
onBuildIcon: (size) => Theme(
data: AppThemes.light,
child: AppIcon(
size: size,
),
),
);

generateAppIconAndroidForeground(
onBuildIcon: (size) => Theme(
data: AppThemes.light,
child: AppIcon(
size: size,
hasTransparentBackground: true,
),
),
);
}

class AppIcon extends StatelessWidget {
const AppIcon({
super.key,
this.size = 512,
this.hasTransparentBackground = false,
});

final double size;
final bool hasTransparentBackground;

@override
Widget build(BuildContext context) {
final fontSize = size * 0.6836;
final textStyle = TextStyle(
fontSize: fontSize,
color: Theme.of(context).colorScheme.primary,
fontFamily: _fontName,
height: 1,
);

return Container(
width: size,
height: size,
color: hasTransparentBackground ? Colors.transparent : Theme.of(context).scaffoldBackgroundColor,
child: Stack(
alignment: Alignment.topCenter,
children: [
Positioned(
top: size * 0.12, // required in order to 'correctly' center the text
child: Text(
'王',
style: textStyle,
),
),
],
),
);
}
}
Binary file modified web/favicon.png
Binary file modified web/icons/Icon-192.png
Binary file modified web/icons/Icon-512.png
Binary file modified web/icons/Icon-maskable-192.png
Binary file modified web/icons/Icon-maskable-512.png
4 changes: 2 additions & 2 deletions web/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"short_name": "Shogi Proverbs",
"start_url": ".",
"display": "standalone",
"background_color": "#e2e3d1",
"theme_color": "#e2e3d1",
"background_color": "#E2E3D1",
"theme_color": "#E2E3D1",
"description": "A mobile application containing various Shogi proverbs.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
Expand Down

0 comments on commit d8488de

Please sign in to comment.