Merge pull request 'main' (#37) from main into diary_refactor
Reviewed-on: maxxkim/eatvio_app#37
This commit is contained in:
@@ -84,8 +84,8 @@ jobs:
|
|||||||
- name: Native Analyze
|
- name: Native Analyze
|
||||||
run: flutter analyze
|
run: flutter analyze
|
||||||
|
|
||||||
- name: Run Code Metrics
|
#- name: Run Code Metrics
|
||||||
run: flutter pub run dart_code_metrics:metrics lib --disable-sunset-warning --fatal-warnings --fatal-performance
|
# run: flutter pub run dart_code_metrics:metrics lib --disable-sunset-warning --fatal-warnings --fatal-performance
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
8
Makefile
Normal file
8
Makefile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
run-tests:
|
||||||
|
flutter test
|
||||||
|
|
||||||
|
run-analyse:
|
||||||
|
flutter analyze
|
||||||
|
|
||||||
|
run-checks: run-analyse run-tests
|
||||||
@@ -5,7 +5,7 @@ import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart';
|
|||||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart';
|
import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart';
|
||||||
import 'package:eatvio_app/presentation/diets/diet_create_screen/diet_create_screen.dart';
|
import 'package:eatvio_app/presentation/diets/diet_create_screen/diet_create_screen.dart';
|
||||||
import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_screen.dart';
|
import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_screen.dart';
|
||||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart';
|
import 'package:eatvio_app/features/blog_post_create/presentation/pages/blog_post_create_screen.dart';
|
||||||
import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart';
|
import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart';
|
||||||
import 'package:eatvio_app/features/blog_post/presentation/pages/blog_post_screen.dart';
|
import 'package:eatvio_app/features/blog_post/presentation/pages/blog_post_screen.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'package:eatvio_app/core/app_export.dart';
|
|||||||
import 'package:eatvio_app/core/initialization_cubit/initialization_state.dart';
|
import 'package:eatvio_app/core/initialization_cubit/initialization_state.dart';
|
||||||
import 'package:eatvio_app/core/token_storage.dart';
|
import 'package:eatvio_app/core/token_storage.dart';
|
||||||
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
|
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
|
||||||
import 'package:pusher_client/pusher_client.dart';
|
|
||||||
|
|
||||||
class InitializationCubit extends Cubit<InitializationState> {
|
class InitializationCubit extends Cubit<InitializationState> {
|
||||||
final ChatRepository chatRepository;
|
final ChatRepository chatRepository;
|
||||||
@@ -12,40 +11,48 @@ class InitializationCubit extends Cubit<InitializationState> {
|
|||||||
runInitialization() async {
|
runInitialization() async {
|
||||||
try {
|
try {
|
||||||
await TokenStorage.haveTokenInStorage();
|
await TokenStorage.haveTokenInStorage();
|
||||||
|
// final wsUrl = await chatRepository.getWebsocket();
|
||||||
final wsUrl = await chatRepository.getWebsocket();
|
// final options = PusherChannelsOptions.fromHost(
|
||||||
|
// scheme: 'wss',
|
||||||
PusherOptions options = PusherOptions(
|
// key: wsUrl.key,
|
||||||
host: 'socket.mobile-stage.eatvio.ru',
|
// host: wsUrl.host,
|
||||||
wsPort: 443,
|
// shouldSupplyMetadataQueries: true,
|
||||||
encrypted: true,
|
// metadata: PusherChannelsOptionsMetadata.byDefault(),
|
||||||
auth: PusherAuth(
|
// port: 443,
|
||||||
'wss://' + wsUrl.host + '/app/' + wsUrl.key,
|
// );
|
||||||
headers: {
|
// final client = PusherChannelsClient.websocket(
|
||||||
'Authorization': 'Bearer ${TokenStorage.getTokenFromStorage()}',
|
// options: options,
|
||||||
},
|
// connectionErrorHandler: (exception, trace, refresh) {
|
||||||
),
|
// refresh();
|
||||||
);
|
// },
|
||||||
|
// minimumReconnectDelayDuration: const Duration(
|
||||||
PusherClient pusherClient = PusherClient(
|
// seconds: 1,
|
||||||
wsUrl.key,
|
// ),
|
||||||
options,
|
// defaultActivityDuration: const Duration(
|
||||||
autoConnect: true,
|
// seconds: 120,
|
||||||
enableLogging: true,
|
// ),
|
||||||
);
|
// activityDurationOverride: const Duration(
|
||||||
|
// seconds: 120,
|
||||||
await pusherClient.connect();
|
// ),
|
||||||
|
// waitForPongDuration: const Duration(
|
||||||
|
// seconds: 30,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// await client.connect();
|
||||||
|
// final myPrivateChannel = client.privateChannel(
|
||||||
|
// 'private-message-events.${wsUrl.userId}',
|
||||||
|
// authorizationDelegate: EndpointAuthorizableChannelTokenAuthorizationDelegate.forPrivateChannel(
|
||||||
|
// authorizationEndpoint: Uri.parse('https://mobile-stage.eatvio.ru/broadcasting/auth'),
|
||||||
|
// headers: {
|
||||||
|
// 'Authorization' : 'Bearer ${await TokenStorage.getTokenFromStorage()}',
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// myPrivateChannel.subscribe();
|
||||||
|
// myPrivateChannel.bindToAll().listen((event) {
|
||||||
|
// print(event.name);
|
||||||
|
// });
|
||||||
emit(const InitializationState.success());
|
emit(const InitializationState.success());
|
||||||
|
|
||||||
Channel channel = pusherClient.subscribe('private-direct-chat.' + '7909ea56-7822-4d5f-8892-134bc937127f');
|
|
||||||
|
|
||||||
channel.bind("pusher_internal:subscription_succeeded", (PusherEvent? event) {
|
|
||||||
channel.trigger("pusher_internal:subscription_succeeded", {});
|
|
||||||
});
|
|
||||||
|
|
||||||
channel.registerListener('pusher:subscribe', (data) => print(data.toString()));
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
emit(InitializationState.error(errorMessage: e.toString()));
|
emit(InitializationState.error(errorMessage: e.toString()));
|
||||||
|
|||||||
@@ -18,14 +18,12 @@ abstract class TokenStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> getTokenFromStorage() async =>
|
static Future<String> getTokenFromStorage() async => (await Hive.openBox('token')).get('token');
|
||||||
(await Hive.openBox('token')).get('token');
|
|
||||||
|
|
||||||
static saveTokenInStorage(String token) async {
|
static saveTokenInStorage(String token) async {
|
||||||
(await Hive.openBox('token')).put('token', token);
|
(await Hive.openBox('token')).put('token', token);
|
||||||
_addTokenToDioHeader(token);
|
_addTokenToDioHeader(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static removeTokenInStorage() async =>
|
static removeTokenInStorage() async => (await Hive.openBox('token')).delete('token');
|
||||||
(await Hive.openBox('token')).delete('token');
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
part 'blog_post_create_credentials_model.freezed.dart';
|
part '../../../presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.freezed.dart';
|
||||||
part 'blog_post_create_credentials_model.g.dart';
|
part '../../../presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.g.dart';
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class BlogPostCreateCredentialsModel with _$BlogPostCreateCredentialsModel {
|
class BlogPostCreateCredentialsModel with _$BlogPostCreateCredentialsModel {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'bloc/blog_post_create_bloc.dart';
|
import '../../../../presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart';
|
||||||
import 'models/blog_post_create_model.dart';
|
import '../../../../presentation/feed/blog_post_create_screen/models/blog_post_create_model.dart';
|
||||||
import 'package:eatvio_app/core/app_export.dart';
|
import 'package:eatvio_app/core/app_export.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.dart';
|
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/services/blog_service.dart';
|
import 'package:eatvio_app/features/blog_post_create/services/blog_service.dart';
|
||||||
|
|
||||||
class BlogRepository {
|
class BlogRepository {
|
||||||
final BlogService blogService;
|
final BlogService blogService;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/models/blog_post_create_credentials_model.dart';
|
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:retrofit/retrofit.dart';
|
import 'package:retrofit/retrofit.dart';
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@ class WebsocketInfoModel with _$WebsocketInfoModel {
|
|||||||
required String key,
|
required String key,
|
||||||
required String host,
|
required String host,
|
||||||
required String port,
|
required String port,
|
||||||
|
required String cluster,
|
||||||
|
@JsonKey(name: 'user_id')
|
||||||
|
required int userId,
|
||||||
}) = _WebsocketInfoModel;
|
}) = _WebsocketInfoModel;
|
||||||
|
|
||||||
factory WebsocketInfoModel.fromJson(Map<String, Object?> json) => _$WebsocketInfoModelFromJson(json);
|
factory WebsocketInfoModel.fromJson(Map<String, Object?> json) => _$WebsocketInfoModelFromJson(json);
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ mixin _$WebsocketInfoModel {
|
|||||||
String get key => throw _privateConstructorUsedError;
|
String get key => throw _privateConstructorUsedError;
|
||||||
String get host => throw _privateConstructorUsedError;
|
String get host => throw _privateConstructorUsedError;
|
||||||
String get port => throw _privateConstructorUsedError;
|
String get port => throw _privateConstructorUsedError;
|
||||||
|
String get cluster => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: 'user_id')
|
||||||
|
int get userId => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@@ -36,7 +39,12 @@ abstract class $WebsocketInfoModelCopyWith<$Res> {
|
|||||||
WebsocketInfoModel value, $Res Function(WebsocketInfoModel) then) =
|
WebsocketInfoModel value, $Res Function(WebsocketInfoModel) then) =
|
||||||
_$WebsocketInfoModelCopyWithImpl<$Res, WebsocketInfoModel>;
|
_$WebsocketInfoModelCopyWithImpl<$Res, WebsocketInfoModel>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String key, String host, String port});
|
$Res call(
|
||||||
|
{String key,
|
||||||
|
String host,
|
||||||
|
String port,
|
||||||
|
String cluster,
|
||||||
|
@JsonKey(name: 'user_id') int userId});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -55,6 +63,8 @@ class _$WebsocketInfoModelCopyWithImpl<$Res, $Val extends WebsocketInfoModel>
|
|||||||
Object? key = null,
|
Object? key = null,
|
||||||
Object? host = null,
|
Object? host = null,
|
||||||
Object? port = null,
|
Object? port = null,
|
||||||
|
Object? cluster = null,
|
||||||
|
Object? userId = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
key: null == key
|
key: null == key
|
||||||
@@ -69,6 +79,14 @@ class _$WebsocketInfoModelCopyWithImpl<$Res, $Val extends WebsocketInfoModel>
|
|||||||
? _value.port
|
? _value.port
|
||||||
: port // ignore: cast_nullable_to_non_nullable
|
: port // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
cluster: null == cluster
|
||||||
|
? _value.cluster
|
||||||
|
: cluster // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
userId: null == userId
|
||||||
|
? _value.userId
|
||||||
|
: userId // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
) as $Val);
|
) as $Val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +99,12 @@ abstract class _$$WebsocketInfoModelImplCopyWith<$Res>
|
|||||||
__$$WebsocketInfoModelImplCopyWithImpl<$Res>;
|
__$$WebsocketInfoModelImplCopyWithImpl<$Res>;
|
||||||
@override
|
@override
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String key, String host, String port});
|
$Res call(
|
||||||
|
{String key,
|
||||||
|
String host,
|
||||||
|
String port,
|
||||||
|
String cluster,
|
||||||
|
@JsonKey(name: 'user_id') int userId});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -98,6 +121,8 @@ class __$$WebsocketInfoModelImplCopyWithImpl<$Res>
|
|||||||
Object? key = null,
|
Object? key = null,
|
||||||
Object? host = null,
|
Object? host = null,
|
||||||
Object? port = null,
|
Object? port = null,
|
||||||
|
Object? cluster = null,
|
||||||
|
Object? userId = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$WebsocketInfoModelImpl(
|
return _then(_$WebsocketInfoModelImpl(
|
||||||
key: null == key
|
key: null == key
|
||||||
@@ -112,6 +137,14 @@ class __$$WebsocketInfoModelImplCopyWithImpl<$Res>
|
|||||||
? _value.port
|
? _value.port
|
||||||
: port // ignore: cast_nullable_to_non_nullable
|
: port // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
cluster: null == cluster
|
||||||
|
? _value.cluster
|
||||||
|
: cluster // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
userId: null == userId
|
||||||
|
? _value.userId
|
||||||
|
: userId // ignore: cast_nullable_to_non_nullable
|
||||||
|
as int,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +153,11 @@ class __$$WebsocketInfoModelImplCopyWithImpl<$Res>
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class _$WebsocketInfoModelImpl implements _WebsocketInfoModel {
|
class _$WebsocketInfoModelImpl implements _WebsocketInfoModel {
|
||||||
const _$WebsocketInfoModelImpl(
|
const _$WebsocketInfoModelImpl(
|
||||||
{required this.key, required this.host, required this.port});
|
{required this.key,
|
||||||
|
required this.host,
|
||||||
|
required this.port,
|
||||||
|
required this.cluster,
|
||||||
|
@JsonKey(name: 'user_id') required this.userId});
|
||||||
|
|
||||||
factory _$WebsocketInfoModelImpl.fromJson(Map<String, dynamic> json) =>
|
factory _$WebsocketInfoModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
_$$WebsocketInfoModelImplFromJson(json);
|
_$$WebsocketInfoModelImplFromJson(json);
|
||||||
@@ -131,10 +168,15 @@ class _$WebsocketInfoModelImpl implements _WebsocketInfoModel {
|
|||||||
final String host;
|
final String host;
|
||||||
@override
|
@override
|
||||||
final String port;
|
final String port;
|
||||||
|
@override
|
||||||
|
final String cluster;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'user_id')
|
||||||
|
final int userId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'WebsocketInfoModel(key: $key, host: $host, port: $port)';
|
return 'WebsocketInfoModel(key: $key, host: $host, port: $port, cluster: $cluster, userId: $userId)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -144,12 +186,15 @@ class _$WebsocketInfoModelImpl implements _WebsocketInfoModel {
|
|||||||
other is _$WebsocketInfoModelImpl &&
|
other is _$WebsocketInfoModelImpl &&
|
||||||
(identical(other.key, key) || other.key == key) &&
|
(identical(other.key, key) || other.key == key) &&
|
||||||
(identical(other.host, host) || other.host == host) &&
|
(identical(other.host, host) || other.host == host) &&
|
||||||
(identical(other.port, port) || other.port == port));
|
(identical(other.port, port) || other.port == port) &&
|
||||||
|
(identical(other.cluster, cluster) || other.cluster == cluster) &&
|
||||||
|
(identical(other.userId, userId) || other.userId == userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, key, host, port);
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, key, host, port, cluster, userId);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
@@ -168,9 +213,12 @@ class _$WebsocketInfoModelImpl implements _WebsocketInfoModel {
|
|||||||
|
|
||||||
abstract class _WebsocketInfoModel implements WebsocketInfoModel {
|
abstract class _WebsocketInfoModel implements WebsocketInfoModel {
|
||||||
const factory _WebsocketInfoModel(
|
const factory _WebsocketInfoModel(
|
||||||
{required final String key,
|
{required final String key,
|
||||||
required final String host,
|
required final String host,
|
||||||
required final String port}) = _$WebsocketInfoModelImpl;
|
required final String port,
|
||||||
|
required final String cluster,
|
||||||
|
@JsonKey(name: 'user_id') required final int userId}) =
|
||||||
|
_$WebsocketInfoModelImpl;
|
||||||
|
|
||||||
factory _WebsocketInfoModel.fromJson(Map<String, dynamic> json) =
|
factory _WebsocketInfoModel.fromJson(Map<String, dynamic> json) =
|
||||||
_$WebsocketInfoModelImpl.fromJson;
|
_$WebsocketInfoModelImpl.fromJson;
|
||||||
@@ -182,6 +230,11 @@ abstract class _WebsocketInfoModel implements WebsocketInfoModel {
|
|||||||
@override
|
@override
|
||||||
String get port;
|
String get port;
|
||||||
@override
|
@override
|
||||||
|
String get cluster;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'user_id')
|
||||||
|
int get userId;
|
||||||
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
_$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith =>
|
_$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ _$WebsocketInfoModelImpl _$$WebsocketInfoModelImplFromJson(
|
|||||||
key: json['key'] as String,
|
key: json['key'] as String,
|
||||||
host: json['host'] as String,
|
host: json['host'] as String,
|
||||||
port: json['port'] as String,
|
port: json['port'] as String,
|
||||||
|
cluster: json['cluster'] as String,
|
||||||
|
userId: (json['user_id'] as num).toInt(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$$WebsocketInfoModelImplToJson(
|
Map<String, dynamic> _$$WebsocketInfoModelImplToJson(
|
||||||
@@ -20,4 +22,6 @@ Map<String, dynamic> _$$WebsocketInfoModelImplToJson(
|
|||||||
'key': instance.key,
|
'key': instance.key,
|
||||||
'host': instance.host,
|
'host': instance.host,
|
||||||
'port': instance.port,
|
'port': instance.port,
|
||||||
|
'cluster': instance.cluster,
|
||||||
|
'user_id': instance.userId,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -190,12 +190,12 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
|||||||
final recommendedChartValues =
|
final recommendedChartValues =
|
||||||
jsonDecode(responseChart.body)['dailyNutritionRecommendation']
|
jsonDecode(responseChart.body)['dailyNutritionRecommendation']
|
||||||
.values
|
.values
|
||||||
.map<int>((value) => value as int)
|
.map<double>((value) => value as double)
|
||||||
.toList();
|
.toList();
|
||||||
final consumedChartValues =
|
final consumedChartValues =
|
||||||
jsonDecode(responseChart.body)['dailyNutritionIntake']
|
jsonDecode(responseChart.body)['dailyNutritionIntake']
|
||||||
.values
|
.values
|
||||||
.map<int>((value) => value as int)
|
.map<double>((value) => value as double)
|
||||||
.toList();
|
.toList();
|
||||||
return [recommendedChartValues, consumedChartValues];
|
return [recommendedChartValues, consumedChartValues];
|
||||||
} else {
|
} else {
|
||||||
@@ -275,10 +275,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
|||||||
moderationExpanded: false,
|
moderationExpanded: false,
|
||||||
token: token,
|
token: token,
|
||||||
recommendedChartValues: recommendedChartValues.values
|
recommendedChartValues: recommendedChartValues.values
|
||||||
.map<int>((value) => value as int)
|
.map<double>((value) => value as double)
|
||||||
.toList(),
|
.toList(),
|
||||||
consumedChartValues: consumedChartValues.values
|
consumedChartValues: consumedChartValues.values
|
||||||
.map<int>((value) => value as int)
|
.map<double>((value) => value as double)
|
||||||
.toList(),
|
.toList(),
|
||||||
meals: diary['meals'],
|
meals: diary['meals'],
|
||||||
portions: diary['meals'][0]['portions'],
|
portions: diary['meals'][0]['portions'],
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ class DiaryEditLoadedState extends DiaryEditState {
|
|||||||
List<dynamic>? portions;
|
List<dynamic>? portions;
|
||||||
List<dynamic>? photos;
|
List<dynamic>? photos;
|
||||||
List<dynamic>? autocompleteList;
|
List<dynamic>? autocompleteList;
|
||||||
List<int> recommendedChartValues;
|
List<double> recommendedChartValues;
|
||||||
List<int> consumedChartValues;
|
List<double> consumedChartValues;
|
||||||
SelectionPopupModel? currentMeal;
|
SelectionPopupModel? currentMeal;
|
||||||
SelectionPopupModel? portionController;
|
SelectionPopupModel? portionController;
|
||||||
TimeOfDay? wakeupController;
|
TimeOfDay? wakeupController;
|
||||||
@@ -117,8 +117,8 @@ class DiaryEditLoadedState extends DiaryEditState {
|
|||||||
SelectionPopupModel? portionController,
|
SelectionPopupModel? portionController,
|
||||||
String? diaryDate,
|
String? diaryDate,
|
||||||
String? token,
|
String? token,
|
||||||
List<int>? recommendedChartValues,
|
List<double>? recommendedChartValues,
|
||||||
List<int>? consumedChartValues,
|
List<double>? consumedChartValues,
|
||||||
List<dynamic>? meals,
|
List<dynamic>? meals,
|
||||||
List<dynamic>? portions,
|
List<dynamic>? portions,
|
||||||
List<dynamic>? photos,
|
List<dynamic>? photos,
|
||||||
|
|||||||
@@ -720,8 +720,8 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildNutritionChart(BuildContext context, DiaryEditLoadedState state) {
|
_buildNutritionChart(BuildContext context, DiaryEditLoadedState state) {
|
||||||
final List<int> recommendedValues = state.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы
|
final List<double> recommendedValues = state.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы
|
||||||
final List<int> consumedValues = state.consumedChartValues; //
|
final List<double> consumedValues = state.consumedChartValues; //
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
@@ -1196,7 +1196,7 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkConsumedValues(List<int> recommendedValues, List<int> consumedValues) {
|
bool checkConsumedValues(List<double> recommendedValues, List<double> consumedValues) {
|
||||||
for (int i = 0; i < recommendedValues.length; i++) {
|
for (int i = 0; i < recommendedValues.length; i++) {
|
||||||
if (consumedValues[i] > recommendedValues[i]) {
|
if (consumedValues[i] > recommendedValues[i]) {
|
||||||
// Если хотя бы одно потребленное значение превышает рекомендованное
|
// Если хотя бы одно потребленное значение превышает рекомендованное
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
part of 'blog_post_create_credentials_model.dart';
|
part of '../../../../features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// FreezedGenerator
|
// FreezedGenerator
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
part of 'blog_post_create_credentials_model.dart';
|
part of '../../../../features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
|
|||||||
26
package-lock.json
generated
Normal file
26
package-lock.json
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "eatvio_app",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "eatvio_app",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"simple-git-hooks": "^2.11.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/simple-git-hooks": {
|
||||||
|
"version": "2.11.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/simple-git-hooks/-/simple-git-hooks-2.11.1.tgz",
|
||||||
|
"integrity": "sha512-tgqwPUMDcNDhuf1Xf6KTUsyeqGdgKMhzaH4PAZZuzguOgTl5uuyeYe/8mWgAr6IBxB5V06uqEf6Dy37gIWDtDg==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"bin": {
|
||||||
|
"simple-git-hooks": "cli.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "eatvio_app",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "- Flutter (Channel stable, 3.19.0, on Ubuntu 22.04.3 LTS 6.2.0-39-generic, locale en_US.UTF-8) - Android Studio (version 2023.1) - VS Code (version 1.85.0) - Android SDK (version 34.0.0) - устанавливается из Android Studio (Tools->SDK Manager->Android Command Line Tools) - Эмулятор (2 available)",
|
||||||
|
"main": "index.js",
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib",
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"simple-git-hooks": "^2.11.1"
|
||||||
|
},
|
||||||
|
"simple-git-hooks": {
|
||||||
|
"pre-push": "make run-checks",
|
||||||
|
"preserveUnused": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,10 +59,8 @@ dependencies:
|
|||||||
get_it: ^7.7.0
|
get_it: ^7.7.0
|
||||||
# http request
|
# http request
|
||||||
dio: ^5.4.3+1
|
dio: ^5.4.3+1
|
||||||
# websocket
|
# pusher
|
||||||
pusher_client:
|
dart_pusher_channels: ^1.2.2+1
|
||||||
git:
|
|
||||||
url: https://github.com/bihim/pusher_client
|
|
||||||
# photo gallery viewer + dismissible page
|
# photo gallery viewer + dismissible page
|
||||||
photo_view: ^0.15.0
|
photo_view: ^0.15.0
|
||||||
dismissible_page: ^1.0.2
|
dismissible_page: ^1.0.2
|
||||||
@@ -70,8 +68,6 @@ dependencies:
|
|||||||
url_launcher: ^6.3.0
|
url_launcher: ^6.3.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
dart_code_metrics: ^5.7.6
|
|
||||||
dart_code_metrics_presets: ^1.8.0
|
|
||||||
build_runner: ^2.4.11
|
build_runner: ^2.4.11
|
||||||
freezed: ^2.5.2
|
freezed: ^2.5.2
|
||||||
json_serializable: ^6.8.0
|
json_serializable: ^6.8.0
|
||||||
|
|||||||
Reference in New Issue
Block a user