mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
dio and login functions
This commit is contained in:
21
lib/utils/const.dart
Normal file
21
lib/utils/const.dart
Normal 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));
|
||||
}
|
7
lib/utils/navigation_service.dart
Normal file
7
lib/utils/navigation_service.dart
Normal file
@ -0,0 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NavigationService {
|
||||
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
static GlobalKey<ScaffoldMessengerState>? snackbarKey =
|
||||
GlobalKey<ScaffoldMessengerState>();
|
||||
}
|
@ -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
40
lib/utils/snack_bar.dart
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Reference in New Issue
Block a user