-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Flutterando/lucid_validation
- Loading branch information
Showing
19 changed files
with
383 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 1.0.0 | ||
|
||
* Production release | ||
|
||
## 0.0.7 | ||
|
||
* Added `when` and `setValidator` | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:lucid_validation/lucid_validation.dart'; | ||
|
||
class CustomLanguageManager extends LanguageManager { | ||
CustomLanguageManager() { | ||
addTranslation(Culture('pt', 'BR'), 'passwordEqualTo', "'{PropertyName}' deve ser igual."); | ||
addTranslation(Culture('pt'), 'passwordEqualTo', "'{PropertyName}' deve ser igual."); | ||
addTranslation(Culture('en', 'US'), 'passwordEqualTo', "'{PropertyName}' must be equal."); | ||
addTranslation(Culture('en'), 'passwordEqualTo', "'{PropertyName}' must be equal."); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,74 @@ | ||
import 'package:example/presentation/login_page/login_page.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_localizations/flutter_localizations.dart'; | ||
import 'package:lucid_validation/lucid_validation.dart'; | ||
|
||
import 'domain/validations/language_manager.dart'; | ||
|
||
void main() { | ||
LucidValidation.global.languageManager = CustomLanguageManager(); | ||
|
||
runApp(const MyApp()); | ||
} | ||
|
||
final globalLocale = ValueNotifier(Locale('en')); | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Flutter Demo', | ||
theme: ThemeData( | ||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), | ||
useMaterial3: true, | ||
), | ||
home: const LoginPage(), | ||
return ValueListenableBuilder<Locale>( | ||
valueListenable: globalLocale, | ||
builder: (context, value, child) { | ||
return MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
title: 'Flutter Demo', | ||
locale: value, | ||
supportedLocales: const [ | ||
Locale('en', 'US'), | ||
Locale('pt', 'BR'), | ||
], | ||
localizationsDelegates: [ | ||
GlobalMaterialLocalizations.delegate, | ||
GlobalWidgetsLocalizations.delegate, | ||
GlobalCupertinoLocalizations.delegate, | ||
LucidLocalizationDelegate.delegate, | ||
], | ||
theme: ThemeData( | ||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), | ||
useMaterial3: true, | ||
), | ||
home: const LoginPage(), | ||
); | ||
}, | ||
); | ||
} | ||
} | ||
|
||
class LucidLocalizationDelegate extends LocalizationsDelegate<Culture> { | ||
const LucidLocalizationDelegate(); | ||
|
||
static final delegate = LucidLocalizationDelegate(); | ||
|
||
@override | ||
bool isSupported(Locale locale) { | ||
return LucidValidation.global.languageManager.isSupported( | ||
locale.languageCode, | ||
locale.countryCode, | ||
); | ||
} | ||
|
||
@override | ||
Future<Culture> load(Locale locale) async { | ||
print(locale); | ||
final culture = Culture(locale.languageCode, locale.countryCode ?? ''); | ||
LucidValidation.global.culture = culture; | ||
return culture; | ||
} | ||
|
||
@override | ||
bool shouldReload(LocalizationsDelegate<Culture> old) { | ||
return true; | ||
} | ||
} |
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
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
Oops, something went wrong.