mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Merge branch 'dev' of https://github.com/SyncrowIOT/web into feature/space-management
This commit is contained in:
@ -5,8 +5,7 @@ abstract class ColorsManager {
|
||||
static const Color switchOffColor = Color(0x7F8D99AE);
|
||||
static const Color primaryColor = Color(0xFF0030CB); //023DFE
|
||||
static const Color secondaryTextColor = Color(0xFF848484);
|
||||
static Color primaryColorWithOpacity =
|
||||
const Color(0xFF023DFE).withOpacity(0.6);
|
||||
static Color primaryColorWithOpacity = const Color(0xFF023DFE).withOpacity(0.6);
|
||||
static const Color whiteColors = Colors.white;
|
||||
static const Color secondaryColor = Color(0xFF023DFE);
|
||||
static const Color onSecondaryColor = Color(0xFF023DFE);
|
||||
@ -52,4 +51,5 @@ abstract class ColorsManager {
|
||||
static const Color spaceColor = Color(0xB2023DFE);
|
||||
static const Color counterBackgroundColor = Color(0xCCF4F4F4);
|
||||
}
|
||||
//0036E6
|
||||
//background: #background: #5D5D5D;
|
||||
|
||||
|
@ -1,69 +1,81 @@
|
||||
abstract class ApiEndpoints {
|
||||
static const String baseUrl = 'http://localhost:4001';
|
||||
//static const String baseUrl = 'http://localhost:4001'; //Localhost
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
//https://syncrow-staging.azurewebsites.net
|
||||
////////////////////////////////////// Authentication ///////////////////////////////
|
||||
static const String signUp = '$baseUrl/authentication/user/signup';
|
||||
static const String login = '$baseUrl/authentication/user/login';
|
||||
static const String forgetPassword =
|
||||
'$baseUrl/authentication/user/forget-password';
|
||||
static const String sendOtp = '$baseUrl/authentication/user/send-otp';
|
||||
static const String verifyOtp = '$baseUrl/authentication/user/verify-otp';
|
||||
static const String getRegion = '$baseUrl/region';
|
||||
static const String visitorPassword = '$baseUrl/visitor-password';
|
||||
static const String getDevices = '$baseUrl/visitor-password/devices';
|
||||
abstract class ApiEndpoints {
|
||||
static String baseUrl = dotenv.env['BASE_URL'] ?? '';
|
||||
static const String signUp = '/authentication/user/signup';
|
||||
static const String login = '/authentication/user/login';
|
||||
static const String forgetPassword = '/authentication/user/forget-password';
|
||||
static const String sendOtp = '/authentication/user/send-otp';
|
||||
static const String verifyOtp = '/authentication/user/verify-otp';
|
||||
static const String getRegion = '/region';
|
||||
static const String visitorPassword = '/visitor-password';
|
||||
static const String getDevices = '/visitor-password/devices';
|
||||
|
||||
static const String sendOnlineOneTime =
|
||||
'$baseUrl/visitor-password/temporary-password/online/one-time';
|
||||
'/visitor-password/temporary-password/online/one-time';
|
||||
static const String sendOnlineMultipleTime =
|
||||
'$baseUrl/visitor-password/temporary-password/online/multiple-time';
|
||||
'/visitor-password/temporary-password/online/multiple-time';
|
||||
|
||||
//offline Password
|
||||
static const String sendOffLineOneTime =
|
||||
'$baseUrl/visitor-password/temporary-password/offline/one-time';
|
||||
'/visitor-password/temporary-password/offline/one-time';
|
||||
static const String sendOffLineMultipleTime =
|
||||
'$baseUrl/visitor-password/temporary-password/offline/multiple-time';
|
||||
'/visitor-password/temporary-password/offline/multiple-time';
|
||||
|
||||
static const String getUser = '$baseUrl/user/{userUuid}';
|
||||
static const String getUser = '/user/{userUuid}';
|
||||
|
||||
////// Devices Management ////////////////
|
||||
|
||||
static const String getAllDevices = '$baseUrl/device';
|
||||
static const String getDeviceStatus =
|
||||
'$baseUrl/device/{uuid}/functions/status';
|
||||
static const String getAllDevices = '/device';
|
||||
static const String getDeviceStatus = '/device/{uuid}/functions/status';
|
||||
static const String getBatchStatus = '/device/status/batch';
|
||||
|
||||
static const String deviceControl = '$baseUrl/device/{uuid}/control';
|
||||
static const String deviceControl = '/device/{uuid}/control';
|
||||
static const String deviceBatchControl = '/device/control/batch';
|
||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||
|
||||
static const String getDeviceLogs =
|
||||
'$baseUrl/device/report-logs/{uuid}?code={code}';
|
||||
'/device/report-logs/{uuid}?code={code}';
|
||||
|
||||
// Space Module
|
||||
static const String createSpace =
|
||||
'$baseUrl/communities/{communityId}/spaces';
|
||||
'/communities/{communityId}/spaces';
|
||||
static const String listSpaces =
|
||||
'$baseUrl/communities/{communityId}/spaces';
|
||||
'/communities/{communityId}/spaces';
|
||||
static const String deleteSpace =
|
||||
'$baseUrl/communities/{communityId}/spaces/{spaceId}';
|
||||
'/communities/{communityId}/spaces/{spaceId}';
|
||||
static const String updateSpace =
|
||||
'$baseUrl/communities/{communityId}/spaces/{spaceId}';
|
||||
'/communities/{communityId}/spaces/{spaceId}';
|
||||
static const String getSpace =
|
||||
'$baseUrl/communities/{communityId}/spaces/{spaceId}';
|
||||
'/communities/{communityId}/spaces/{spaceId}';
|
||||
static const String getSpaceHierarchy =
|
||||
'$baseUrl/communities/{communityId}/spaces/hierarchy';
|
||||
'/communities/{communityId}/spaces/hierarchy';
|
||||
|
||||
// Community Module
|
||||
static const String createCommunity = '$baseUrl/communities';
|
||||
static const String getCommunityList = '$baseUrl/communities';
|
||||
static const String createCommunity = '/communities';
|
||||
static const String getCommunityList = '/communities';
|
||||
static const String getCommunityById =
|
||||
'$baseUrl/communities/{communityId}';
|
||||
'/communities/{communityId}';
|
||||
static const String updateCommunity =
|
||||
'$baseUrl/communities/{communityId}';
|
||||
'/communities/{communityId}';
|
||||
static const String deleteCommunity =
|
||||
'$baseUrl/communities/{communityId}';
|
||||
'/communities/{communityId}';
|
||||
static const String getUserCommunities =
|
||||
'$baseUrl/communities/user/{userUuid}';
|
||||
static const String createUserCommunity = '$baseUrl/communities/user';
|
||||
'/communities/user/{userUuid}';
|
||||
static const String createUserCommunity = '/communities/user';
|
||||
static const String getDeviceLogsByDate =
|
||||
'/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
||||
|
||||
static const String scheduleByDeviceId = '/schedule/{deviceUuid}';
|
||||
static const String getScheduleByDeviceId =
|
||||
'/schedule/{deviceUuid}?category={category}';
|
||||
static const String deleteScheduleByDeviceId =
|
||||
'/schedule/{deviceUuid}/{scheduleUuid}';
|
||||
static const String updateScheduleByDeviceId =
|
||||
'/schedule/enable/{deviceUuid}';
|
||||
|
||||
static const String factoryReset = '/device/factory/reset/{deviceUuid}';
|
||||
static const String powerClamp =
|
||||
'/device/{powerClampUuid}/power-clamp/status';
|
||||
}
|
||||
|
@ -13,9 +13,8 @@ class Assets {
|
||||
static const String rightLine = "assets/images/right_line.png";
|
||||
static const String google = "assets/images/google.svg";
|
||||
static const String facebook = "assets/images/facebook.svg";
|
||||
static const String invisiblePassword =
|
||||
"assets/images/Password_invisible.svg";
|
||||
static const String visiblePassword = "assets/images/Password_visible.svg";
|
||||
static const String invisiblePassword = "assets/images/Password_invisible.svg";
|
||||
static const String visiblePassword = "assets/images/password_visible.svg";
|
||||
static const String accessIcon = "assets/images/access_icon.svg";
|
||||
static const String spaseManagementIcon =
|
||||
"assets/images/spase_management_icon.svg";
|
||||
@ -65,39 +64,23 @@ class Assets {
|
||||
static const String nobodyTime = "assets/icons/nobody_time.svg";
|
||||
|
||||
// Automation functions
|
||||
static const String tempPasswordUnlock =
|
||||
"assets/icons/automation_functions/temp_password_unlock.svg";
|
||||
static const String doorlockNormalOpen =
|
||||
"assets/icons/automation_functions/doorlock_normal_open.svg";
|
||||
static const String doorbell =
|
||||
"assets/icons/automation_functions/doorbell.svg";
|
||||
static const String remoteUnlockViaApp =
|
||||
"assets/icons/automation_functions/remote_unlock_via_app.svg";
|
||||
static const String doubleLock =
|
||||
"assets/icons/automation_functions/double_lock.svg";
|
||||
static const String selfTestResult =
|
||||
"assets/icons/automation_functions/self_test_result.svg";
|
||||
static const String lockAlarm =
|
||||
"assets/icons/automation_functions/lock_alarm.svg";
|
||||
static const String presenceState =
|
||||
"assets/icons/automation_functions/presence_state.svg";
|
||||
static const String currentTemp =
|
||||
"assets/icons/automation_functions/current_temp.svg";
|
||||
static const String presence =
|
||||
"assets/icons/automation_functions/presence.svg";
|
||||
static const String residualElectricity =
|
||||
"assets/icons/automation_functions/residual_electricity.svg";
|
||||
static const String hijackAlarm =
|
||||
"assets/icons/automation_functions/hijack_alarm.svg";
|
||||
static const String passwordUnlock =
|
||||
"assets/icons/automation_functions/password_unlock.svg";
|
||||
static const String remoteUnlockRequest =
|
||||
"assets/icons/automation_functions/remote_unlock_req.svg";
|
||||
static const String cardUnlock =
|
||||
"assets/icons/automation_functions/card_unlock.svg";
|
||||
static const String tempPasswordUnlock = "assets/icons/automation_functions/temp_password_unlock.svg";
|
||||
static const String doorlockNormalOpen = "assets/icons/automation_functions/doorlock_normal_open.svg";
|
||||
static const String doorbell = "assets/icons/automation_functions/doorbell.svg";
|
||||
static const String remoteUnlockViaApp = "assets/icons/automation_functions/remote_unlock_via_app.svg";
|
||||
static const String doubleLock = "assets/icons/automation_functions/double_lock.svg";
|
||||
static const String selfTestResult = "assets/icons/automation_functions/self_test_result.svg";
|
||||
static const String lockAlarm = "assets/icons/automation_functions/lock_alarm.svg";
|
||||
static const String presenceState = "assets/icons/automation_functions/presence_state.svg";
|
||||
static const String currentTemp = "assets/icons/automation_functions/current_temp.svg";
|
||||
static const String presence = "assets/icons/automation_functions/presence.svg";
|
||||
static const String residualElectricity = "assets/icons/automation_functions/residual_electricity.svg";
|
||||
static const String hijackAlarm = "assets/icons/automation_functions/hijack_alarm.svg";
|
||||
static const String passwordUnlock = "assets/icons/automation_functions/password_unlock.svg";
|
||||
static const String remoteUnlockRequest = "assets/icons/automation_functions/remote_unlock_req.svg";
|
||||
static const String cardUnlock = "assets/icons/automation_functions/card_unlock.svg";
|
||||
static const String motion = "assets/icons/automation_functions/motion.svg";
|
||||
static const String fingerprintUnlock =
|
||||
"assets/icons/automation_functions/fingerprint_unlock.svg";
|
||||
static const String fingerprintUnlock = "assets/icons/automation_functions/fingerprint_unlock.svg";
|
||||
|
||||
// Presence Sensor Assets
|
||||
static const String sensorMotionIcon = "assets/icons/sensor_motion_ic.svg";
|
||||
@ -172,4 +155,78 @@ class Assets {
|
||||
static const String Gang1SwitchIcon = 'assets/icons/1_Gang_switch_icon.svg';
|
||||
static const String DoorLockIcon = 'assets/icons/door_lock.svg';
|
||||
static const String SmartGatewayIcon = 'assets/icons/smart_gateway_icon.svg';
|
||||
static const String curtainIcon = "assets/images/curtain.svg";
|
||||
static const String unlock = 'assets/icons/unlock_ic.svg';
|
||||
static const String firmware = 'assets/icons/firmware.svg';
|
||||
//assets/images/scheduling.svg
|
||||
static const String scheduling = 'assets/images/scheduling.svg';
|
||||
//assets/icons/main_door_notifi.svg
|
||||
static const String mainDoorNotifi = 'assets/icons/main_door_notifi.svg';
|
||||
//assets/icons/main_door_reports.svg
|
||||
static const String mainDoorReports = 'assets/icons/main_door_reports.svg';
|
||||
//assets/icons/main_door.svg
|
||||
static const String mainDoor = 'assets/icons/main_door.svg';
|
||||
|
||||
//assets/icons/empty_records.svg
|
||||
static const String emptyRecords = 'assets/icons/empty_records.svg';
|
||||
|
||||
//assets/icons/open_close_door.svg
|
||||
static const String openCloseDoor = 'assets/icons/open_close_door.svg';
|
||||
|
||||
//assets/icons/open_close_records.svg
|
||||
static const String openCloseRecords = 'assets/icons/open_close_records.svg';
|
||||
|
||||
//assets/icons/water_heater.svg
|
||||
static const String waterHeater = 'assets/icons/water_heater.svg';
|
||||
|
||||
//assets/icons/ac_lock.svg
|
||||
static const String acLock = 'assets/icons/ac_lock.svg';
|
||||
|
||||
//assets/icons/ac_schedule.svg
|
||||
static const String acSchedule = 'assets/icons/ac_schedule.svg';
|
||||
|
||||
//assets/icons/preferences.svg
|
||||
static const String preferences = 'assets/icons/preferences.svg';
|
||||
|
||||
static const String openedDoor = 'assets/icons/opened_door.svg';
|
||||
static const String closedDoor = 'assets/icons/closed_door.svg';
|
||||
static const String doorDelay = 'assets/icons/door_delay.svg';
|
||||
static const String records = 'assets/icons/records.svg';
|
||||
//assets/icons/water_leak_normal.svg
|
||||
static const String waterLeakNormal = 'assets/icons/water_leak_normal.svg';
|
||||
//assets/icons/water_leak_detected.svg
|
||||
static const String waterLeakDetected = 'assets/icons/water_leak_detected.svg';
|
||||
|
||||
//assets/icons/automation_records.svg
|
||||
static const String automationRecords = 'assets/icons/automation_records.svg';
|
||||
|
||||
//assets/icons/1gang.svg
|
||||
static const String oneGang = 'assets/icons/1gang.svg';
|
||||
|
||||
//assets/icons/2gang.svg
|
||||
static const String twoGang = 'assets/icons/2gang.svg';
|
||||
|
||||
static const String frequencyIcon = "assets/icons/frequency_icon.svg";
|
||||
static const String voltMeterIcon = "assets/icons/volt_meter_icon.svg";
|
||||
static const String powerActiveIcon = "assets/icons/power_active_icon.svg";
|
||||
static const String searchIcon = "assets/icons/search_icon.svg";
|
||||
static const String voltageIcon = "assets/icons/voltage_icon.svg";
|
||||
static const String speedoMeter = "assets/icons/speedo_meter.svg";
|
||||
//assets/icons/account_setting.svg
|
||||
static const String accountSetting = 'assets/icons/account_setting.svg';
|
||||
|
||||
//assets/icons/settings.svg
|
||||
static const String settings = 'assets/icons/settings.svg';
|
||||
|
||||
//assets/icons/sign_out.svg
|
||||
static const String signOut = 'assets/icons/sign_out.svg';
|
||||
|
||||
//assets/icons/logo_grey.svg
|
||||
static const String logoGrey = 'assets/icons/logo-grey.svg';
|
||||
|
||||
//assets/icons/sos.svg
|
||||
static const String sos = 'assets/icons/sos.svg';
|
||||
|
||||
//assets/icons/sos_normal.svg
|
||||
static const String sosNormal = 'assets/icons/sos_normal.svg';
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
class RoutesConst {
|
||||
static const String auth = '/';
|
||||
static const String auth = '/auth';
|
||||
static const String home = '/home';
|
||||
static const String visitorPassword = '/visitor-password';
|
||||
static const String accessManagementPage = '/access-management-page';
|
||||
|
@ -4,12 +4,37 @@ enum DeviceType {
|
||||
DoorLock,
|
||||
Curtain,
|
||||
Blind,
|
||||
OneGang,
|
||||
TwoGang,
|
||||
ThreeGang,
|
||||
Gateway,
|
||||
CeilingSensor,
|
||||
WallSensor,
|
||||
WH,
|
||||
DoorSensor,
|
||||
GarageDoor,
|
||||
WaterLeak,
|
||||
Other,
|
||||
}
|
||||
/*
|
||||
|
||||
3G:
|
||||
1G:
|
||||
2G:
|
||||
GW:
|
||||
DL:
|
||||
WPS:
|
||||
CPS:
|
||||
AC:
|
||||
CUR:
|
||||
WH:
|
||||
DS:
|
||||
1GT:
|
||||
2GT:
|
||||
3GT:
|
||||
GD:
|
||||
WL:
|
||||
*/
|
||||
|
||||
Map<String, DeviceType> devicesTypesMap = {
|
||||
"AC": DeviceType.AC,
|
||||
@ -18,4 +43,14 @@ Map<String, DeviceType> devicesTypesMap = {
|
||||
"DL": DeviceType.DoorLock,
|
||||
"WPS": DeviceType.WallSensor,
|
||||
"3G": DeviceType.ThreeGang,
|
||||
"2G": DeviceType.TwoGang,
|
||||
"1G": DeviceType.OneGang,
|
||||
"CUR": DeviceType.Curtain,
|
||||
"WH": DeviceType.WH,
|
||||
'DS': DeviceType.DoorSensor,
|
||||
"1GT": DeviceType.OneGang,
|
||||
"2GT": DeviceType.TwoGang,
|
||||
"3GT": DeviceType.ThreeGang,
|
||||
'GD': DeviceType.GarageDoor,
|
||||
'WL': DeviceType.WaterLeak
|
||||
};
|
||||
|
129
lib/utils/extension/build_context_x.dart
Normal file
129
lib/utils/extension/build_context_x.dart
Normal file
@ -0,0 +1,129 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
extension BuildContextExt on BuildContext {
|
||||
ThemeData get theme => Theme.of(this);
|
||||
|
||||
TextTheme get textTheme => Theme.of(this).textTheme;
|
||||
|
||||
AppBarTheme get appBarTheme => Theme.of(this).appBarTheme;
|
||||
|
||||
Size get screenSize => MediaQuery.of(this).size;
|
||||
|
||||
double get screenWidth => MediaQuery.of(this).size.width;
|
||||
|
||||
double get screenHeight => MediaQuery.of(this).size.height;
|
||||
|
||||
double get textScale => MediaQuery.textScalerOf(this).scale(1);
|
||||
|
||||
void customAlertDialog({
|
||||
required Widget alertBody,
|
||||
required String title,
|
||||
required VoidCallback onConfirm,
|
||||
VoidCallback? onDismiss,
|
||||
bool? hideConfirmButton,
|
||||
final double? dialogWidth,
|
||||
}) {
|
||||
showDialog(
|
||||
context: this,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Container(
|
||||
width: dialogWidth ?? 360,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// header widget
|
||||
Text(
|
||||
title,
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 15,
|
||||
horizontal: 50,
|
||||
),
|
||||
child: Container(
|
||||
height: 1,
|
||||
width: double.infinity,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
|
||||
/// custom body content
|
||||
Flexible(child: SingleChildScrollView(child: alertBody)),
|
||||
|
||||
/// Footer buttons
|
||||
Container(
|
||||
height: 1,
|
||||
width: double.infinity,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
hideConfirmButton != true
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: onDismiss ??
|
||||
() {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(color: ColorsManager.greyColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 50,
|
||||
width: 1,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: onConfirm,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
color:
|
||||
ColorsManager.primaryColorWithOpacity),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: GestureDetector(
|
||||
onTap: onDismiss ??
|
||||
() {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(color: ColorsManager.greyColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
String formatDateTime(DateTime? dateTime) {
|
||||
@ -9,3 +10,31 @@ String formatDateTime(DateTime? dateTime) {
|
||||
|
||||
return '${dateFormatter.format(dateTime)} ${timeFormatter.format(dateTime)}';
|
||||
}
|
||||
|
||||
String formatTimeOfDayToISO(TimeOfDay time, {DateTime? currentDate}) {
|
||||
final now = currentDate ?? DateTime.now();
|
||||
|
||||
final dateTime = DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
now.day,
|
||||
time.hour,
|
||||
time.minute,
|
||||
);
|
||||
// Convert DateTime to Unix timestamp (in seconds)
|
||||
final unixTimestamp = dateTime.millisecondsSinceEpoch ~/ 1000;
|
||||
|
||||
return unixTimestamp.toString();
|
||||
}
|
||||
|
||||
String formatIsoStringToTime(String isoString, BuildContext context) {
|
||||
try {
|
||||
final parts = isoString.split(':');
|
||||
final hour = int.parse(parts[0]);
|
||||
final minute = int.parse(parts[1]);
|
||||
final timeOfDay = TimeOfDay(hour: hour, minute: minute);
|
||||
return timeOfDay.format(context);
|
||||
} catch (e) {
|
||||
return isoString;
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,25 @@ import 'package:flutter/material.dart';
|
||||
|
||||
mixin HelperResponsiveLayout {
|
||||
bool isSmallScreenSize(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width < 700;
|
||||
return MediaQuery.of(context).size.width < 600;
|
||||
}
|
||||
|
||||
bool isMediumScreenSize(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width >= 700 &&
|
||||
MediaQuery.of(context).size.width < 1400;
|
||||
return MediaQuery.of(context).size.width >= 600 &&
|
||||
MediaQuery.of(context).size.width < 1024;
|
||||
}
|
||||
|
||||
bool isHafMediumScreenSize(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width >= 600 / 1.3 &&
|
||||
MediaQuery.of(context).size.width < 1024 / 1.3;
|
||||
}
|
||||
|
||||
bool isLargeScreenSize(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width >= 1400;
|
||||
return MediaQuery.of(context).size.width >= 1024 &&
|
||||
MediaQuery.of(context).size.width < 1440;
|
||||
}
|
||||
|
||||
bool isExtraLargeScreenSize(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width >= 1440;
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ InputDecoration? textBoxDecoration({bool suffixIcon = false}) =>
|
||||
BoxDecoration containerDecoration = BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 3), // changes position of shadow
|
||||
color: Colors.grey.withOpacity(0.3),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 5), // changes position of shadow
|
||||
),
|
||||
],
|
||||
color: ColorsManager.boxColor,
|
||||
|
55
lib/utils/theme/theme.dart
Normal file
55
lib/utils/theme/theme.dart
Normal file
@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
final myTheme = ThemeData(
|
||||
fontFamily: 'Aftika',
|
||||
useMaterial3: true,
|
||||
textTheme: const TextTheme(
|
||||
bodySmall: TextStyle(
|
||||
fontSize: 13,
|
||||
color: ColorsManager.whiteColors,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
bodyMedium: TextStyle(color: Colors.black87, fontSize: 14),
|
||||
bodyLarge: TextStyle(fontSize: 16, color: Colors.white),
|
||||
headlineSmall: TextStyle(color: Colors.black87, fontSize: 18),
|
||||
headlineMedium: TextStyle(color: Colors.black87, fontSize: 20),
|
||||
headlineLarge: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: ColorsManager.blueColor,
|
||||
primary: ColorsManager.blueColor,
|
||||
onSurface: Colors.grey.shade400,
|
||||
),
|
||||
switchTheme: SwitchThemeData(
|
||||
thumbColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return ColorsManager.blueColor;
|
||||
}
|
||||
return ColorsManager.whiteColors;
|
||||
}),
|
||||
trackColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return ColorsManager.blueColor.withOpacity(0.5);
|
||||
}
|
||||
return ColorsManager.whiteColors;
|
||||
}),
|
||||
),
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return ColorsManager.blueColor;
|
||||
}
|
||||
return Colors.grey.shade200;
|
||||
}),
|
||||
checkColor: WidgetStateProperty.all(Colors.white),
|
||||
side: const BorderSide(color: ColorsManager.whiteColors),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
);
|
239
lib/utils/user_drop_down_menu.dart
Normal file
239
lib/utils/user_drop_down_menu.dart
Normal file
@ -0,0 +1,239 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||
import 'package:syncrow_web/pages/auth/model/user_model.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class UserDropdownMenu extends StatefulWidget {
|
||||
const UserDropdownMenu({super.key, required this.user});
|
||||
final UserModel? user;
|
||||
|
||||
@override
|
||||
_UserDropdownMenuState createState() => _UserDropdownMenuState();
|
||||
}
|
||||
|
||||
class _UserDropdownMenuState extends State<UserDropdownMenu> {
|
||||
bool _isDropdownOpen = false;
|
||||
|
||||
void _toggleDropdown() {
|
||||
setState(() {
|
||||
_isDropdownOpen = !_isDropdownOpen;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
_toggleDropdown();
|
||||
await _showPopupMenu(context);
|
||||
setState(() {
|
||||
_isDropdownOpen = false;
|
||||
});
|
||||
},
|
||||
child: Transform.rotate(
|
||||
angle: _isDropdownOpen ? -1.5708 : 1.5708,
|
||||
child: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showPopupMenu(BuildContext context) async {
|
||||
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final RelativeRect position = RelativeRect.fromRect(
|
||||
Rect.fromLTRB(
|
||||
overlay.size.width,
|
||||
75,
|
||||
0,
|
||||
overlay.size.height,
|
||||
),
|
||||
Offset.zero & overlay.size,
|
||||
);
|
||||
|
||||
await showMenu(
|
||||
context: context,
|
||||
position: position,
|
||||
color: ColorsManager.whiteColors,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomRight: Radius.circular(10),
|
||||
bottomLeft: Radius.circular(10),
|
||||
),
|
||||
),
|
||||
items: <PopupMenuEntry>[
|
||||
PopupMenuItem(
|
||||
onTap: () {},
|
||||
child: ListTile(
|
||||
leading: SvgPicture.asset(Assets.accountSetting),
|
||||
title: Text(
|
||||
"Account Settings",
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () {},
|
||||
child: ListTile(
|
||||
leading: SvgPicture.asset(Assets.settings),
|
||||
title: Text(
|
||||
"Settings",
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
final size = MediaQuery.of(context).size;
|
||||
return AlertDialog(
|
||||
alignment: Alignment.center,
|
||||
content: SizedBox(
|
||||
height: 200,
|
||||
width: 400,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 24, left: 24, right: 24),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset(
|
||||
Assets.blackLogo,
|
||||
height: 40,
|
||||
width: 200,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
child: Text(
|
||||
'Log out of your Syncrow account',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox.square(
|
||||
dimension: 80,
|
||||
child: CircleAvatar(
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
child: SizedBox.square(
|
||||
dimension: 78,
|
||||
child: SvgPicture.asset(
|
||||
Assets.logoGrey,
|
||||
fit: BoxFit.fitHeight,
|
||||
height: 80,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${widget.user?.firstName ?? ''} ${widget.user?.lastName}',
|
||||
style: Theme.of(context).textTheme.titleMedium!.copyWith(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
' ${widget.user?.email}',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actionsAlignment: MainAxisAlignment.center,
|
||||
actions: [
|
||||
SizedBox(
|
||||
width: 200,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.pop();
|
||||
},
|
||||
child: DefaultButton(
|
||||
backgroundColor: ColorsManager.boxColor,
|
||||
elevation: 1,
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 12,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
AuthBloc.logout();
|
||||
context.go(RoutesConst.auth);
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
child: DefaultButton(
|
||||
elevation: 1,
|
||||
child: Text(
|
||||
'Logout',
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium!.copyWith(fontSize: 12, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
]);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: ListTile(
|
||||
leading: SvgPicture.asset(Assets.signOut),
|
||||
title: Text(
|
||||
"Log Out",
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
).then((value) {
|
||||
setState(() {
|
||||
_isDropdownOpen = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user