106 lines
2.4 KiB
Dart
106 lines
2.4 KiB
Dart
// Flutter imports:
|
|
import 'package:flutter/material.dart';
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
// Package imports:
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
|
import 'package:remever/common/resources.dart';
|
|
import 'package:remever/components/extensions/context.dart';
|
|
import 'package:remever/router.dart';
|
|
import 'package:remever/services/logs/logs_service.dart';
|
|
import 'package:talker/talker.dart';
|
|
import 'events/events.dart';
|
|
|
|
///
|
|
/// Глобальный навигатор
|
|
///
|
|
AppRouter get globalRouter {
|
|
return GetIt.I.get<AppRouter>();
|
|
}
|
|
|
|
///
|
|
/// Логирование
|
|
///
|
|
LogsService get logger {
|
|
return GetIt.I.get<LogsService>();
|
|
}
|
|
|
|
Talker get talker {
|
|
return GetIt.I.get<Talker>();
|
|
}
|
|
|
|
///
|
|
/// Показ тоста
|
|
///
|
|
void showErrorToast(String text) {
|
|
Fluttertoast.showToast(
|
|
msg: text,
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
gravity: ToastGravity.TOP,
|
|
timeInSecForIosWeb: 1,
|
|
backgroundColor: AppColors.danger,
|
|
textColor: AppColors.white,
|
|
fontSize: 16,
|
|
);
|
|
}
|
|
|
|
void showSuccessToast(String text) {
|
|
Fluttertoast.showToast(
|
|
msg: text,
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
gravity: ToastGravity.TOP,
|
|
timeInSecForIosWeb: 1,
|
|
backgroundColor: AppColors.additional_blue,
|
|
textColor: AppColors.white,
|
|
fontSize: 16,
|
|
);
|
|
}
|
|
|
|
///
|
|
/// Глобальный показ ошибки
|
|
///
|
|
void showErrorNotification(String text, [SnackBarAction? action]) {
|
|
eventBus.fire(
|
|
NotificationEvent(
|
|
text: text,
|
|
type: NotificationEventType.ERROR,
|
|
action: action,
|
|
),
|
|
);
|
|
}
|
|
|
|
///
|
|
/// Глобальный показ уведомления
|
|
///
|
|
void showInfoNoitification(String text, [SnackBarAction? action]) {
|
|
eventBus.fire(
|
|
NotificationEvent(
|
|
text: text,
|
|
type: NotificationEventType.NOTIFY,
|
|
action: action,
|
|
),
|
|
);
|
|
}
|
|
|
|
///
|
|
/// Показ диалога как cupertino
|
|
///
|
|
Future<T?> showCuperModalBottomSheet<T>({
|
|
required BuildContext context,
|
|
required WidgetBuilder builder,
|
|
Color? backgroundColor,
|
|
double? height,
|
|
}) {
|
|
return showCupertinoModalBottomSheet(
|
|
topRadius: const Radius.circular(24).r,
|
|
backgroundColor: backgroundColor ?? AppColors.white,
|
|
context: context,
|
|
builder:
|
|
(BuildContext _) => SizedBox(
|
|
height: height ?? MediaQuery.of(context).size.height / 2,
|
|
child: Builder(builder: builder),
|
|
),
|
|
);
|
|
}
|