Skip to content

Commit

Permalink
CI: Action - Code Analysis (fluttercandies#559)
Browse files Browse the repository at this point in the history
Provides checks for dart code analysis.
  • Loading branch information
AmosHuKe authored Mar 2, 2024
1 parent 44ad870 commit b714de7
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Publish
uses: k-paxian/dart-package-publisher@master
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publishable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Publish dry-run with packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: k-paxian/dart-package-publisher@master
with:
credentialJson: 'MockCredentialJson'
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/runnable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
branches:
- main
Expand All @@ -18,8 +20,8 @@ jobs:
matrix:
os: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
Expand All @@ -32,8 +34,10 @@ jobs:
flutter --version
- name: Prepare dependencies
run: flutter pub get
- name: Analyse the repo
run: flutter analyze lib example/lib
- name: Check Dart code formatting
run: dart format . -o none --set-exit-if-changed
- name: Analyze Dart code
run: flutter analyze .
- name: Run tests
run: flutter test
- name: Generate docs
Expand All @@ -46,8 +50,8 @@ jobs:
name: Test iOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
Expand All @@ -64,8 +68,8 @@ jobs:
name: Test Android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ that can be found in the LICENSE file. -->
> [!IMPORTANT]
> See the [Migration Guide](guides/migration_guide.md) for the details of breaking changes between versions.
## 9.0.1

### Improvements

- Improve code formatting.

## 9.0.0

### Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion example/l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
arb-dir: lib/l10n
# format: true
format: true
output-class: AppLocalizations
output-dir: lib/l10n/gen
output-localization-file: app_localizations.dart
Expand Down
32 changes: 18 additions & 14 deletions example/lib/l10n/gen/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ import 'app_localizations_zh.dart';
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());

final String localeName;

static AppLocalizations? of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}

static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();

/// A list of this localizations delegate along with the default localizations
/// delegates.
Expand All @@ -80,7 +82,8 @@ abstract class AppLocalizations {
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
Expand Down Expand Up @@ -412,7 +415,8 @@ abstract class AppLocalizations {
String get customPickerInstagramLayoutDescription;
}

class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();

@override
Expand All @@ -421,25 +425,25 @@ class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations>
}

@override
bool isSupported(Locale locale) => <String>['en', 'zh'].contains(locale.languageCode);
bool isSupported(Locale locale) =>
<String>['en', 'zh'].contains(locale.languageCode);

@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}

AppLocalizations lookupAppLocalizations(Locale locale) {


// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en': return AppLocalizationsEn();
case 'zh': return AppLocalizationsZh();
case 'en':
return AppLocalizationsEn();
case 'zh':
return AppLocalizationsZh();
}

throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.'
);
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
}
57 changes: 38 additions & 19 deletions example/lib/l10n/gen/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get pickMethodVideoName => 'Video picker';

@override
String get pickMethodVideoDescription => 'Only pick video from device. (Includes Live Photos on iOS and macOS.)';
String get pickMethodVideoDescription =>
'Only pick video from device. (Includes Live Photos on iOS and macOS.)';

@override
String get pickMethodAudioName => 'Audio picker';
Expand All @@ -54,13 +55,15 @@ class AppLocalizationsEn extends AppLocalizations {
String get pickMethodCameraName => 'Pick from camera';

@override
String get pickMethodCameraDescription => 'Allow to pick an asset through camera.';
String get pickMethodCameraDescription =>
'Allow to pick an asset through camera.';

@override
String get pickMethodCameraAndStayName => 'Pick from camera and stay';

@override
String get pickMethodCameraAndStayDescription => 'Take a photo or video with the camera picker, select the result and stay in the entities list.';
String get pickMethodCameraAndStayDescription =>
'Take a photo or video with the camera picker, select the result and stay in the entities list.';

@override
String get pickMethodCommonName => 'Common picker';
Expand All @@ -72,49 +75,58 @@ class AppLocalizationsEn extends AppLocalizations {
String get pickMethodThreeItemsGridName => '3 items grid';

@override
String get pickMethodThreeItemsGridDescription => 'Picker will served as 3 items on cross axis. (pageSize must be a multiple of the gridCount)';
String get pickMethodThreeItemsGridDescription =>
'Picker will served as 3 items on cross axis. (pageSize must be a multiple of the gridCount)';

@override
String get pickMethodCustomFilterOptionsName => 'Custom filter options';

@override
String get pickMethodCustomFilterOptionsDescription => 'Add filter options for the picker.';
String get pickMethodCustomFilterOptionsDescription =>
'Add filter options for the picker.';

@override
String get pickMethodPrependItemName => 'Prepend special item';

@override
String get pickMethodPrependItemDescription => 'A special item will prepend to the assets grid.';
String get pickMethodPrependItemDescription =>
'A special item will prepend to the assets grid.';

@override
String get pickMethodNoPreviewName => 'No preview';

@override
String get pickMethodNoPreviewDescription => 'You cannot preview assets during the picking, the behavior is like the WhatsApp/MegaTok pattern.';
String get pickMethodNoPreviewDescription =>
'You cannot preview assets during the picking, the behavior is like the WhatsApp/MegaTok pattern.';

@override
String get pickMethodKeepScrollOffsetName => 'Keep scroll offset';

@override
String get pickMethodKeepScrollOffsetDescription => 'Pick assets from same scroll position.';
String get pickMethodKeepScrollOffsetDescription =>
'Pick assets from same scroll position.';

@override
String get pickMethodChangeLanguagesName => 'Change Languages';

@override
String get pickMethodChangeLanguagesDescription => 'Pass AssetPickerTextDelegate to change between languages (e.g. EnglishAssetPickerTextDelegate).';
String get pickMethodChangeLanguagesDescription =>
'Pass AssetPickerTextDelegate to change between languages (e.g. EnglishAssetPickerTextDelegate).';

@override
String get pickMethodPreventGIFPickedName => 'Prevent GIF being picked';

@override
String get pickMethodPreventGIFPickedDescription => 'Use selectPredicate to banned GIF picking when tapped.';
String get pickMethodPreventGIFPickedDescription =>
'Use selectPredicate to banned GIF picking when tapped.';

@override
String get pickMethodCustomizableThemeName => 'Customizable theme (ThemeData)';
String get pickMethodCustomizableThemeName =>
'Customizable theme (ThemeData)';

@override
String get pickMethodCustomizableThemeDescription => 'Picking assets with the light theme or with a different color.';
String get pickMethodCustomizableThemeDescription =>
'Picking assets with the light theme or with a different color.';

@override
String get pickMethodPathNameBuilderName => 'Path name builder';
Expand All @@ -126,16 +138,20 @@ class AppLocalizationsEn extends AppLocalizations {
String get pickMethodWeChatMomentName => 'WeChat Moment';

@override
String get pickMethodWeChatMomentDescription => 'Pick assets with images or only 1 video.';
String get pickMethodWeChatMomentDescription =>
'Pick assets with images or only 1 video.';

@override
String get pickMethodCustomImagePreviewThumbSizeName => 'Custom image preview thumb size';
String get pickMethodCustomImagePreviewThumbSizeName =>
'Custom image preview thumb size';

@override
String get pickMethodCustomImagePreviewThumbSizeDescription => 'You can reduce the thumb size to get faster load speed.';
String get pickMethodCustomImagePreviewThumbSizeDescription =>
'You can reduce the thumb size to get faster load speed.';

@override
String get customPickerNotice => 'This page contains customized pickers with different asset types, different UI layouts, or some use case for specific apps. Contribute to add your custom picker are welcomed.\nPickers in this page are located at the lib/customs/pickers folder.';
String get customPickerNotice =>
'This page contains customized pickers with different asset types, different UI layouts, or some use case for specific apps. Contribute to add your custom picker are welcomed.\nPickers in this page are located at the lib/customs/pickers folder.';

@override
String get customPickerCallThePickerButton => '🎁 Call the Picker';
Expand All @@ -144,13 +160,15 @@ class AppLocalizationsEn extends AppLocalizations {
String get customPickerDirectoryAndFileName => 'Directory+File picker';

@override
String get customPickerDirectoryAndFileDescription => 'This is a custom picker built for `File`.\nBy browsing this picker, we want you to know that you can build your own picker components using the entity\'s type you desired.\n\nIn this page, picker will grab files from `getApplicationDocumentsDirectory`, then check whether it contains images. Put files into the path to see how this custom picker work.';
String get customPickerDirectoryAndFileDescription =>
'This is a custom picker built for `File`.\nBy browsing this picker, we want you to know that you can build your own picker components using the entity\'s type you desired.\n\nIn this page, picker will grab files from `getApplicationDocumentsDirectory`, then check whether it contains images. Put files into the path to see how this custom picker work.';

@override
String get customPickerMultiTabName => 'Multi tab picker';

@override
String get customPickerMultiTabDescription => 'The picker contains multiple tab with different types of assets for the picking at the same time.';
String get customPickerMultiTabDescription =>
'The picker contains multiple tab with different types of assets for the picking at the same time.';

@override
String get customPickerMultiTabTab1 => 'All';
Expand All @@ -165,5 +183,6 @@ class AppLocalizationsEn extends AppLocalizations {
String get customPickerInstagramLayoutName => 'Instagram layout picker';

@override
String get customPickerInstagramLayoutDescription => 'The picker reproduces Instagram layout with preview and scroll animations. It\'s also published as the package insta_assets_picker.';
String get customPickerInstagramLayoutDescription =>
'The picker reproduces Instagram layout with preview and scroll animations. It\'s also published as the package insta_assets_picker.';
}
27 changes: 18 additions & 9 deletions example/lib/l10n/gen/app_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class AppLocalizationsZh extends AppLocalizations {
String get pickMethodThreeItemsGridName => '横向 3 格';

@override
String get pickMethodThreeItemsGridDescription => '选择器每行为 3 格。(pageSize 必须为 gridCount 的倍数)';
String get pickMethodThreeItemsGridDescription =>
'选择器每行为 3 格。(pageSize 必须为 gridCount 的倍数)';

@override
String get pickMethodCustomFilterOptionsName => '自定义过滤条件';
Expand All @@ -90,7 +91,8 @@ class AppLocalizationsZh extends AppLocalizations {
String get pickMethodNoPreviewName => '禁止预览';

@override
String get pickMethodNoPreviewDescription => '无法预览选择的资源,与 WhatsApp/MegaTok 的行为类似。';
String get pickMethodNoPreviewDescription =>
'无法预览选择的资源,与 WhatsApp/MegaTok 的行为类似。';

@override
String get pickMethodKeepScrollOffsetName => '保持滚动位置';
Expand All @@ -102,13 +104,15 @@ class AppLocalizationsZh extends AppLocalizations {
String get pickMethodChangeLanguagesName => '更改语言';

@override
String get pickMethodChangeLanguagesDescription => '传入 AssetPickerTextDelegate 手动更改选择器的语言(例如 EnglishAssetPickerTextDelegate)。';
String get pickMethodChangeLanguagesDescription =>
'传入 AssetPickerTextDelegate 手动更改选择器的语言(例如 EnglishAssetPickerTextDelegate)。';

@override
String get pickMethodPreventGIFPickedName => '禁止选择 GIF 图片';

@override
String get pickMethodPreventGIFPickedDescription => '通过 selectPredicate 来禁止 GIF 图片在点击时被选择。';
String get pickMethodPreventGIFPickedDescription =>
'通过 selectPredicate 来禁止 GIF 图片在点击时被选择。';

@override
String get pickMethodCustomizableThemeName => '自定义主题 (ThemeData)';
Expand All @@ -132,10 +136,12 @@ class AppLocalizationsZh extends AppLocalizations {
String get pickMethodCustomImagePreviewThumbSizeName => '自定义图片预览的缩略图大小';

@override
String get pickMethodCustomImagePreviewThumbSizeDescription => '通过降低缩略图的质量来获得更快的加载速度。';
String get pickMethodCustomImagePreviewThumbSizeDescription =>
'通过降低缩略图的质量来获得更快的加载速度。';

@override
String get customPickerNotice => '本页面包含了多种方式、不同界面和特定应用的自定义选择器。欢迎贡献添加你自定义的选择器。\n该页面的所有选择器的代码位于 lib/customs/pickers 目录。';
String get customPickerNotice =>
'本页面包含了多种方式、不同界面和特定应用的自定义选择器。欢迎贡献添加你自定义的选择器。\n该页面的所有选择器的代码位于 lib/customs/pickers 目录。';

@override
String get customPickerCallThePickerButton => '🎁 开始选择资源';
Expand All @@ -144,13 +150,15 @@ class AppLocalizationsZh extends AppLocalizations {
String get customPickerDirectoryAndFileName => 'Directory+File 选择器';

@override
String get customPickerDirectoryAndFileDescription => '为 `File` 构建的自定义选择器。\n通过阅读该选择器的源码,你可以学习如何完全以你自定义的资源类型来构建并选择器的界面。\n\n该选择器会从 `getApplicationDocumentsDirectory` 目录获取资源,然后检查它是否包含图片。你需要将图片放在该目录来查看选择器的效果。';
String get customPickerDirectoryAndFileDescription =>
'为 `File` 构建的自定义选择器。\n通过阅读该选择器的源码,你可以学习如何完全以你自定义的资源类型来构建并选择器的界面。\n\n该选择器会从 `getApplicationDocumentsDirectory` 目录获取资源,然后检查它是否包含图片。你需要将图片放在该目录来查看选择器的效果。';

@override
String get customPickerMultiTabName => '多 Tab 选择器';

@override
String get customPickerMultiTabDescription => '该选择器会以多 Tab 的形式同时展示多种资源类型的选择器。';
String get customPickerMultiTabDescription =>
'该选择器会以多 Tab 的形式同时展示多种资源类型的选择器。';

@override
String get customPickerMultiTabTab1 => '全部';
Expand All @@ -165,5 +173,6 @@ class AppLocalizationsZh extends AppLocalizations {
String get customPickerInstagramLayoutName => 'Instagram 布局的选择器';

@override
String get customPickerInstagramLayoutDescription => '该选择器以 Instagram 的布局模式构建,在选择时可以同时预览。其已发布为单独的 package:insta_assets_picker。';
String get customPickerInstagramLayoutDescription =>
'该选择器以 Instagram 的布局模式构建,在选择时可以同时预览。其已发布为单独的 package:insta_assets_picker。';
}
1 change: 0 additions & 1 deletion lib/src/delegates/asset_picker_text_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1127,4 +1127,3 @@ class KoreanAssetPickerTextDelegate extends AssetPickerTextDelegate {
@override
String get sUnitAssetCountLabel => '개';
}

Loading

0 comments on commit b714de7

Please sign in to comment.