From b7ac2dbda8f225b1dcb8618cc69d96bc94b3455d Mon Sep 17 00:00:00 2001 From: Fernando da Silva Sousa Date: Sun, 19 Nov 2023 13:28:54 -0300 Subject: [PATCH 1/4] Adiciona atributos em pets --- pets-api/app/Models/Pet.php | 2 ++ pets-api/database/factories/PetFactory.php | 6 ++++ ..._19_143359_add_atributos_on_pets_table.php | 28 +++++++++++++++++++ pets-api/tests/Pest.php | 4 +++ pets-api/tests/Unit/Models/PetTest.php | 27 ++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 pets-api/database/migrations/2023_11_19_143359_add_atributos_on_pets_table.php create mode 100644 pets-api/tests/Unit/Models/PetTest.php diff --git a/pets-api/app/Models/Pet.php b/pets-api/app/Models/Pet.php index 99d4e1a..f17c947 100644 --- a/pets-api/app/Models/Pet.php +++ b/pets-api/app/Models/Pet.php @@ -74,6 +74,7 @@ class Pet extends Model 'castracao', 'mae_id', 'pai_id', + 'atributos', ]; /** @@ -85,6 +86,7 @@ class Pet extends Model 'nascimento' => 'datetime', 'falecimento' => 'datetime', 'castracao' => 'datetime', + 'atributos' => 'array', ]; /** diff --git a/pets-api/database/factories/PetFactory.php b/pets-api/database/factories/PetFactory.php index d592287..7bb05d5 100644 --- a/pets-api/database/factories/PetFactory.php +++ b/pets-api/database/factories/PetFactory.php @@ -30,6 +30,12 @@ public function definition(): array 'nascimento' => $this->faker->dateTimeBetween('-10 years', '-1 year'), 'falecimento' => $this->faker->dateTimeBetween('-1 year', 'now'), 'castracao' => $this->faker->dateTimeBetween('-1 year', 'now'), + 'atributos' => [ + 'cor' => $this->faker->randomElement(['preto', 'branco', 'marrom']), + 'pelagem' => $this->faker->randomElement(['curta', 'longa']), + 'porte' => $this->faker->randomElement(['pequeno', 'medio', 'grande']), + 'temperamento' => $this->faker->randomElement(['calmo', 'agressivo', 'brincalhao']), + ], ]; } } diff --git a/pets-api/database/migrations/2023_11_19_143359_add_atributos_on_pets_table.php b/pets-api/database/migrations/2023_11_19_143359_add_atributos_on_pets_table.php new file mode 100644 index 0000000..6c24654 --- /dev/null +++ b/pets-api/database/migrations/2023_11_19_143359_add_atributos_on_pets_table.php @@ -0,0 +1,28 @@ +json('atributos')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('pets', function (Blueprint $table) { + $table->dropColumn('atributos'); + }); + } +}; diff --git a/pets-api/tests/Pest.php b/pets-api/tests/Pest.php index 3d4d875..70ec389 100644 --- a/pets-api/tests/Pest.php +++ b/pets-api/tests/Pest.php @@ -16,6 +16,10 @@ Illuminate\Foundation\Testing\RefreshDatabase::class, )->in('Feature'); +uses( + Tests\TestCase::class, +)->in('Unit'); + /* |-------------------------------------------------------------------------- | Expectations diff --git a/pets-api/tests/Unit/Models/PetTest.php b/pets-api/tests/Unit/Models/PetTest.php new file mode 100644 index 0000000..52cb1a5 --- /dev/null +++ b/pets-api/tests/Unit/Models/PetTest.php @@ -0,0 +1,27 @@ +create(); + + $pet->fill([ + 'atributos' => [ + 'cor' => 'preto', + 'pelagem' => 'curta', + 'porte' => 'pequeno', + 'temperamento' => 'calmo', + ], + ]); + + assertEquals($pet->atributos, [ + 'cor' => 'preto', + 'pelagem' => 'curta', + 'porte' => 'pequeno', + 'temperamento' => 'calmo', + ]); +}); From 0f232ad38d5bd312e454c32d80e413cbf00e304b Mon Sep 17 00:00:00 2001 From: Fernando da Silva Sousa Date: Sun, 19 Nov 2023 13:30:29 -0300 Subject: [PATCH 2/4] Adiciona leitura de atributos na request de pets --- pets-api/app/Http/Requests/PetRequest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pets-api/app/Http/Requests/PetRequest.php b/pets-api/app/Http/Requests/PetRequest.php index 01c8216..25cbf01 100644 --- a/pets-api/app/Http/Requests/PetRequest.php +++ b/pets-api/app/Http/Requests/PetRequest.php @@ -25,6 +25,7 @@ public function rules(): array 'castracao' => 'nullable|date', 'mae_id' => 'nullable|exists:pets,id', 'pai_id' => 'nullable|exists:pets,id', + 'atributos' => 'nullable|array', ]; } } From 932ffde4ef671a19ce7970ea554ef58cae0712a8 Mon Sep 17 00:00:00 2001 From: Fernando da Silva Sousa Date: Sun, 19 Nov 2023 13:52:19 -0300 Subject: [PATCH 3/4] =?UTF-8?q?Corrige=20tradu=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pets/README.md | 11 +++++++++++ pets/l10n.yaml | 3 ++- pets/lib/l10n/app_en.arb | 3 ++- pets/lib/l10n/app_pt.arb | 6 +++++- pets/untranslated_messages.json | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 pets/untranslated_messages.json diff --git a/pets/README.md b/pets/README.md index 466b4f9..61981cc 100644 --- a/pets/README.md +++ b/pets/README.md @@ -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). \ No newline at end of file diff --git a/pets/l10n.yaml b/pets/l10n.yaml index 4e6692e..66876ad 100644 --- a/pets/l10n.yaml +++ b/pets/l10n.yaml @@ -1,3 +1,4 @@ arb-dir: lib/l10n template-arb-file: app_en.arb -output-localization-file: app_localizations.dart \ No newline at end of file +output-localization-file: app_localizations.dart +untranslated-messages-file: untranslated_messages.json \ No newline at end of file diff --git a/pets/lib/l10n/app_en.arb b/pets/lib/l10n/app_en.arb index 6ac35a0..7bc0555 100644 --- a/pets/lib/l10n/app_en.arb +++ b/pets/lib/l10n/app_en.arb @@ -133,5 +133,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", + "petsNewField": "New field" } diff --git a/pets/lib/l10n/app_pt.arb b/pets/lib/l10n/app_pt.arb index fce0fae..8b20a30 100644 --- a/pets/lib/l10n/app_pt.arb +++ b/pets/lib/l10n/app_pt.arb @@ -13,9 +13,12 @@ "sharedUnknown": "Desconhecido", "sharedCancel": "Cancelar", "sharedExclude": "Excluir", + "sharedMale": "Macho", + "sharedFemale": "Fêmea", "dashboardMyPets": "Meus pets", "dashboardTodo": "A fazer", "dashboardTimeline": "Linha do tempo", + "medicineMain": "Principal", "medicineType": "Tipo", "medicinePrefixOn": "Em ", "medicineAnimal": "Animal", @@ -86,5 +89,6 @@ "placeholderProximos4": "Os agendamentos podem ", "placeholderProximos5": "ser repetições para tarefas rotineiras", "placeholderProximos6": " ou ", - "placeholderProximos7": "por quantidade como as doses em medicamentos.\n" + "placeholderProximos7": "por quantidade como as doses em medicamentos.\n", + "petsNewField": "Novo campo" } diff --git a/pets/untranslated_messages.json b/pets/untranslated_messages.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pets/untranslated_messages.json @@ -0,0 +1 @@ +{} \ No newline at end of file From 5d6e56c7afce37064670747af500447e2a4e87c4 Mon Sep 17 00:00:00 2001 From: Fernando da Silva Sousa Date: Sun, 19 Nov 2023 16:51:54 -0300 Subject: [PATCH 4/4] Adiciona atributos em pet --- pets/lib/models/pet.dart | 1 + pets/lib/models/pet.freezed.dart | 89 ++++++++++++++++++++++---------- pets/lib/models/pet.g.dart | 5 ++ 3 files changed, 67 insertions(+), 28 deletions(-) diff --git a/pets/lib/models/pet.dart b/pets/lib/models/pet.dart index c6fc59d..d05e50d 100644 --- a/pets/lib/models/pet.dart +++ b/pets/lib/models/pet.dart @@ -29,6 +29,7 @@ class Pet with _$Pet { @JsonKey(name: 'espaco_id') required String? espacoId, String? falecimento, @JsonKey(name: 'imagem_url') String? imagemUrl, + @Default({}) Map? atributos, }) = _Pet; Uri? get imagemUri { diff --git a/pets/lib/models/pet.freezed.dart b/pets/lib/models/pet.freezed.dart index baa5709..2a8f363 100644 --- a/pets/lib/models/pet.freezed.dart +++ b/pets/lib/models/pet.freezed.dart @@ -45,6 +45,7 @@ mixin _$Pet { String? get falecimento => throw _privateConstructorUsedError; @JsonKey(name: 'imagem_url') String? get imagemUrl => throw _privateConstructorUsedError; + Map? get atributos => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -74,7 +75,8 @@ abstract class $PetCopyWith<$Res> { String? userUpdated, @JsonKey(name: 'espaco_id') String? espacoId, String? falecimento, - @JsonKey(name: 'imagem_url') String? imagemUrl}); + @JsonKey(name: 'imagem_url') String? imagemUrl, + Map? atributos}); } /// @nodoc @@ -107,6 +109,7 @@ class _$PetCopyWithImpl<$Res, $Val extends Pet> implements $PetCopyWith<$Res> { Object? espacoId = freezed, Object? falecimento = freezed, Object? imagemUrl = freezed, + Object? atributos = freezed, }) { return _then(_value.copyWith( id: freezed == id @@ -181,6 +184,10 @@ class _$PetCopyWithImpl<$Res, $Val extends Pet> implements $PetCopyWith<$Res> { ? _value.imagemUrl : imagemUrl // ignore: cast_nullable_to_non_nullable as String?, + atributos: freezed == atributos + ? _value.atributos + : atributos // ignore: cast_nullable_to_non_nullable + as Map?, ) as $Val); } } @@ -209,7 +216,8 @@ abstract class _$$_PetCopyWith<$Res> implements $PetCopyWith<$Res> { String? userUpdated, @JsonKey(name: 'espaco_id') String? espacoId, String? falecimento, - @JsonKey(name: 'imagem_url') String? imagemUrl}); + @JsonKey(name: 'imagem_url') String? imagemUrl, + Map? atributos}); } /// @nodoc @@ -239,6 +247,7 @@ class __$$_PetCopyWithImpl<$Res> extends _$PetCopyWithImpl<$Res, _$_Pet> Object? espacoId = freezed, Object? falecimento = freezed, Object? imagemUrl = freezed, + Object? atributos = freezed, }) { return _then(_$_Pet( id: freezed == id @@ -313,6 +322,10 @@ class __$$_PetCopyWithImpl<$Res> extends _$PetCopyWithImpl<$Res, _$_Pet> ? _value.imagemUrl : imagemUrl // ignore: cast_nullable_to_non_nullable as String?, + atributos: freezed == atributos + ? _value._atributos + : atributos // ignore: cast_nullable_to_non_nullable + as Map?, )); } } @@ -338,8 +351,10 @@ class _$_Pet extends _Pet with DiagnosticableTreeMixin { this.userUpdated, @JsonKey(name: 'espaco_id') required this.espacoId, this.falecimento, - @JsonKey(name: 'imagem_url') this.imagemUrl}) - : super._(); + @JsonKey(name: 'imagem_url') this.imagemUrl, + final Map? atributos = const {}}) + : _atributos = atributos, + super._(); factory _$_Pet.fromJson(Map json) => _$$_PetFromJson(json); @@ -387,10 +402,20 @@ class _$_Pet extends _Pet with DiagnosticableTreeMixin { @override @JsonKey(name: 'imagem_url') final String? imagemUrl; + final Map? _atributos; + @override + @JsonKey() + Map? get atributos { + final value = _atributos; + if (value == null) return null; + if (_atributos is EqualUnmodifiableMapView) return _atributos; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'Pet(id: $id, nome: $nome, createdAt: $createdAt, updatedAt: $updatedAt, especieId: $especieId, especie: $especie, imagem: $imagem, maeId: $maeId, nascimento: $nascimento, castracao: $castracao, paiId: $paiId, raca: $raca, sexo: $sexo, userCreated: $userCreated, userUpdated: $userUpdated, espacoId: $espacoId, falecimento: $falecimento, imagemUrl: $imagemUrl)'; + return 'Pet(id: $id, nome: $nome, createdAt: $createdAt, updatedAt: $updatedAt, especieId: $especieId, especie: $especie, imagem: $imagem, maeId: $maeId, nascimento: $nascimento, castracao: $castracao, paiId: $paiId, raca: $raca, sexo: $sexo, userCreated: $userCreated, userUpdated: $userUpdated, espacoId: $espacoId, falecimento: $falecimento, imagemUrl: $imagemUrl, atributos: $atributos)'; } @override @@ -415,7 +440,8 @@ class _$_Pet extends _Pet with DiagnosticableTreeMixin { ..add(DiagnosticsProperty('userUpdated', userUpdated)) ..add(DiagnosticsProperty('espacoId', espacoId)) ..add(DiagnosticsProperty('falecimento', falecimento)) - ..add(DiagnosticsProperty('imagemUrl', imagemUrl)); + ..add(DiagnosticsProperty('imagemUrl', imagemUrl)) + ..add(DiagnosticsProperty('atributos', atributos)); } @override @@ -450,31 +476,35 @@ class _$_Pet extends _Pet with DiagnosticableTreeMixin { (identical(other.falecimento, falecimento) || other.falecimento == falecimento) && (identical(other.imagemUrl, imagemUrl) || - other.imagemUrl == imagemUrl)); + other.imagemUrl == imagemUrl) && + const DeepCollectionEquality() + .equals(other._atributos, _atributos)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - id, - nome, - createdAt, - updatedAt, - especieId, - especie, - imagem, - maeId, - nascimento, - castracao, - paiId, - raca, - sexo, - userCreated, - userUpdated, - espacoId, - falecimento, - imagemUrl); + int get hashCode => Object.hashAll([ + runtimeType, + id, + nome, + createdAt, + updatedAt, + especieId, + especie, + imagem, + maeId, + nascimento, + castracao, + paiId, + raca, + sexo, + userCreated, + userUpdated, + espacoId, + falecimento, + imagemUrl, + const DeepCollectionEquality().hash(_atributos) + ]); @JsonKey(ignore: true) @override @@ -509,7 +539,8 @@ abstract class _Pet extends Pet { final String? userUpdated, @JsonKey(name: 'espaco_id') required final String? espacoId, final String? falecimento, - @JsonKey(name: 'imagem_url') final String? imagemUrl}) = _$_Pet; + @JsonKey(name: 'imagem_url') final String? imagemUrl, + final Map? atributos}) = _$_Pet; const _Pet._() : super._(); factory _Pet.fromJson(Map json) = _$_Pet.fromJson; @@ -558,6 +589,8 @@ abstract class _Pet extends Pet { @JsonKey(name: 'imagem_url') String? get imagemUrl; @override + Map? get atributos; + @override @JsonKey(ignore: true) _$$_PetCopyWith<_$_Pet> get copyWith => throw _privateConstructorUsedError; } diff --git a/pets/lib/models/pet.g.dart b/pets/lib/models/pet.g.dart index 2a7f2fd..78905c0 100644 --- a/pets/lib/models/pet.g.dart +++ b/pets/lib/models/pet.g.dart @@ -27,6 +27,10 @@ _$_Pet _$$_PetFromJson(Map json) => _$_Pet( espacoId: json['espaco_id'] as String?, falecimento: json['falecimento'] as String?, imagemUrl: json['imagem_url'] as String?, + atributos: (json['atributos'] as Map?)?.map( + (k, e) => MapEntry(k, e as String), + ) ?? + const {}, ); Map _$$_PetToJson(_$_Pet instance) => { @@ -48,4 +52,5 @@ Map _$$_PetToJson(_$_Pet instance) => { 'espaco_id': instance.espacoId, 'falecimento': instance.falecimento, 'imagem_url': instance.imagemUrl, + 'atributos': instance.atributos, };