4 Commits

Author SHA1 Message Date
Artem Luzin m
ead44f1b1a feat: добавить визуальный элемент 2025-06-17 20:44:23 +07:00
Artem Luzin m
f64f63641e fix: исправил ширину строки 2025-06-17 20:25:24 +07:00
Artem Luzin m
3895b9a7fc fix 2025-06-17 20:09:34 +07:00
Artem Luzin m
f7d4c02623 feat 2025-06-17 20:05:59 +07:00
8 changed files with 81 additions and 157 deletions

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:friflex_starter/app/theme/app_colors_scheme.dart';
import 'package:friflex_starter/app/theme/theme_notifier.dart'; import 'package:friflex_starter/app/theme/theme_notifier.dart';
import 'package:friflex_starter/di/di_container.dart'; import 'package:friflex_starter/di/di_container.dart';
import 'package:friflex_starter/l10n/gen/app_localizations.dart'; import 'package:friflex_starter/l10n/gen/app_localizations.dart';
@@ -10,6 +11,9 @@ extension AppContextExt on BuildContext {
/// Метод для получения экземпляра DIContainer /// Метод для получения экземпляра DIContainer
DiContainer get di => read<DiContainer>(); DiContainer get di => read<DiContainer>();
/// Геттер для получения цветовой схемы
AppColors get colors => Theme.of(this).extension<AppColors>()!;
/// Геттер для получения темы /// Геттер для получения темы
ThemeNotifier get theme => read<ThemeNotifier>(); ThemeNotifier get theme => read<ThemeNotifier>();

View File

@@ -1,13 +1,10 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
part 'app_colors_scheme.tailor.dart';
/// {@template app_colors} /// {@template app_colors}
/// Класс, реализующий расширение для добавления токенов в цветовую схему /// Класс, реализующий расширение для добавления токенов в цветовую схему
/// {@endtemplate} /// {@endtemplate}
@TailorMixin(themeGetter: ThemeGetter.onBuildContext) class AppColors extends ThemeExtension<AppColors> with DiagnosticableTreeMixin {
class AppColors extends ThemeExtension<AppColors> with _$AppColorsTailorMixin {
/// {@macro app_colors} /// {@macro app_colors}
/// ///
/// Принимает: /// Принимает:
@@ -26,23 +23,18 @@ class AppColors extends ThemeExtension<AppColors> with _$AppColorsTailorMixin {
}); });
/// Цвет тестовый /// Цвет тестовый
@override
final Color testColor; final Color testColor;
/// Цвет элемента текста /// Цвет элемента текста
@override
final Color itemTextColor; final Color itemTextColor;
/// Цвет фона снекбара ошибки /// Цвет фона снекбара ошибки
@override
final Color errorSnackbarBackground; final Color errorSnackbarBackground;
/// Цвет фона снекбара успеха /// Цвет фона снекбара успеха
@override
final Color successSnackbarBackground; final Color successSnackbarBackground;
/// Цвет фона снекбара информации /// Цвет фона снекбара информации
@override
final Color infoSnackbarBackground; final Color infoSnackbarBackground;
/// Цвета светлой темы /// Цвета светлой темы
@@ -62,4 +54,50 @@ class AppColors extends ThemeExtension<AppColors> with _$AppColorsTailorMixin {
infoSnackbarBackground: const Color.fromARGB(255, 35, 147, 178), infoSnackbarBackground: const Color.fromARGB(255, 35, 147, 178),
itemTextColor: Colors.white, itemTextColor: Colors.white,
); );
@override
ThemeExtension<AppColors> copyWith({
Color? testColor,
Color? errorSnackbarBackground,
Color? successSnackbarBackground,
Color? infoSnackbarBackground,
Color? itemTextColor,
}) => AppColors(
testColor: testColor ?? this.testColor,
errorSnackbarBackground:
errorSnackbarBackground ?? this.errorSnackbarBackground,
successSnackbarBackground:
successSnackbarBackground ?? this.successSnackbarBackground,
infoSnackbarBackground:
infoSnackbarBackground ?? this.infoSnackbarBackground,
itemTextColor: itemTextColor ?? this.itemTextColor,
);
@override
ThemeExtension<AppColors> lerp(
covariant ThemeExtension<AppColors>? other,
double t,
) {
if (other is! AppColors) return this;
return AppColors(
testColor: Color.lerp(testColor, other.testColor, t)!,
errorSnackbarBackground: Color.lerp(
errorSnackbarBackground,
other.errorSnackbarBackground,
t,
)!,
successSnackbarBackground: Color.lerp(
successSnackbarBackground,
other.successSnackbarBackground,
t,
)!,
infoSnackbarBackground: Color.lerp(
infoSnackbarBackground,
other.infoSnackbarBackground,
t,
)!,
itemTextColor: Color.lerp(itemTextColor, other.itemTextColor, t)!,
);
}
} }

View File

@@ -1,102 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// 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
part of 'app_colors_scheme.dart';
// **************************************************************************
// TailorAnnotationsGenerator
// **************************************************************************
mixin _$AppColorsTailorMixin on ThemeExtension<AppColors> {
Color get testColor;
Color get itemTextColor;
Color get errorSnackbarBackground;
Color get successSnackbarBackground;
Color get infoSnackbarBackground;
@override
AppColors copyWith({
Color? testColor,
Color? itemTextColor,
Color? errorSnackbarBackground,
Color? successSnackbarBackground,
Color? infoSnackbarBackground,
}) {
return AppColors(
testColor: testColor ?? this.testColor,
itemTextColor: itemTextColor ?? this.itemTextColor,
errorSnackbarBackground:
errorSnackbarBackground ?? this.errorSnackbarBackground,
successSnackbarBackground:
successSnackbarBackground ?? this.successSnackbarBackground,
infoSnackbarBackground:
infoSnackbarBackground ?? this.infoSnackbarBackground,
);
}
@override
AppColors lerp(covariant ThemeExtension<AppColors>? other, double t) {
if (other is! AppColors) return this as AppColors;
return AppColors(
testColor: Color.lerp(testColor, other.testColor, t)!,
itemTextColor: Color.lerp(itemTextColor, other.itemTextColor, t)!,
errorSnackbarBackground: Color.lerp(
errorSnackbarBackground,
other.errorSnackbarBackground,
t,
)!,
successSnackbarBackground: Color.lerp(
successSnackbarBackground,
other.successSnackbarBackground,
t,
)!,
infoSnackbarBackground: Color.lerp(
infoSnackbarBackground,
other.infoSnackbarBackground,
t,
)!,
);
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is AppColors &&
const DeepCollectionEquality().equals(testColor, other.testColor) &&
const DeepCollectionEquality().equals(
itemTextColor,
other.itemTextColor,
) &&
const DeepCollectionEquality().equals(
errorSnackbarBackground,
other.errorSnackbarBackground,
) &&
const DeepCollectionEquality().equals(
successSnackbarBackground,
other.successSnackbarBackground,
) &&
const DeepCollectionEquality().equals(
infoSnackbarBackground,
other.infoSnackbarBackground,
));
}
@override
int get hashCode {
return Object.hash(
runtimeType.hashCode,
const DeepCollectionEquality().hash(testColor),
const DeepCollectionEquality().hash(itemTextColor),
const DeepCollectionEquality().hash(errorSnackbarBackground),
const DeepCollectionEquality().hash(successSnackbarBackground),
const DeepCollectionEquality().hash(infoSnackbarBackground),
);
}
}
extension AppColorsBuildContext on BuildContext {
AppColors get appColors => Theme.of(this).extension<AppColors>()!;
}

View File

@@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:friflex_starter/app/theme/app_colors_scheme.dart'; import 'package:friflex_starter/app/app_context_ext.dart';
import 'package:friflex_starter/app/ui_kit/app_box.dart'; import 'package:friflex_starter/app/ui_kit/app_box.dart';
/// {@template app_snackbar} /// {@template app_snackbar}
@@ -264,9 +264,9 @@ class _AppSnackBarState extends State<AppSnackBar>
/// [TypeSnackBar.error] - цвет ошибки /// [TypeSnackBar.error] - цвет ошибки
Color _getBackgroundColor(TypeSnackBar type) { Color _getBackgroundColor(TypeSnackBar type) {
return switch (type) { return switch (type) {
TypeSnackBar.success => context.appColors.successSnackbarBackground, TypeSnackBar.success => context.colors.successSnackbarBackground,
TypeSnackBar.error => context.appColors.errorSnackbarBackground, TypeSnackBar.error => context.colors.errorSnackbarBackground,
TypeSnackBar.info => context.appColors.infoSnackbarBackground, TypeSnackBar.info => context.colors.infoSnackbarBackground,
}; };
} }
} }

View File

@@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:friflex_starter/app/app_context_ext.dart'; import 'package:friflex_starter/app/app_context_ext.dart';
import 'package:friflex_starter/app/theme/app_colors_scheme.dart';
import 'package:friflex_starter/gen/assets.gen.dart'; import 'package:friflex_starter/gen/assets.gen.dart';
import 'package:friflex_starter/gen/fonts.gen.dart'; import 'package:friflex_starter/gen/fonts.gen.dart';
@@ -37,7 +36,7 @@ class LangScreen extends StatelessWidget {
Text( Text(
'Тестовое слово bold: ${context.l10n.helloWorld}', 'Тестовое слово bold: ${context.l10n.helloWorld}',
style: TextStyle( style: TextStyle(
color: context.appColors.testColor, color: context.colors.testColor,
fontFamily: Assets.fonts.montserratBold, fontFamily: Assets.fonts.montserratBold,
), ),
), ),
@@ -45,7 +44,7 @@ class LangScreen extends StatelessWidget {
Text( Text(
'Тестовое слово medium: ${context.l10n.helloWorld}', 'Тестовое слово medium: ${context.l10n.helloWorld}',
style: TextStyle( style: TextStyle(
color: context.appColors.testColor, color: context.colors.testColor,
fontFamily: FontFamily.montserrat, fontFamily: FontFamily.montserrat,
), ),
), ),

View File

@@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:friflex_starter/app/app_context_ext.dart'; import 'package:friflex_starter/app/app_context_ext.dart';
import 'package:friflex_starter/app/theme/app_colors_scheme.dart';
/// {@template ThemeScreen} /// {@template ThemeScreen}
/// Экран для отладки темы приложения /// Экран для отладки темы приложения
@@ -11,7 +10,7 @@ class ThemeScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final colors = context.appColors; final colors = context.colors;
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('Theme')), appBar: AppBar(title: const Text('Theme')),
body: Center( body: Center(
@@ -26,7 +25,7 @@ class ThemeScreen extends StatelessWidget {
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
ColoredBox( ColoredBox(
color: context.appColors.testColor, color: context.colors.testColor,
child: const SizedBox(height: 100, width: 100), child: const SizedBox(height: 100, width: 100),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),

View File

@@ -5,18 +5,23 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: _fe_analyzer_shared name: _fe_analyzer_shared
sha256: e55636ed79578b9abca5fecf9437947798f5ef7456308b5cb85720b793eac92f sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "82.0.0" version: "76.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.3"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
name: analyzer name: analyzer
sha256: "904ae5bb474d32c38fb9482e2d925d5454cda04ddd0e55d2e6826bc72f6ba8c0" sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.4.5" version: "6.11.0"
ansicolor: ansicolor:
dependency: transitive dependency: transitive
description: description:
@@ -220,10 +225,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: dart_style name: dart_style
sha256: "5b236382b47ee411741447c1f1e111459c941ea1b3f2b540dde54c210a3662af" sha256: "7306ab8a2359a48d22310ad823521d723acfed60ee1f7e37388e8986853b6820"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.0" version: "2.3.8"
dartx: dartx:
dependency: transitive dependency: transitive
description: description:
@@ -587,6 +592,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.1" version: "3.3.1"
macros:
dependency: transitive
description:
name: macros
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
url: "https://pub.dev"
source: hosted
version: "0.1.3-main.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@@ -868,18 +881,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_gen name: source_gen
sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "1.5.0"
source_helper:
dependency: transitive
description:
name: source_helper
sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c"
url: "https://pub.dev"
source: hosted
version: "1.3.5"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@@ -984,22 +989,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.4" version: "0.7.4"
theme_tailor:
dependency: "direct dev"
description:
name: theme_tailor
sha256: ba98be1d04856deef932757a3ca8fa7a5e2a6f96c30466a59c48924eeb608b97
url: "https://pub.dev"
source: hosted
version: "3.0.3"
theme_tailor_annotation:
dependency: "direct main"
description:
name: theme_tailor_annotation
sha256: "0d5ecd13a6a52add2082aa60497179f6093acf482eb69e7fa3a9f37eb990ac34"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
time: time:
dependency: transitive dependency: transitive
description: description:

View File

@@ -32,8 +32,6 @@ dependencies:
equatable: 2.0.7 equatable: 2.0.7
theme_tailor_annotation: 3.0.2
### основной сервис с интерфейсами ### основной сервис с интерфейсами
i_app_services: i_app_services:
path: ./app_services/i_app_services path: ./app_services/i_app_services
@@ -52,7 +50,6 @@ dev_dependencies:
flutter_gen_runner: 5.10.0 flutter_gen_runner: 5.10.0
flutter_gen: 5.10.0 flutter_gen: 5.10.0
flutter_lints: 6.0.0 flutter_lints: 6.0.0
theme_tailor: 3.0.3
flutter: flutter:
uses-material-design: true uses-material-design: true