Skip to content

Commit

Permalink
Merge pull request #40 from Onix-Systems/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
cozvtieg9 authored Jan 30, 2024
2 parents 6a8df96 + dfd9903 commit 22b1c40
Show file tree
Hide file tree
Showing 98 changed files with 5,015 additions and 170 deletions.
11 changes: 11 additions & 0 deletions installers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


# Onix Flutter Project Generator


## Creating DMG installer

Use following command:

`rm ‘release/Onix Flutter Project Generator.dmg’ && flutter clean && flutter build macos --release && appdmg installers/dmg_creator/config.json ‘release/Onix Flutter Project Generator.dmg’`

4 changes: 2 additions & 2 deletions lib/app/bloc/app_models.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class _$ChangeThemeEventImpl implements ChangeThemeEvent {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ChangeThemeEventImpl &&
Expand Down Expand Up @@ -308,7 +308,7 @@ class _$AppScreenStateImpl implements _AppScreenState {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$AppScreenStateImpl &&
Expand Down
10 changes: 10 additions & 0 deletions lib/core/arch/domain/common/converter/mapper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//ignore: one_member_abstracts
abstract class Mapper<T, E> {
E map(T from);
}

abstract class MapperIterable<T, E> extends Mapper<T, E> {
Iterable<E> mapIterable(Iterable<T> from) {
return from.map(map);
}
}
8 changes: 8 additions & 0 deletions lib/core/di/repository.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:get_it/get_it.dart';
import 'package:onix_flutter_bricks/data/repository/figma_repository_impl.dart';
import 'package:onix_flutter_bricks/data/source/remote/figma/figma_remote_data_source.dart';
import 'package:onix_flutter_bricks/domain/repository/data_component_repository.dart';
import 'package:onix_flutter_bricks/data/repository/data_component_repository_impl.dart';
import 'package:onix_flutter_bricks/domain/repository/figma_repository.dart';
import 'package:onix_flutter_bricks/domain/repository/screen_repository.dart';
import 'package:onix_flutter_bricks/data/repository/screen_repository_impl.dart';
import 'package:onix_flutter_bricks/domain/repository/source_repository.dart';
Expand All @@ -18,6 +21,11 @@ void registerRepositories(GetIt getIt) {
)
..registerSingleton<SourceRepository>(
SourceRepositoryImpl(),
)
..registerLazySingleton<FigmaRepository>(
() => FigmaRepositoryImpl(
figmaRemoteDataSource: GetIt.I.get<FigmaRemoteDataSource>(),
),
); //{repositories end}
}

Expand Down
7 changes: 6 additions & 1 deletion lib/core/di/services.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:get_it/get_it.dart';
import 'package:onix_flutter_bricks/domain/repository/figma_repository.dart';
import 'package:onix_flutter_bricks/domain/service/figma_service/figma_service.dart';
import 'package:onix_flutter_bricks/domain/service/file_generator_service/file_generator_service.dart';
import 'package:onix_flutter_bricks/domain/service/output_service/output_service.dart';
Expand All @@ -7,7 +8,11 @@ void registerServices(GetIt getIt) {
getIt
..registerSingleton<OutputService>(OutputService())
..registerSingleton<FileGeneratorService>(FileGeneratorService())
..registerSingleton<FigmaService>(FigmaService());
..registerLazySingleton<FigmaService>(
() => FigmaService(
figmaRepository: GetIt.I.get<FigmaRepository>(),
),
);
}

OutputService get outputService => GetIt.I.get<OutputService>();
Expand Down
9 changes: 8 additions & 1 deletion lib/core/di/source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import 'package:get_it/get_it.dart';

import 'package:onix_flutter_bricks/data/source/local/config_source/config_source.dart';
import 'package:onix_flutter_bricks/data/source/local/config_source/config_source_impl.dart';
import 'package:onix_flutter_bricks/data/source/remote/figma/figma_remote_data_source.dart';
import 'package:onix_flutter_bricks/data/source/remote/figma/figma_remote_source_impl.dart';

//{imports end}

void registerSources(GetIt getIt) {
getIt.registerSingleton<ConfigSource>(ConfigSourceImpl()); //{sources end}
getIt
..registerSingleton<ConfigSource>(ConfigSourceImpl())
..registerLazySingleton<FigmaRemoteDataSource>(
() => const FigmaRemoteDataSourceImpl(),
);
//{sources end}
}

ConfigSource get configSource => GetIt.I.get<ConfigSource>();
61 changes: 61 additions & 0 deletions lib/data/converter/figma/figma_node_type_converter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/connector/connector_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/document/document_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/frame/frame_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/node/node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/section/section_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/shape_with_text/shape_with_text_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/sticky/sticky_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/table_cell/table_cell_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/text/text_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/vector/vector_node_data_model.dart';

class FigmaNodeTypeConverter
extends JsonConverter<NodeDataModel, Map<String, dynamic>> {
const FigmaNodeTypeConverter();

@override
NodeDataModel fromJson(Map<String, dynamic> json) {
final type = json['type'];

switch (type) {
case 'DOCUMENT':
return DocumentNodeDataModel.fromJson(json);
case 'FRAME':
case 'COMPONENT':
case 'COMPONENT_SET':
case 'INSTANCE':
case 'GROUP':
return FrameNodeDataModel.fromJson(json);
case 'SECTION':
return SectionNodeDataModel.fromJson(json);
case 'VECTOR':
case 'BOOLEAN_OPERATION':
case 'STAR':
case 'LINE':
case 'ELLIPSE':
case 'REGULAR_POLYGON':
case 'WASHI_TAPE':
case 'RECTANGLE':
return VectorNodeDataModel.fromJson(json);
case 'TEXT':
return TextNodeDataModel.fromJson(json);
case 'TABLE_CELL':
return TableCellNodeDataModel.fromJson(json);
case 'STICKY':
return StickyNodeDataModel.fromJson(json);
case 'SHAPE_WITH_TEXT':
return ShapeWithTextNodeDataModel.fromJson(json);
case 'CONNECTOR':
return ConnectorNodeDataModel.fromJson(json);
default:
return NodeDataModel.fromJson(json);
}
}

@override
Map<String, dynamic> toJson(NodeDataModel object) {
// TODO(Ivan Modlo): Implement it if necessary
throw UnimplementedError();
}
}
27 changes: 27 additions & 0 deletions lib/data/converter/figma/figma_nodes_converter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:onix_flutter_bricks/data/converter/figma/figma_node_type_converter.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/node/node_data_model.dart';

class FigmaNodesConverter
extends JsonConverter<List<NodeDataModel>, Map<String, dynamic>> {
const FigmaNodesConverter();

@override
List<NodeDataModel> fromJson(Map<String, dynamic> json) {
final list = json.values
.map(
(e) => const FigmaNodeTypeConverter().fromJson(
(e as Map<String, dynamic>)['document'],
),
)
.toList();

return list;
}

@override
Map<String, dynamic> toJson(List<NodeDataModel> object) {
// TODO(Ivan Modlo): Implement it if necessary
throw UnimplementedError();
}
}
144 changes: 144 additions & 0 deletions lib/data/mapper/figma/figma_nodes_mapper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import 'package:onix_flutter_bricks/core/arch/domain/common/converter/mapper.dart';
import 'package:onix_flutter_bricks/data/mapper/figma/properties_mapper.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/connector/connector_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/document/document_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/frame/frame_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/node/node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/section/section_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/shape_with_text/shape_with_text_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/sticky/sticky_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/table_cell/table_cell_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/text/text_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/nodes/vector/vector_node_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/properties/paint/paint_property_data_model.dart';
import 'package:onix_flutter_bricks/data/model/figma/properties/type_style/figma_type_style.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/connector_node/connector_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/document_node/document_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/frame_node/frame_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/node/base_node.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/node/base_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/section_node/section_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/shape_with_text_node/shape_with_text_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/sticky_node/sticky_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/table_cell_node/table_cell_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/text_node/text_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/nodes/vector_node/vector_node_entity.dart';
import 'package:onix_flutter_bricks/domain/entity/figma/properties/paint_property/paint_property.dart';

class FigmaNodesMapper {
List<BaseNode> mapNodesDataModelToEntity(List<NodeDataModel> from) =>
_MapNodeDataModelToEntity().mapIterable(from).toList();
}

class _MapNodeDataModelToEntity
extends MapperIterable<NodeDataModel, BaseNode> {
@override
BaseNode map(NodeDataModel from) {
switch (from) {
case (DocumentNodeDataModel _):
return DocumentNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
// (Ivan Modlo): Maybe we should call the map method recursively
children: from.children
?.map(
(e) => BaseNodeEntity(
id: e?.id ?? '',
key: e?.key ?? '',
name: e?.name ?? '',
type: e?.type ?? '',
),
)
.toList() ??
[],
);
case TextNodeDataModel _:
return TextNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
style: PropertyMapper().mapFigmaTypeStyleDataModelToEntity(
from.style ??
const FigmaTypeStyle(
fontFamily: '',
fontWeight: 0,
fontSize: 0,
letterSpacing: 0,
),
),
);
case FrameNodeDataModel _:
return FrameNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
);
case SectionNodeDataModel _:
return SectionNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
);
case VectorNodeDataModel _:
return VectorNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
);
case TableCellNodeDataModel _:
return TableCellNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
);

case StickyNodeDataModel _:
return StickyNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
);

case ShapeWithTextNodeDataModel _:
return ShapeWithTextNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
);
case ConnectorNodeDataModel _:
return ConnectorNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
fills: _mapPaintProperty(from.fills),
);
default:
return BaseNodeEntity(
id: from.id ?? '',
key: from.key ?? '',
name: from.name ?? '',
type: from.type ?? '',
);
}
}

List<PaintProperty> _mapPaintProperty(List<PaintPropertyDataModel>? from) =>
PropertyMapper().mapPaintPropertyDataModelToEntity(from ?? []).toList();
}
Loading

0 comments on commit 22b1c40

Please sign in to comment.