dio and login functions

This commit is contained in:
mohammad
2024-07-21 12:55:13 +03:00
parent 62d40bd750
commit 2e678388fb
35 changed files with 1163 additions and 62 deletions

21
lib/utils/const.dart Normal file
View File

@ -0,0 +1,21 @@
import 'dart:convert';
String decodeBase64(String str) {
//'-', '+' 62nd char of encoding, '_', '/' 63rd char of encoding
String output = str.replaceAll('-', '+').replaceAll('_', '/');
switch (output.length % 4) {
// Pad with trailing '='
case 0: // No pad chars in this case
break;
case 2: // Two pad chars
output += '==';
break;
case 3: // One pad char
output += '=';
break;
default:
throw Exception('Illegal base64url string!"');
}
return utf8.decode(base64Url.decode(output));
}

View File

@ -0,0 +1,7 @@
import 'package:flutter/material.dart';
class NavigationService {
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
static GlobalKey<ScaffoldMessengerState>? snackbarKey =
GlobalKey<ScaffoldMessengerState>();
}

View File

@ -1,5 +1,3 @@
import 'package:flutter/material.dart';
@ -15,7 +13,7 @@ class ResponsiveLayout extends StatelessWidget {
}else{
return desktopBody;
}
},
},
);
}
}

40
lib/utils/snack_bar.dart Normal file
View File

@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/navigation_service.dart';
class CustomSnackBar {
static displaySnackBar(String message) {
final key = NavigationService.snackbarKey;
if (key != null) {
final snackBar = SnackBar(content: Text(message));
key.currentState?.clearSnackBars();
key.currentState?.showSnackBar(snackBar);
}
}
static greenSnackBar(String message) {
final key = NavigationService.snackbarKey;
BuildContext? currentContext = key?.currentContext;
if (key != null && currentContext != null) {
final snackBar = SnackBar(
padding: const EdgeInsets.all(16),
backgroundColor: Colors.green,
content: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
const Icon(
Icons.check_circle,
color: Colors.white,
size: 32,
),
const SizedBox(
width: 8,
),
Text(
message,
style: Theme.of(currentContext).textTheme.bodySmall!.copyWith(
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.green),
)
]),
);
key.currentState?.showSnackBar(snackBar);
}
}
}

View File

@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'color_manager.dart';
InputDecoration? textBoxDecoration = InputDecoration(
InputDecoration? textBoxDecoration({bool suffixIcon = false}) => InputDecoration(
focusColor: ColorsManager.grayColor,
suffixIcon: const Icon(Icons.search),
suffixIcon:suffixIcon? const Icon(Icons.search):null,
hintText: 'Search',
filled: true, // Enable background filling
fillColor: Colors.grey.shade200, // Set the background color