import 'dart:ui'; import 'dart:convert'; import 'package:workouttest_util/util/app_language.dart'; enum TutorialEnum { basic, development, training } class TutorialStepAction { late String direction; late int top; late int left; late bool showBubble; late int bubbleX; late int bubbleY; late int bubbleWidth; late int bubbleHeight; late bool showCheckText; late int parent; TutorialStepAction.fromJson(Map json) { direction = json['direction']; top = json['top']; left = json['left']; showBubble = json['show_bubble']; bubbleX = json['bubble_x']; bubbleY = json['bubble_y']; bubbleWidth = json['bubble_width']; bubbleHeight = json['bubble_height']; showCheckText = json['show_check_text']; parent = json['parent']; } Map toJson() => { "direction": direction, "top": top, "left": left, "showBubble": showBubble, "bubbleX": bubbleX, "bubbleY": bubbleY, "bubbleWidth": bubbleWidth, "bubbleHeight": bubbleHeight, "showCheckText": showCheckText, "parent": parent, }; @override String toString() => toJson().toString(); } class TutorialStep { int? tutorialStepId; int? tutorialId; int? step; String? tutorialText; String? direction; String? checkText; String? condition; String? branch; int? parentId; TutorialStepAction? action; String? tutorialTextTranslation; String? errorTextTranslation; TutorialStep.fromJson(Map json) { tutorialStepId = json['tutorialStepId']; tutorialId = json['tutorialId']; step = json['step']; tutorialText = json['tutorialText']; checkText = json['checkText']; condition = json['condition']; if (condition != null) { condition = condition!.replaceAll(r'\\', "replace"); action = TutorialStepAction.fromJson(jsonDecode(condition!)); } if (json['translations'] != null && json['translations'].length > 0) { tutorialTextTranslation = AppLanguage().appLocal == const Locale('hu') ? json['translations'][0]['tutorialText'] : json['tutorialText']; errorTextTranslation = AppLanguage().appLocal == const Locale('hu') ? json['translations'][0]['errorText'] : json['errorText']; } } Map toJson() => { "tutorialStepId": tutorialStepId, "tutorialId": tutorialId, "step": step, "tutorialText": tutorialText, "checkText": checkText, "tutorialTextTranslation": tutorialTextTranslation, "errorTextTranslation": errorTextTranslation, "condition": condition, "action": action != null ? action!.toJson() : "" }; @override String toString() => toJson().toString(); }