Skip to content

Commit

Permalink
mock data ile json menu modeli oluşturuldu...dil sayfa adı , icon bil…
Browse files Browse the repository at this point in the history
…gisi , url bilgisi ve parent bilgisi gibi bilgiler sahte data ile oluşturuldu. translate ile oluşturulan menu isimlerini çevirmek için traslate locale yapısı oıluşturuldu. dil desteği örneği sayfası incelenebilir. (#3)
  • Loading branch information
yusuf-gundogdu authored Nov 21, 2023
1 parent b587c99 commit 34b3a6c
Show file tree
Hide file tree
Showing 29 changed files with 862 additions and 239 deletions.
1 change: 1 addition & 0 deletions ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
2 changes: 2 additions & 0 deletions lib/configuration/app_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ class ApplicationKeys {
static const taskSaveScreen = Key('__taskSaveScreen__');
static const taskListScreen = Key('__taskListScreen__');
static const taskDetailScreen = Key('__taskDetailScreen__');
static const languageScreen = Key('__languageScreen__');

}
1 change: 1 addition & 0 deletions lib/configuration/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ApplicationRoutes {
static final account = '/account';
static final users = '/users';
static final tasks = '/tasks';
static final language = '/language';
// static final tasksDetail = '/tasks/:id';
// static final taskNew = '/tasks/new';
// static final taskEdit = '/tasks/:id/edit';
Expand Down
53 changes: 26 additions & 27 deletions lib/data/models/menu.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import 'package:dart_json_mapper/dart_json_mapper.dart';
import 'package:equatable/equatable.dart';

/// menu object
/// example:
/// id name description url icon order_priority active parent_id level
// 1 home home / icon 0 1 0
// 2 account account branch icon 4 1 1 1
// 3 logout logout /logout icon 1 1 2 2
// 4 login login /login icon 2 1 2 2
// 5 settings settings branch icon 3 1 1 1
import 'package:dart_json_mapper/dart_json_mapper.dart';

@jsonSerializable
class Menu extends Equatable {

@JsonProperty(name: 'id')
final int id;

Expand All @@ -33,37 +27,26 @@ class Menu extends Equatable {
@JsonProperty(name: 'active')
final bool active;

@JsonProperty(name: 'parentId')
final int? parentId;
@JsonProperty(name: 'parent')
final Menu? parent;

@JsonProperty(name: 'level')
final int level;

// salesPersonCode and salesPersonName

const Menu({
this.id = 1,
this.id = 0,
this.name = '',
this.description = '',
this.url = '',
this.icon = '',
this.orderPriority = 0,
this.active = false,
this.parentId,
this.parent,
this.level = 0,
});

@override
List<Object?> get props => [
id,
name,
description,
url,
icon,
orderPriority,
active,
parentId,
level,
];

Menu copyWith({
int? id,
String? name,
Expand All @@ -72,7 +55,7 @@ class Menu extends Equatable {
String? icon,
int? orderPriority,
bool? active,
int? parentId,
Menu? parent,
int? level,
}) {
return Menu(
Expand All @@ -83,8 +66,24 @@ class Menu extends Equatable {
icon: icon ?? this.icon,
orderPriority: orderPriority ?? this.orderPriority,
active: active ?? this.active,
parentId: parentId ?? this.parentId,
parent: parent ?? this.parent,
level: level ?? this.level,
);
}

@override
List<Object?> get props => [
id,
name,
description,
url,
icon,
orderPriority,
active,
parent,
level,
];

@override
bool get stringify => true;
}
256 changes: 256 additions & 0 deletions lib/data/repository/menu_repository.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
import 'dart:convert';

import 'package:dart_json_mapper/dart_json_mapper.dart';

import '../models/menu.dart';

class MenuRepository {
MenuRepository();

Future<List<Menu>> getMenus() async {
var obj = [
{
"id": 2,
"name": "account",
"description": "account",
"url": "/account",
"icon": "account",
"orderPriority": 1,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
},
{
"id": 3,
"name": "logout",
"description": "logout",
"url": "/logout",
"icon": "logout",
"orderPriority": 2,
"active": true,
"parent": {
"id": 2,
"name": "account",
"description": "account",
"url": "/account",
"icon": "account",
"orderPriority": 1,
"active": true,
"level": 1
},
"level": 2
},
{
"id": 5,
"name": "settings",
"description": "settings",
"url": "/settings",
"icon": "cog-outline",
"orderPriority": 6,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
},
{
"id": 25,
"name": "language",
"description": "language",
"url": "/language",
"icon": "web",
"orderPriority": 1,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
},
{
"id": 8,
"name": "register",
"description": "register",
"url": "/register",
"icon": "account-tie",
"orderPriority": 2,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
}, {
"id": 20,
"name": " New account",
"description": "New account",
"url": "/account",
"icon": "account-tie",
"orderPriority": 2,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
},
{
"id": 9,
"name": "createOffer",
"description": "createOffer",
"url": "/salesPerson/createOffer",
"icon": "account-multiple-plus-outline",
"orderPriority": 1,
"active": true,
"parent": {
"id": 8,
"name": "salesPerson",
"description": "salesPerson",
"url": "/salesPerson",
"icon": "account-tie",
"orderPriority": 2,
"active": true,
"level": 1
},
"level": 2
},
{
"id": 10,
"name": "editOffer",
"description": "editOffer",
"url": "/salesPerson/editOffer",
"icon": "account-edit-outline",
"orderPriority": 2,
"active": true,
"parent": {
"id": 8,
"name": "salesPerson",
"description": "salesPerson",
"url": "/salesPerson",
"icon": "account-tie",
"orderPriority": 2,
"active": true,
"level": 1
},
"level": 2
},
{
"id": 11,
"name": "customer",
"description": "customer",
"url": "/customer",
"icon": "account-group-outline",
"orderPriority": 3,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
},
{
"id": 14,
"name": "dashboard",
"description": "dashboard",
"url": "/dashboard",
"icon": "finance",
"orderPriority": 5,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
},
{
"id": 20,
"name": "tasks",
"description": "tasks",
"url": "/tasks",
"icon": "file-chart",
"orderPriority": 4,
"active": true,
"parent": {
"id": 1,
"name": "home",
"description": "home",
"url": "/",
"icon": "icon",
"orderPriority": 0,
"active": true,
"level": 0
},
"level": 1
},
{
"id": 22,
"name": "login",
"description": "login",
"url": "/login",
"icon": "information",
"orderPriority": 1,
"active": true,
"parent": {
"id": 2,
"name": "account",
"description": "account",
"url": "/account",
"icon": "account",
"orderPriority": 1,
"active": true,
"level": 1
},
"level": 2
}
];
List<Menu> menus = JsonMapper.deserialize<List<Menu>>(obj)!;

return menus;
}
}
Loading

0 comments on commit 34b3a6c

Please sign in to comment.