87 lines
3.7 KiB
Dart
87 lines
3.7 KiB
Dart
import 'package:birzha/services/helpers.dart';
|
|
import 'package:birzha/core/adaptix/adaptix.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_html/flutter_html.dart';
|
|
|
|
const kBannerAssetRatio = 1161 / 500;
|
|
const kProductAspectRatio = 189 / 357;
|
|
|
|
typedef VoidWithParam<T> = void Function(T);
|
|
|
|
abstract class AppConstants {
|
|
static const appColor = Color.fromRGBO(0, 49, 151, 1);
|
|
static const backgroundColor = Colors.white;
|
|
static const kDefaultLanguage = 'tk';
|
|
static const scaffoldColorLight = const Color.fromRGBO(242, 245, 255, 1);
|
|
static const supprtedLocales = [const Locale('en', 'US'), const Locale('ru'), const Locale('tk')];
|
|
static double get appBarHeight => clearAppBarHeight + Adaptix.systemPadding.top;
|
|
static double get clearAppBarHeight => 50.adaptedPx();
|
|
static double get appBarIconSize => clearAppBarHeight / 2.3;
|
|
static double get appBarFontSize => clearAppBarHeight * 0.29;
|
|
static double get b2FontSize => 13.2.adaptedPx();
|
|
static double get b3FontSize => 12.95.adaptedPx();
|
|
static double get h2FontSize => 14.adaptedPx();
|
|
static double get h1FontSize => 16.adaptedPx();
|
|
static double get h3FontSize => 13.8.adaptedPx();
|
|
static const int pageLimit = 20;
|
|
static int categoryAxisCount(BuildContext context) {
|
|
return Resizer(small: 2, large: 3, xlarge: 3, totalWidth: MediaQuery.of(context).size.width).value;
|
|
}
|
|
|
|
static double horizontalPadding(BuildContext context) => MediaQuery.of(context).size.width * 0.04;
|
|
static double verticalPadding(BuildContext context) => 20.adaptedPx();
|
|
|
|
static int productAxisCount(BuildContext context) {
|
|
return Resizer(small: 2, large: 3, xlarge: 3, totalWidth: MediaQuery.of(context).size.width).value;
|
|
}
|
|
|
|
static SliverGridDelegate productsGridDelegate(BuildContext context) {
|
|
return SliverGridDelegateWithFixedCrossAxisCount(
|
|
childAspectRatio: kProductAspectRatio,
|
|
mainAxisSpacing: horizontalPadding(context),
|
|
crossAxisSpacing: horizontalPadding(context) / 2,
|
|
crossAxisCount: Resizer(small: 2, medium: 2, large: 3, xlarge: 4, totalWidth: MediaQuery.of(context).size.width).value,
|
|
);
|
|
}
|
|
|
|
static double productCarouselHeight(BuildContext context) {
|
|
final fullWidth = MediaQuery.of(context).size.width;
|
|
final divided = fullWidth / productAxisCount(context);
|
|
final clearWidth = divided - ((horizontalPadding(context) / 2) * 1.8);
|
|
return (clearWidth / kProductAspectRatio) / 1.07;
|
|
}
|
|
|
|
static Map<String, Style> htmlContentStyle(BuildContext context) => {
|
|
'*': Style(
|
|
fontSize: FontSize(13.1.adaptedPx()),
|
|
alignment: Alignment.centerLeft,
|
|
textAlign: TextAlign.start,
|
|
margin: EdgeInsets.all(0),
|
|
lineHeight: LineHeight.number(1.2),
|
|
fontFamily: 'Segoe',
|
|
),
|
|
'p': Style(margin: EdgeInsets.only(bottom: 12.adaptedPx())),
|
|
'a': Style(color: Theme.of(context).accentColor)
|
|
};
|
|
|
|
static Map<String, dynamic Function(RenderContext, Widget)> htmlCustomRenderer(BuildContext context) => {
|
|
'a': (elementContext, child) {
|
|
final String? text = elementContext.tree.children.first.toString().replaceAll('"', '');
|
|
final String? url = elementContext.tree.attributes['href'];
|
|
return TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: '$text',
|
|
style: TextStyle(color: Theme.of(context).accentColor, decoration: TextDecoration.underline),
|
|
recognizer: TapGestureRecognizer()
|
|
..onTap = () {
|
|
linkLauncher(url ?? "");
|
|
})
|
|
],
|
|
);
|
|
}
|
|
};
|
|
static const passwordReset = 'https://tmex.gov.tm/ru/password-reset';
|
|
}
|