layrz_ui_extensions 1.0.1
layrz_ui_extensions: ^1.0.1 copied to clipboard
Adapters and extensions bridging layrz_sdk and other Layrz packages into layrz_ui, including i18n bindings and model conversions.
Changelog #
1.0.1 #
- Added the
AvatarInput↔LayrzAvatarSourcebridge:AvatarInput?.toLayrzUi()(LayrzAvatarInputConverterX), a write-model forward converter mirroringAvatar.toLayrzUi(), andLayrzAvatarSource?.toAvatarInput()(LayrzAvatarSourceToInputX), the reverse converter for turning aLayrzDynamicAvatarInputselection back into theAvatarInputpayload the API expects.
1.0.0 #
- Stable release!
1.0.0-rc.1 #
- Upgraded go_router to ^18.0.1.
1.0.0-prerelease.3 #
- The
Inter,Noto Sans,Open SansandRobotofonts now register a browser@font-faceon web viaregisterOnWeb(), so DOM-rendered text uses the intended font instead of falling back to a generic sans-serif. Previouslyload()only registered them with the Flutter engine canvas. - Added
LayrzOrm, a validation-error helper: a static error store plus aBuildContextextension.setErrors(Map?)(null clears),getErrors(key)→List<String>,hasErrors(key),hasGroupedErrors(keys)(true if any key has errors), andclearErrors()(clears all stored errors, equivalent tosetErrors(null)). Error codes translate viaLayrzI18nresolved from context — context-only, independent oflayrz_ui's own localization.
1.0.0-prerelease.2 #
- Added the static
LayrzUiI18n.delegate(engine)factory, which returns aLocalizationsDelegateready to drop intoLayrzApp.localizationsDelegateswithout constructingLayrzUiI18nDelegateyourself, mirroring the newLayrzUiL10n.delegateaccessor. layrz_uiraised to^1.0.0-prerelease.3— the version that introduces theLayrzUiL10n.delegateaccessor this factory aligns with.
1.0.0-prerelease.1 #
- Preparation of stable release of
layrz_ui
0.0.4 #
Changed #
-
layrz_uiraised to^0.0.26— the version that introduces theMdiRemapIcon-basedLayrzAvatarIconmodel. -
Avatar.toLayrzUi()(LayrzAvatarSourceConverterX.toLayrzUi) updated for the new model — the icon case now passes the SDKAvatar'sMdiRemapIconstraight through toLayrzAvatarIcon, sincelayrz_sdk'sAvatar.iconis already anMdiRemapIconvialayrz_sdk ^4.4.6. Avatar conversion tests updated to read the icon's code point throughMdiRemapIcon.iconData. -
layrz_sdkraised to^4.4.6. -
flutter_material_design_iconsmoved to regular dependencies, andflutter_mdi_remap: ^1.0.0added — needed for theMdiRemapIcontype shared withlayrz_uiandlayrz_sdk.
0.0.3 #
Added #
- Fonts! We added support for
Inter,Noto Sans,Open SansandRobotofonts forlayrz_uithrough our CDNs. - Extended
LayrzUiI18nto include new keys required onlayrz_ui 0.0.13
0.0.2 #
First release under the layrz_ui_extensions name, and the scope widens past i18n.
Added #
-
Avatar.toLayrzUi()— an extension onlayrz_sdk'sAvatar?converting it tolayrz_ui'sLayrzAvatarSourcesealed hierarchy (LayrzAvatarUrl,LayrzAvatarBase64,LayrzAvatarIcon,LayrzAvatarEmoji). Declared on the nullable type, so a null avatar,AvatarType.none, and a type/payload mismatch all yieldnull— which is exactly howLayrzAvatartriggers its initials fallback. Callers writeLayrzAvatar(source: entity.avatar.toLayrzUi())with no null check. -
layrz_sdk: ^4.4.3as a dependency, required by the avatar conversion.
Changed #
-
layrz_uiraised to^0.0.9— the version that introducedLayrzUiL10n. -
lib/restructured by concern. The i18n binding moved tolib/src/i18n/, and the avatar conversion lives inlib/src/sdk/. The barrellib/layrz_ui_extensions.dartexports both. Class names are unchanged —LayrzUiI18n,LayrzUiI18nDelegateand the 17 namespace mixins still describe the i18n concern; only the package grew broader.
Design Notes #
-
This package is why
layrz_uineeds nolayrz_sdkdependency.layrz_uidefines its ownLayrzAvatarSource; this package supplies the bridge. Apps holding SDK models convert at the boundary, and apps that do not never inherit the SDK's dependency tree. -
Type and payload can disagree, and that is handled. The SDK's
Avatarcarries atypealongside four independently-nullable payload fields, soAvatar(type: AvatarType.url, url: null)is representable. The conversion returnsnullin that case rather than throwing, matching howlayrz_uipreviously rendered such avatars as initials. Empty strings are treated the same as missing. -
layrz_iconsstays on 1.x.layrz_sdk 4.4.3pinslayrz_icons: ^1.1.1, and this package depends on both it andlayrz_ui, solayrz_uideliberately holds the same 1.x constraint. Raising either side alone would make this package unresolvable.
0.0.1 #
Initial release. An adapter binding layrz_ui's LayrzUiL10n contract to the layrz_i18n translation engine.
Added #
-
LayrzUiI18n— adapter implementingLayrzUiL10nby delegating all 133 keys throughLayrzI18n.t()andLayrzI18n.tc(). Covers 17 namespaces: actions, about, calendar, date-time pickers, dual list, dynamic avatar, editor, files, helpers, map, notifications, password, required fields, select, table, taskbar, and weekdays. All keys are derived from the contract member names with a dotted prefix pattern (e.g.,actionCancel→'actions.cancel'). -
LayrzUiI18nDelegate— aLocalizationsDelegate<LayrzUiL10n>that loadsLayrzUiI18ninstances. Typed over the contract base classLayrzUiL10n(not the subclass) to ensureLocalizations.of<LayrzUiL10n>()correctly resolves this delegate. Must be registered before the defaultLayrzUiL10nDelegateinLayrzApp.localizationsDelegatesto take precedence. -
Complete test coverage mirroring the adapter implementation across all 17 namespaces.
Design Notes #
-
Translation keys are derived, not verified. The 133 dotted keys are generated from the contract member names and have not been verified against real translation data in the
layrz_i18nengine. The implementation is correct; the key naming convention is derived and should be validated during integration. -
Unresolved keys fall back gracefully. Any key not present in the translation engine is handled by
layrz_i18n's fallback behavior. Missing keys will not break rendering; partial translation is fully supported. -
English defaults are inherited. When a key is not overridden,
LayrzUiI18ninherits the English default fromLayrzUiL10n. This allows the adapter to remain compatible with new keys added tolayrz_uiwithout requiring immediate translation updates. -
Pluralization support. Eight duration-related keys use
tc(String key, int? val)for singular/plural selection. These keys expect' | '-separated singular and plural forms in the translation engine (e.g.,'1 day | %count% days'). Thetc()call passesval = 1for singular,val = countfor plural, and the engine selects the appropriate form. -
No dependency between layrz_ui and layrz_i18n.
layrz_uideclares no dependency onlayrz_i18n. This adapter exists to bridge the two, enabling both to remain independently published and versioned. The decoupling allowslayrz_uito be used standalone in apps that have no i18n requirement.
Installation #
Add both layrz_ui and layrz_ui_extensions to your pubspec.yaml:
dependencies:
layrz_ui: ^0.0.9
layrz_ui_extensions: ^0.0.2
layrz_ui_extensions requires layrz_ui >= 0.0.9 because that is where LayrzUiL10n was introduced. Both packages version independently.
Usage #
Register the delegate and initialize the engine:
import 'package:layrz_i18n/layrz_i18n.dart';
import 'package:layrz_ui/layrz_ui.dart';
import 'package:layrz_ui_extensions/layrz_ui_extensions.dart';
void main() async {
final i18n = LayrzI18n(languages: [...]);
await i18n.load();
runApp(MyApp(i18n: i18n));
}
class MyApp extends StatelessWidget {
final LayrzI18n i18n;
const MyApp({required this.i18n});
@override
Widget build(BuildContext context) {
return LayrzApp(
title: 'My App',
theme: LayrzThemeData.light(),
localizationsDelegates: [
LayrzUiI18nDelegate(i18n), // Your translations
const LayrzUiL10nDelegate(), // English fallback
],
home: const HomePage(),
);
}
}
Once registered, every layrz_ui component reading context.l10n automatically picks up your translations with no additional wiring.
License #
This project is licensed under the MIT License — see the LICENSE file for details.