Skip to content

Commit 306635f

Browse files
committed
feat: basic structure
1 parent 462dd83 commit 306635f

11 files changed

+1081
-30
lines changed

analysis_options.yaml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1-
# This file configures the analyzer, which statically analyzes Dart code to
2-
# check for errors, warnings, and lints.
3-
#
4-
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5-
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6-
# invoked from the command line by running `flutter analyze`.
7-
8-
# The following line activates a set of recommended lints for Flutter apps,
9-
# packages, and plugins designed to encourage good coding practices.
10-
include: package:flutter_lints/flutter.yaml
1+
analyzer:
2+
errors:
3+
public_member_api_docs: ignore
4+
include: package:very_good_analysis/analysis_options.yaml
115

126
linter:
13-
# The lint rules applied to this project can be customized in the
14-
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15-
# included above or to enable additional rules. A list of all available lints
16-
# and their documentation is published at https://dart.dev/lints.
17-
#
18-
# Instead of disabling a lint rule for the entire project in the
19-
# section below, it can also be suppressed for a single line of code
20-
# or a specific dart file by using the `// ignore: name_of_lint` and
21-
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22-
# producing the lint.
237
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26-
27-
# Additional information about this file can be found at
28-
# https://dart.dev/guides/language/analysis-options
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class TrainingsPlannerError {
2+
final String message;
3+
final StackTrace? stackTrace;
4+
5+
TrainingsPlannerError(this.message, {this.stackTrace});
6+
7+
@override
8+
String toString() {
9+
return 'Error{message: $message, ${stackTrace != null ? 'stackTrace: $stackTrace' : ''}}';
10+
}
11+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:trainings_planner/features/home/home_model.dart';
5+
6+
class HomeController extends Cubit<HomeModel> {
7+
HomeController() : super(HomeModel.loading()) {
8+
unawaited(_laodTraining());
9+
}
10+
11+
Future<void> _laodTraining() =>
12+
Future.delayed(const Duration(seconds: 2), () {
13+
emit(
14+
HomeModel.data(
15+
collections: [
16+
HomeModelCollection(
17+
name: 'name',
18+
exercises: [
19+
HomeModelExercise(
20+
id: 'id',
21+
name: 'name',
22+
description: 'description',
23+
material: [],
24+
image: null,
25+
difficulty: 1,
26+
inTraining: false,
27+
),
28+
],
29+
),
30+
],
31+
),
32+
);
33+
});
34+
}

lib/features/home/home_model.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import 'package:freezed_annotation/freezed_annotation.dart';
2+
import 'package:trainings_planner/common/trainings_planner_error.dart';
3+
4+
part 'home_model.freezed.dart';
5+
6+
@freezed
7+
class HomeModel with _$HomeModel {
8+
factory HomeModel.loading() = HomeModelLoading;
9+
factory HomeModel.data({
10+
required List<HomeModelCollection> collections,
11+
}) = HomeModelData;
12+
factory HomeModel.error({
13+
required TrainingsPlannerError error,
14+
}) = HomeModelError;
15+
}
16+
17+
@freezed
18+
class HomeModelCollection with _$HomeModelCollection {
19+
factory HomeModelCollection({
20+
required String name,
21+
required List<HomeModelExercise> exercises,
22+
}) = _HomeModelCollection;
23+
}
24+
25+
@freezed
26+
class HomeModelExercise with _$HomeModelExercise {
27+
factory HomeModelExercise({
28+
required String id,
29+
required String name,
30+
required String description,
31+
required List<String> material,
32+
required String? image,
33+
required int difficulty,
34+
required bool inTraining,
35+
}) = _HomeModelExercise;
36+
}

0 commit comments

Comments
 (0)