Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat initialize releases notes page #28

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/core/libraries/templates/default_page_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ class DefaultPageTemplate extends StatelessWidget {
final Object? error;
final Widget Function()? pageInitial;
final Widget appBar;
final Widget? bottomNavigationBar;
const DefaultPageTemplate({
super.key,
required this.pageDone,
required this.state,
required this.error,
this.pageInitial,
required this.appBar,
this.bottomNavigationBar,
});

@override
Expand All @@ -41,6 +43,7 @@ class DefaultPageTemplate extends StatelessWidget {
appBar: AppBar(
title: appBar,
),
bottomNavigationBar: bottomNavigationBar,
);
}
}
12 changes: 10 additions & 2 deletions lib/core/libraries/templates/modulo_page_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,17 @@ class ModuloPageTemplate extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
ElevatedButton.icon(
style: TextButton.styleFrom(
padding: EdgeInsets.symmetric(
horizontal: AppTheme.defaultPadding * 1.5,
vertical: AppTheme.defaultPadding /
(Responsive.isMobile(context) ? 2 : 1),
),
),
onPressed: onPressedAtualiza,
child: const Text('Atualiza'),
icon: const Icon(Icons.replay),
label: const Text('Atualizar'),
),
if (labelNovoItem != null)
ElevatedButton.icon(
Expand Down
2 changes: 2 additions & 0 deletions lib/core/services/routers/service_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'package:dashboard_manga_easy/modules/recomendacao/recomendacao_module.da
import 'package:dashboard_manga_easy/modules/splash/splash_module.dart';
import 'package:dashboard_manga_easy/modules/splash/views/splash_view.dart';
import 'package:dashboard_manga_easy/modules/toggles/toggles_module.dart';
import 'package:dashboard_manga_easy/modules/update_notes/update_notes_module.dart';
import 'package:dashboard_manga_easy/modules/users/users_module.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
Expand Down Expand Up @@ -49,6 +50,7 @@ class ServiceRoute {
PermissoesModule(),
HostModule(),
TogglesModule(),
UpdateNotesModule(),
];

Future<void> initialise() async {
Expand Down
8 changes: 0 additions & 8 deletions lib/modules/banners/data/repositories/banner_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,4 @@ class BannerRepository {
);
return BannerEntity.fromJson(result.first);
}

String lokkk(String path) {
final index = path.lastIndexOf('.');
if (index < 0 || index + 1 >= path.length) {
return path;
}
return path.substring(index + 1).toLowerCase();
}
}
2 changes: 2 additions & 0 deletions lib/modules/dashboard/presenter/ui/organisms/side_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:dashboard_manga_easy/modules/notificacao/views/notificacao_page.
import 'package:dashboard_manga_easy/modules/permissoes/presenter/ui/pages/permissoes_page.dart';
import 'package:dashboard_manga_easy/modules/recomendacao/views/recomendacao_page.dart';
import 'package:dashboard_manga_easy/modules/toggles/presenter/ui/pages/toggles_page.dart';
import 'package:dashboard_manga_easy/modules/update_notes/presenter/ui/release_notes_page.dart';
import 'package:dashboard_manga_easy/modules/users/presenter/ui/pages/users_page.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
Expand All @@ -32,6 +33,7 @@ class SideMenu extends StatelessWidget {
MenuItem(route: PermissoesPage.route, title: 'Permissões'),
MenuItem(route: HostPage.route, title: 'Hosts'),
MenuItem(route: TogglesPage.route, title: 'Toggles'),
MenuItem(route: ReleaseNotesPage.route, title: 'Notas de atualização'),
];

SideMenu({
Expand Down
176 changes: 176 additions & 0 deletions lib/modules/update_notes/data/dtos/update_notes_dto.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import 'package:dashboard_manga_easy/modules/update_notes/domain/update_notes_entity.dart';

class FixDto {
String title;
String subtitle;
String description;

FixDto({
required this.title,
required this.subtitle,
required this.description,
});

factory FixDto.fromJson(Map<String, dynamic> json) {
return FixDto(
title: json['title'],
subtitle: json['subtitle'],
description: json['description'],
);
}

factory FixDto.empty() {
return FixDto(
title: '',
subtitle: '',
description: '',
);
}

Map<String, dynamic> toJson() {
return {
'title': title,
'subtitle': subtitle,
'description': description,
};
}

Fix toEntity() {
return Fix(
title: title,
subtitle: subtitle,
description: description,
);
}

static FixDto fromEntity(Fix entity) {
return FixDto(
title: entity.title,
subtitle: entity.subtitle,
description: entity.description,
);
}
}

class FeatureDto {
String title;
String subtitle;
String description;

FeatureDto({
required this.title,
required this.subtitle,
required this.description,
});

factory FeatureDto.fromJson(Map<String, dynamic> json) {
return FeatureDto(
title: json['title'],
subtitle: json['subtitle'],
description: json['description'],
);
}

factory FeatureDto.empty() {
return FeatureDto(
title: '',
subtitle: '',
description: '',
);
}

Map<String, dynamic> toJson() {
return {
'title': title,
'subtitle': subtitle,
'description': description,
};
}

Feature toEntity() {
return Feature(
title: title,
subtitle: subtitle,
description: description,
);
}

static FeatureDto fromEntity(Feature entity) {
return FeatureDto(
title: entity.title,
subtitle: entity.subtitle,
description: entity.description,
);
}
}

class UpdateNotesDto {
String version;
String description;
List<FixDto> fixes;
String id;
List<FeatureDto> features;

UpdateNotesDto({
required this.id,
required this.version,
required this.description,
required this.fixes,
required this.features,
});

factory UpdateNotesDto.fromJson(Map<String, dynamic> json) {
return UpdateNotesDto(
id: json['id'],
version: json['version'],
description: json['description'],
fixes: (json['fixes'] as List)
.map((fixJson) => FixDto.fromJson(fixJson))
.toList(),
features: (json['features'] as List)
.map((featureJson) => FeatureDto.fromJson(featureJson))
.toList(),
);
}

factory UpdateNotesDto.empty() {
return UpdateNotesDto(
version: '',
id: '',
description: '',
fixes: [],
features: [],
);
}

Map<String, dynamic> toJson() {
return {
'version': version,
'description': description,
'fixes': fixes.map((fixDto) => fixDto.toJson()).toList(),
'features': features.map((featureDto) => featureDto.toJson()).toList(),
};
}

UpdateNotesEntity toEntity() {
return UpdateNotesEntity(
version: version,
description: description,
id: id,
fixes: fixes.map((fixDto) => fixDto.toEntity()).toList(),
features: features.map((featureDto) => featureDto.toEntity()).toList(),
);
}

static UpdateNotesDto fromEntity(UpdateNotesEntity entity) {
return UpdateNotesDto(
id: entity.id,
version: entity.version,
description: entity.description,
fixes: entity.fixes.map((fix) => FixDto.fromEntity(fix)).toList(),
features: entity.features
.map((feature) => FeatureDto.fromEntity(feature))
.toList(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:dashboard_manga_easy/core/services/apis/api_monolito.dart';
import 'package:dashboard_manga_easy/modules/update_notes/data/dtos/update_notes_dto.dart';
import 'package:dashboard_manga_easy/modules/update_notes/domain/update_notes_entity.dart';

class UpdateNotesRepository {
final ApiMonolith _monolith;

UpdateNotesRepository(this._monolith);

Future<List<UpdateNotesEntity>> get() async {
final data = await _monolith.get('release-note/v1');
if (data is List && data.isNotEmpty) {
return data
.map((item) => UpdateNotesDto.fromJson(item).toEntity())
.toList();
}
return [];
}

Future<UpdateNotesDto> getById({required String id}) async {
final data = await _monolith.get('release-note/v1/$id');
return UpdateNotesDto.fromJson(data);
}

Future<UpdateNotesDto> getByVersion({required String version}) async {
final data = await _monolith.get('release-note/v1/version/$version');
return UpdateNotesDto.fromJson(data);
}

Future<void> post({required UpdateNotesDto body}) async {
await _monolith.post(
'release-note/v1',
body: body.toJson(),
);
}

Future<void> put({required String id, required UpdateNotesDto body}) async {
await _monolith.put(
'release-note/v1/$id',
body: body.toJson(),
);
}

Future<void> delete({required String id}) async {
await _monolith.delete('release-note/v1/$id');
}
}
39 changes: 39 additions & 0 deletions lib/modules/update_notes/domain/update_notes_entity.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class Fix {
final String title;
final String subtitle;
final String description;

Fix({
required this.title,
required this.subtitle,
required this.description,
});
}

class Feature {
final String title;
final String subtitle;
final String description;

Feature({
required this.title,
required this.subtitle,
required this.description,
});
}

class UpdateNotesEntity {
final String version;
final String id;
final String description;
final List<Fix> fixes;
final List<Feature> features;

UpdateNotesEntity({
required this.version,
required this.description,
required this.fixes,
required this.id,
required this.features,
});
}
Loading