Skip to content

Commit

Permalink
Merge pull request #1 from TI-TecnicamenteIdiotas/develop
Browse files Browse the repository at this point in the history
Release - 2023/06/24
  • Loading branch information
AlmirJNR authored Jun 24, 2023
2 parents 969b1e2 + 5abdb41 commit 035413a
Show file tree
Hide file tree
Showing 89 changed files with 3,858 additions and 138 deletions.
7 changes: 7 additions & 0 deletions .run/production.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="production" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="additionalArgs" value="--dart-define-from-file=config.production.json --release" />
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
<method v="2" />
</configuration>
</component>
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.nimbleflow.nimbleflow"
namespace "com.nimbleflow"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand All @@ -37,7 +37,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.nimbleflow.nimbleflow"
applicationId "com.nimbleflow"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="nimbleflow"
android:name="${applicationName}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.nimbleflow.nimbleflow;
package com.nimbleflow;

import io.flutter.embedding.android.FlutterActivity;

Expand Down
Binary file added assets/images/image_not_found.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"CATEGORY_BASE_SERVICE_URL": "http://10.0.2.2:10506",
"ORDER_BASE_SERVICE_URL": "http://10.0.2.2:10507",
"PRODUCT_BASE_SERVICE_URL": "http://10.0.2.2:10506",
"TABLE_BASE_SERVICE_URL": "http://10.0.2.2:10506",
"MAIN_HUB_BASE_SERVICE_URL": "http://10.0.2.2:10504",
"UPLOAD_BASE_SERVICE_URL": "http://10.0.2.2:10506"
}
8 changes: 8 additions & 0 deletions config.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"CATEGORY_BASE_SERVICE_URL": "http://192.168.15.131:10506",
"ORDER_BASE_SERVICE_URL": "http://192.168.15.131:10507",
"PRODUCT_BASE_SERVICE_URL": "http://192.168.15.131:10506",
"TABLE_BASE_SERVICE_URL": "http://192.168.15.131:10506",
"MAIN_HUB_BASE_SERVICE_URL": "http://192.168.15.131:10504",
"UPLOAD_BASE_SERVICE_URL": "http://192.168.15.131:10506"
}
61 changes: 61 additions & 0 deletions lib/home/categories/categories_module_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:nimbleflow/home/categories/utils/category_hub_subscribers.dart';
import 'package:nimbleflow/home/categories/widgets/list_of_categories_widget.dart';
import 'package:nimbleflow/shared/constants/global_keys_constants.dart';
import 'package:nimbleflow/home/categories/models/category_model.dart';
import 'package:nimbleflow/shared/services/hub_service.dart';
import 'package:nimbleflow/shared/storage/storage.dart';

import '../../shared/widgets/loading_dialog_widget.dart';

class CategoriesModulePage extends StatefulWidget {
final List<CategoryModel> listOfCategories;
final bool isLoading;

const CategoriesModulePage(this.listOfCategories, this.isLoading,
{super.key});

@override
State<CategoriesModulePage> createState() => _CategoriesModulePageState();
}

class _CategoriesModulePageState extends State<CategoriesModulePage> {
late final CategoryHubSubscriber categoryHubSubscriber;

@override
void initState() {
super.initState();
categoryHubSubscriber = CategoryHubSubscriber(
widget.listOfCategories,
HubService.mainHubConnection,
Storage.storage,
setState,
);
}

@override
void dispose() {
super.dispose();
categoryHubSubscriber.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Categorias")),
body: MaterialApp(
theme: Theme.of(context),
debugShowCheckedModeBanner: false,
navigatorKey: kCategoriesModuleNavigatorKey,
home: Builder(
builder: (_) {
if (widget.isLoading) {
return const Center(child: LoadingDialogWidget());
}
return ListOfCategoriesWidget(widget.listOfCategories);
},
),
),
);
}
}
3 changes: 3 additions & 0 deletions lib/home/categories/constants/categories_constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const kListOfCategoriesLimit = 64;

const kMaxTitleLength = 32;
19 changes: 19 additions & 0 deletions lib/home/categories/dtos/create_category_dto.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class CreateCategoryDto {
String title;
int? colorTheme;
int? categoryIcon;

CreateCategoryDto({
required this.title,
this.colorTheme,
this.categoryIcon,
});

Map<String, dynamic> toJson() {
return {
"title": title,
"colorTheme": colorTheme,
"categoryIcon": categoryIcon,
};
}
}
21 changes: 21 additions & 0 deletions lib/home/categories/dtos/update_category_dto.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class UpdateCategoryDto {
final String id;
String? title;
int? colorTheme;
int? categoryIcon;

UpdateCategoryDto({
required this.id,
this.title,
this.colorTheme,
this.categoryIcon,
});

Map<String, dynamic> toJson() {
return {
"title": title,
"colorTheme": colorTheme,
"categoryIcon": categoryIcon,
};
}
}
42 changes: 42 additions & 0 deletions lib/home/categories/models/category_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:nimbleflow/shared/constants/storage_constants.dart';

class CategoryModel {
final String id;
String title;
int? colorTheme;
int? categoryIcon;

CategoryModel({
required this.id,
required this.title,
this.colorTheme,
this.categoryIcon,
});

factory CategoryModel.fromStorageMap(Map<String, dynamic> map) {
return CategoryModel(
id: map["${kCategoryTableName}_id"],
title: map["${kCategoryTableName}_title"],
colorTheme: map["${kCategoryTableName}_colorTheme"],
categoryIcon: map["${kCategoryTableName}_categoryIcon"],
);
}

Map<String, dynamic> toStorageMap() {
return {
"id": id,
"title": title,
"colorTheme": colorTheme,
"categoryIcon": categoryIcon,
};
}

factory CategoryModel.fromJson(Map<String, dynamic> json) {
return CategoryModel(
id: json["id"],
title: json["title"],
colorTheme: json["colorTheme"],
categoryIcon: json["categoryIcon"],
);
}
}
22 changes: 22 additions & 0 deletions lib/home/categories/models/paginated_category_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:nimbleflow/home/categories/models/category_model.dart';

class PaginatedCategoryModel {
final int totalItems;
final List<CategoryModel> items;

PaginatedCategoryModel({
required this.totalItems,
required this.items,
});

factory PaginatedCategoryModel.fromJson(Map<String, dynamic> json) {
var itemsIterable = Iterable
.castFrom<dynamic, Map<String, dynamic>>(json["items"])
.map(CategoryModel.fromJson);

return PaginatedCategoryModel(
totalItems: json["totalItems"],
items: List.from(itemsIterable),
);
}
}
93 changes: 93 additions & 0 deletions lib/home/categories/pages/category_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import 'package:flutter/material.dart';
import 'package:nimbleflow/home/categories/dtos/update_category_dto.dart';
import 'package:nimbleflow/home/categories/models/category_model.dart';
import 'package:nimbleflow/home/categories/widgets/category_detailed_widget.dart';

import '../../../shared/constants/layout_constants.dart';
import '../../../shared/widgets/delete_button_widget.dart';
import '../../../shared/widgets/save_button_widget.dart';
import '../services/category_service.dart';

class CategoryPage extends StatefulWidget {
final CategoryModel category;

const CategoryPage(this.category, {super.key});

@override
State<CategoryPage> createState() => _CategoryPageState();
}

class _CategoryPageState extends State<CategoryPage> {
final formKey = GlobalKey<FormState>();
final titleTextEditingController = TextEditingController();
int? categoryIcon;
int? colorTheme;

void setCategoryIcon(IconData? value) {
if (value == null) return;

setState(() => categoryIcon = kListOfIcons.indexOf(value));
}

void setColorTheme(Color? value) {
if (value == null) return;

setState(() => colorTheme = kListOfColors.indexOf(value));
}

Future<bool> save() async {
if (!formKey.currentState!.validate()) return false;

await CategoryService.httpPutCategory(UpdateCategoryDto(
id: widget.category.id,
title: titleTextEditingController.text,
categoryIcon: categoryIcon,
colorTheme: colorTheme,
));

return true;
}

Future<void> delete() async {
await CategoryService.httpDeleteCategory(widget.category.id);
}

@override
void initState() {
super.initState();
titleTextEditingController.text = widget.category.title;
categoryIcon = widget.category.categoryIcon;
colorTheme = widget.category.colorTheme;
}

@override
void didUpdateWidget(covariant CategoryPage oldWidget) {
super.didUpdateWidget(oldWidget);
titleTextEditingController.text = widget.category.title;
categoryIcon = widget.category.categoryIcon;
colorTheme = widget.category.colorTheme;
}

@override
void dispose() {
super.dispose();
titleTextEditingController.dispose();
formKey.currentState?.dispose();
}

@override
Widget build(BuildContext context) {
return CategoryDetailed(
formKey: formKey,
titleTextEditingController: titleTextEditingController,
colorTheme: colorTheme,
setColorTheme: setColorTheme,
categoryIcon: categoryIcon,
setCategoryIcon: setCategoryIcon,
floatingActionButtons: [
SaveButtonWidget(onPressed: save),
DeleteButtonWidget(onPressed: delete),
],
);
}
}
66 changes: 66 additions & 0 deletions lib/home/categories/pages/create_category_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:nimbleflow/home/categories/services/category_service.dart';
import 'package:nimbleflow/home/categories/widgets/category_detailed_widget.dart';
import 'package:nimbleflow/shared/constants/layout_constants.dart';

import '../../../shared/widgets/cancel_button_widget.dart';
import '../../../shared/widgets/create_button_widget.dart';
import '../dtos/create_category_dto.dart';

class CreateCategoryPage extends StatefulWidget {
const CreateCategoryPage({super.key});

@override
State<CreateCategoryPage> createState() => _CreateCategoryPageState();
}

class _CreateCategoryPageState extends State<CreateCategoryPage> {
final formKey = GlobalKey<FormState>();

final titleTextEditingController = TextEditingController();
int? categoryIcon;
int? colorTheme;

void setCategoryIcon(IconData? value) {
if (value == null) return;

setState(() => categoryIcon = kListOfIcons.indexOf(value));
}

void setColorTheme(Color? value) {
if (value == null) return;

setState(() => colorTheme = kListOfColors.indexOf(value));
}

Future<bool> create() async {
if (!formKey.currentState!.validate()) return false;

await CategoryService.httpPostCategory(
CreateCategoryDto(
title: titleTextEditingController.text,
colorTheme: colorTheme,
categoryIcon: categoryIcon,
),
);

return true;
}

@override
Widget build(BuildContext context) {
return CategoryDetailed(
appBarText: "Nova categoria",
formKey: formKey,
titleTextEditingController: titleTextEditingController,
colorTheme: colorTheme,
setColorTheme: setColorTheme,
categoryIcon: categoryIcon,
setCategoryIcon: setCategoryIcon,
floatingActionButtons: [
CreateButtonWidget(onPressed: create),
const CancelButtonWidget(),
],
);
}
}
Loading

0 comments on commit 035413a

Please sign in to comment.