Skip to content

Commit

Permalink
Merge pull request #20 from naaando/54-melhoria-na-interface
Browse files Browse the repository at this point in the history
54  - melhoria na interface
  • Loading branch information
naaando authored Jan 7, 2024
2 parents 23873bb + 8a091a5 commit df35b65
Show file tree
Hide file tree
Showing 23 changed files with 1,327 additions and 121 deletions.
11 changes: 11 additions & 0 deletions pets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

# Atualizando Traduções

Para atualizar as traduções do seu aplicativo Flutter, siga os passos abaixo:

1. Adicione o novo texto no arquivo de localização (geralmente `lib/l10n/app_en.arb` para inglês).
2. Traduza o texto para os idiomas suportados adicionando entradas correspondentes nos respectivos arquivos de localização (como `lib/l10n/app_pt.arb` para português).
3. Execute o comando `flutter gen-l10n` no terminal para gerar os arquivos de classe de localização.
4. Use as classes geradas para exibir texto traduzido em seu aplicativo.

Lembre-se de que você precisa ter a internacionalização configurada em seu projeto Flutter para usar esse recurso. Se você ainda não configurou, consulte a [documentação de internacionalização do Flutter](https://flutter.dev/docs/development/accessibility-and-localization/internationalization).
1,020 changes: 1,020 additions & 0 deletions pets/assets/images/3778546.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion pets/l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-localization-file: app_localizations.dart
untranslated-messages-file: untranslated_messages.json
11 changes: 0 additions & 11 deletions pets/lib/components/lista_pets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ class ListaPets extends HookConsumerWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 12),
child: Text(
t(context).dashboardMyPets,
textAlign: TextAlign.start,
style: theme.textTheme.titleLarge!.copyWith(
color: theme.colorScheme.onBackground,
),
),
),
const SizedBox(height: 8),
Container(
padding: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
Expand Down
8 changes: 5 additions & 3 deletions pets/lib/components/pet_avatar.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fast_cached_network_image/fast_cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:pets/magic_colors.dart';
import 'package:pets/models/pet.dart';

class PetAvatar extends StatelessWidget {
Expand Down Expand Up @@ -28,12 +29,13 @@ class PetAvatar extends StatelessWidget {

@override
Widget build(BuildContext context) {
final backgroundColor = Theme.of(context).colorScheme.primary;
final iconColor = Theme.of(context).colorScheme.primaryContainer;
final colorScheme = Theme.of(context).colorScheme;
final backgroundColor = colorScheme.onPrimaryContainer;

final iconColor = magicColors(colorScheme.brightness);

return CircleAvatar(
radius: size,
foregroundColor: Colors.black,
backgroundColor: backgroundColor,
foregroundImage: image,
child: Icon(
Expand Down
6 changes: 4 additions & 2 deletions pets/lib/components/pet_square_avatar.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fast_cached_network_image/fast_cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:pets/magic_colors.dart';
import 'package:pets/models/pet.dart';

class PetSquareAvatar extends StatelessWidget {
Expand Down Expand Up @@ -28,8 +29,9 @@ class PetSquareAvatar extends StatelessWidget {

@override
Widget build(BuildContext context) {
final backgroundColor = Theme.of(context).colorScheme.onPrimaryContainer;
final iconColor = Theme.of(context).colorScheme.onPrimary;
final colorScheme = Theme.of(context).colorScheme;
final backgroundColor = colorScheme.onPrimaryContainer;
final iconColor = magicColors(colorScheme.brightness);
final placeholder = Container(
width: size! * 2,
height: size! * 2,
Expand Down
31 changes: 22 additions & 9 deletions pets/lib/components/placeholder_ocorridos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,37 @@ class PlaceholderOcorridos extends HookWidget {

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = Theme.of(context).colorScheme;

final textColor = colorScheme.brightness == Brightness.light
? colorScheme.primaryContainer
: colorScheme.onBackground;

final backgroundColor = colorScheme.brightness == Brightness.light
? colorScheme.onPrimaryContainer
: colorScheme.primaryContainer;

return Stack(
clipBehavior: Clip.none,
children: [
Column(
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
padding: const EdgeInsets.only(
top: 8,
left: 8,
right: 8,
bottom: 30,
),
alignment: Alignment.center,
decoration: BoxDecoration(
color: theme.colorScheme.surfaceVariant,
color: backgroundColor,
borderRadius: BorderRadius.circular(8),
),
child: Text.rich(
TextSpan(children: [
TextSpan(
text: t(context).placeholderTimeline1,
style: Theme.of(context).textTheme.bodyMedium,
),
TextSpan(
children: [
Expand All @@ -36,9 +48,8 @@ class PlaceholderOcorridos extends HookWidget {
),
TextSpan(
text: t(context).placeholderTimeline3,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onPrimaryContainer,
),
),
TextSpan(
Expand All @@ -53,9 +64,8 @@ class PlaceholderOcorridos extends HookWidget {
),
TextSpan(
text: t(context).placeholderTimeline5,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onPrimaryContainer,
),
),
TextSpan(
Expand All @@ -64,7 +74,10 @@ class PlaceholderOcorridos extends HookWidget {
],
)
]),
style: Theme.of(context).textTheme.bodyMedium,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: textColor),
),
),
const SizedBox(height: 22),
Expand Down
32 changes: 23 additions & 9 deletions pets/lib/components/placeholder_proximos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,30 @@ class PlaceholderProximos extends HookWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = Theme.of(context).colorScheme;

final textColor = colorScheme.brightness == Brightness.light
? colorScheme.primaryContainer
: colorScheme.onBackground;

final backgroundColor = colorScheme.brightness == Brightness.light
? colorScheme.onPrimaryContainer
: colorScheme.primaryContainer;

return Stack(
clipBehavior: Clip.none,
children: [
Column(children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
padding: const EdgeInsets.only(
top: 8,
left: 8,
right: 8,
bottom: 30,
),
alignment: Alignment.center,
decoration: BoxDecoration(
color: theme.colorScheme.surfaceVariant,
color: backgroundColor,
borderRadius: BorderRadius.circular(8),
),
child: Text.rich(
Expand All @@ -32,9 +46,8 @@ class PlaceholderProximos extends HookWidget {
),
TextSpan(
text: t(context).placeholderProximos2,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onPrimaryContainer,
),
),
TextSpan(
Expand All @@ -49,26 +62,27 @@ class PlaceholderProximos extends HookWidget {
),
TextSpan(
text: t(context).placeholderProximos5,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onPrimaryContainer,
),
),
TextSpan(
text: t(context).placeholderProximos6,
),
TextSpan(
text: t(context).placeholderProximos7,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onPrimaryContainer,
),
),
],
)
],
),
style: Theme.of(context).textTheme.bodyMedium,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(color: textColor),
),
),
const SizedBox(
Expand Down
106 changes: 61 additions & 45 deletions pets/lib/components/small_native_ad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

class SmallNativeAd extends StatefulWidget {
const SmallNativeAd({super.key});
ColorScheme scheme;

SmallNativeAd({super.key, required this.scheme});

@override
SmallNativeAdState createState() => SmallNativeAdState();
Expand All @@ -22,7 +24,56 @@ class SmallNativeAdState extends State<SmallNativeAd> {
void initState() {
super.initState();

_loadAd();
final naviteListener = NativeAdListener(
onAdLoaded: (ad) {
// ignore: avoid_print
print('$NativeAd loaded.');
setState(() {
_nativeAdIsLoaded = true;
});
},
onAdFailedToLoad: (ad, error) {
// ignore: avoid_print
print('$NativeAd failedToLoad: $error');
ad.dispose();
},
onAdClicked: (ad) {},
onAdImpression: (ad) {},
onAdClosed: (ad) {},
onAdOpened: (ad) {},
onAdWillDismissScreen: (ad) {},
onPaidEvent: (ad, valueMicros, precision, currencyCode) {},
);

final nativeTemplateStyle = NativeTemplateStyle(
templateType: TemplateType.small,
mainBackgroundColor: widget.scheme.background,
callToActionTextStyle: NativeTemplateTextStyle(
textColor: widget.scheme.surface,
style: NativeTemplateFontStyle.bold,
size: 16.0,
),
primaryTextStyle: NativeTemplateTextStyle(
textColor: widget.scheme.primary,
style: NativeTemplateFontStyle.bold,
size: 16.0,
),
secondaryTextStyle: NativeTemplateTextStyle(
textColor: widget.scheme.onBackground,
style: NativeTemplateFontStyle.italic,
size: 14.0,
),
tertiaryTextStyle: NativeTemplateTextStyle(
textColor: widget.scheme.onBackground,
style: NativeTemplateFontStyle.normal,
size: 14.0,
),
);

_loadAd(
naviteListener,
nativeTemplateStyle,
);
}

@override
Expand All @@ -37,54 +88,19 @@ class SmallNativeAdState extends State<SmallNativeAd> {
}

/// Loads a native ad.
void _loadAd() {
void _loadAd(naviteListener, nativeTemplateStyle) {
setState(() {
_nativeAdIsLoaded = false;
});

_nativeAd = NativeAd(
adUnitId: _adUnitId,
listener: NativeAdListener(
onAdLoaded: (ad) {
// ignore: avoid_print
print('$NativeAd loaded.');
setState(() {
_nativeAdIsLoaded = true;
});
},
onAdFailedToLoad: (ad, error) {
// ignore: avoid_print
print('$NativeAd failedToLoad: $error');
ad.dispose();
},
onAdClicked: (ad) {},
onAdImpression: (ad) {},
onAdClosed: (ad) {},
onAdOpened: (ad) {},
onAdWillDismissScreen: (ad) {},
onPaidEvent: (ad, valueMicros, precision, currencyCode) {},
),
request: const AdRequest(),
nativeTemplateStyle: NativeTemplateStyle(
templateType: TemplateType.small,
mainBackgroundColor: const Color(0xfffffbed),
callToActionTextStyle: NativeTemplateTextStyle(
textColor: Colors.white,
style: NativeTemplateFontStyle.monospace,
size: 16.0),
primaryTextStyle: NativeTemplateTextStyle(
textColor: Colors.black,
style: NativeTemplateFontStyle.bold,
size: 16.0),
secondaryTextStyle: NativeTemplateTextStyle(
textColor: Colors.black,
style: NativeTemplateFontStyle.italic,
size: 16.0),
tertiaryTextStyle: NativeTemplateTextStyle(
textColor: Colors.black,
style: NativeTemplateFontStyle.normal,
size: 16.0)))
..load();
adUnitId: _adUnitId,
listener: naviteListener,
request: const AdRequest(),
nativeTemplateStyle: nativeTemplateStyle,
);

_nativeAd!.load();
}

@override
Expand Down
11 changes: 5 additions & 6 deletions pets/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@
"medicineProducer": "Producer",
"medicineVeterinary": "Veterinary",
"onboardingTitle": "Welcome",
"onboardingContent1": "You still ",
"onboardingContent2": "didn''t register",
"onboardingContent3": " any of your pets.",
"onboardingContent4": "Que tal cadastrar um agora?",
"onboardingNoPetsCta": "Cadastrar novo pet",
"onboardingContent1": "Here you can keep track of your pets health.",
"onboardingContent4": "What about registering your first pet now?",
"onboardingNoPetsCta": "Register new pet",
"onboardingAcessibleLabel": "A person with a dog walking",
"petsNewPet": "New pet",
"petsAnimalName": "Animal name",
Expand Down Expand Up @@ -133,5 +131,6 @@
"placeholderProximos4": "Appointments can be ",
"placeholderProximos5": "repetitions for routine tasks",
"placeholderProximos6": " or ",
"placeholderProximos7": "by quantity, like doses in medications.\n"
"placeholderProximos7": "by quantity, like doses in medications.\n",
"spaces": "Spaces"
}
Loading

0 comments on commit df35b65

Please sign in to comment.