Files
mitra-corporate/lib/app/constant.dart
2026-03-26 14:43:42 +07:00

273 lines
7.9 KiB
Dart

import 'package:mitra_corporate/app/route.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:mitra_corporate/model/menu_model.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../model/surat_jalan_model.dart';
import '../widgets/custom_snackbar_widget.dart';
class Constant {
static String baseUrl = "";
static String protocol = "";
static String tokenName = "oneMitraPramita";
static double designHeight = 1024;
static double designWidth = 1440;
static String version = "Versi 1.02";
static String build = "Build 13-12-2024";
// flutter build web --base-href "/mitra/"
static String ipAddress = "";
// //color Theme
// static Color textBlack = Color(0xff212B36);
// static Color textGrey = Color(0xff919EAB);
// static Color textBlue = Color(0xff1939B7);
// static Color textWhite = Color(0xffffffff);
// static Color backgroundColor = Color(0xffFCFAFA);
// static Color primaryBlue = Color(0xff1939B7);
// static Color buttonPrimary1 = Color(0xff1E1BD3);
// static Color buttonPrimary2 = Color(0xff5959FF);
//typoGraphy
static TextStyle h1_700({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 36),
fontWeight: FontWeight.w700,
);
}
static TextStyle h2_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 28),
fontWeight: FontWeight.w600,
);
}
static TextStyle h3_400({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 24),
fontWeight: FontWeight.w600,
);
}
static TextStyle h4_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 18),
fontWeight: FontWeight.w600,
);
}
static TextStyle body1_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 16),
fontWeight: FontWeight.w600,
);
}
static TextStyle body2_400({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 16),
fontWeight: FontWeight.w500,
);
}
static TextStyle body2_700({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 16),
fontWeight: FontWeight.w700,
);
}
static TextStyle body3_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 14),
fontWeight: FontWeight.w600,
);
}
static TextStyle body3_500({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 14),
fontWeight: FontWeight.w500,
);
}
static TextStyle body3_400({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 14),
fontWeight: FontWeight.w400,
);
}
static TextStyle caption1_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 12),
fontWeight: FontWeight.w600,
);
}
static TextStyle caption1_400({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 12),
fontWeight: FontWeight.w400,
);
}
static TextStyle caption2_600({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 10),
fontWeight: FontWeight.w600,
);
}
static TextStyle caption2_400({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 10),
fontWeight: FontWeight.w400,
);
}
static TextStyle button_large({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 15),
fontWeight: FontWeight.w700,
);
}
static TextStyle button_medium({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 14),
fontWeight: FontWeight.w700,
);
}
static TextStyle button_small({required BuildContext context}) {
return TextStyle(
fontSize: Constant.getActualX(context: context, x: 13),
fontWeight: FontWeight.w700,
);
}
//size convertion
static double getActualX({
required BuildContext context,
required double x,
}) {
return x / designWidth * MediaQuery.of(context).size.width;
}
static double getActualY({
required BuildContext context,
required double y,
}) {
return y / designHeight * MediaQuery.of(context).size.height;
}
static String convertToIdr(dynamic number, int decimalDigit) {
NumberFormat currencyFormatter = NumberFormat.currency(
locale: 'id',
symbol: 'Rp ',
decimalDigits: decimalDigit,
);
return currencyFormatter.format(number);
}
//color Theme
static Color textBlack = Color(0xff212B36);
static Color textGrey = Color(0xff637381);
static Color textBlue = Color(0xff1939B7);
static Color textWhite = Color(0xffffffff);
static Color textYellow = Color(0xffB78103);
static Color textGreen = Color(0xff229A16);
static Color textPurple = Color(0xffBF07FF);
static Color backgroundColor = Color(0xffFCFAFA);
static Color primaryBlue = Color(0xff1939B7);
static Color buttonPrimary1 = Color(0xff1E1BD3);
static Color buttonPrimary2 = Color(0xff5959FF);
static Color grey_200 = Color(0xffF4F6F8);
static Color yellow_016 = Color(0xffFFC107).withOpacity(0.16);
static Color green_016 = Color(0xff54D62C).withOpacity(0.16);
static Color blue_016 = Color(0xff1890FF).withOpacity(0.16);
static Color green = Color(0xff00AB55);
static Color purple_016 = Color(0xffbf07ff).withOpacity(0.16);
static Color selectedMenuBg = Color(0xffFF0000).withOpacity(0.1);
//Pramita color
static Color primaryRed = Color(0xffFF0000);
static List<dateFilterModel> dateFilter = [
dateFilterModel(id: "1", name: "Tanggal Surat Jalan"),
dateFilterModel(id: "2", name: "Tanggal Kedatangan"),
];
static List<MenuModel> menuList = [
MenuModel(
icon: EvaIcons.grid,
subValue: [1],
title: "Dashboard",
index: 1,
mainValue: 1),
MenuModel(
icon: EvaIcons.fileAdd,
subValue: [2],
title: "Registrasi Pasien",
index: 2,
mainValue: 2),
MenuModel(
icon: EvaIcons.clipboard,
subValue: [3, 5],
title: "Kirim Order",
index: 3,
mainValue: 3),
MenuModel(
icon: EvaIcons.shoppingCart,
subValue: [6],
title: "List Order",
index: 4,
mainValue: 6),
// MenuModel(
// icon: EvaIcons.fileText,
// subValue: [4, 7],
// title: "Hasil",
// index: 5,
// mainValue: 4),
];
static List<MenuModel> getMenuModel() {
List<MenuModel> data = menuList;
data.sort(
(a, b) => a.index.compareTo(b.index),
);
return data;
}
static autoLogout({
required BuildContext context,
required String msg,
bool? isSplashScreen,
}) async {
if (msg == "Invalid token") {
final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.remove(tokenName);
Navigator.pushNamed(context, loginRoute);
if (isSplashScreen != true) {
SanckbarWidget(
context, "Invalid token, please login again", snackbarType.warning);
}
}
}
static setBaseUrl(String text, String? protocol) {
var prt = protocol;
if (protocol == null) {
prt = "https://";
}
// baseUrl = "$protocol//10.9.20.30/one-api/one_mitra/";
// ipAddress = "devbandungraya.aplikasi.web.id";
// protocol = protocol;
baseUrl = "$protocol//$text/one-api/one_mitra/";
ipAddress = text;
print(baseUrl);
}
}