Update Saqel Platform: 2026-08-31 01:52:23
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// Enterprise Logging Utility for Saqel Admin & Schools Management
|
||||
/// Active in Debug mode (kDebugMode), completely silent in Production
|
||||
class AppLogger {
|
||||
AppLogger._();
|
||||
|
||||
static void log(String message, {String tag = 'ADMIN_APP'}) {
|
||||
if (kDebugMode) {
|
||||
debugPrint('[$tag] $message');
|
||||
}
|
||||
}
|
||||
|
||||
static void request({
|
||||
required String method,
|
||||
required Uri uri,
|
||||
Map<String, String>? headers,
|
||||
dynamic body,
|
||||
}) {
|
||||
if (!kDebugMode) return;
|
||||
|
||||
final buffer = StringBuffer();
|
||||
buffer.writeln('\n🌐 ─── [HTTP REQUEST (ADMIN)] ───────────────────────────────────');
|
||||
buffer.writeln('➡️ Method: $method');
|
||||
buffer.writeln('🔗 URL: $uri');
|
||||
if (headers != null && headers.isNotEmpty) {
|
||||
final safeHeaders = Map<String, String>.from(headers);
|
||||
if (safeHeaders.containsKey('Authorization')) {
|
||||
final auth = safeHeaders['Authorization']!;
|
||||
safeHeaders['Authorization'] = auth.length > 20 ? '${auth.substring(0, 15)}...' : 'Bearer [REDACTED]';
|
||||
}
|
||||
buffer.writeln('📋 Headers: ${jsonEncode(safeHeaders)}');
|
||||
}
|
||||
if (body != null) {
|
||||
buffer.writeln('📦 Body: ${body is String ? body : jsonEncode(body)}');
|
||||
}
|
||||
buffer.writeln('───────────────────────────────────────────────────────────────');
|
||||
debugPrint(buffer.toString());
|
||||
}
|
||||
|
||||
static void response({
|
||||
required String method,
|
||||
required Uri uri,
|
||||
required int statusCode,
|
||||
dynamic responseBody,
|
||||
Duration? duration,
|
||||
}) {
|
||||
if (!kDebugMode) return;
|
||||
|
||||
final isSuccess = statusCode >= 200 && statusCode < 300;
|
||||
final emoji = isSuccess ? '✅' : '⚠️';
|
||||
final buffer = StringBuffer();
|
||||
|
||||
buffer.writeln('\n$emoji ─── [HTTP RESPONSE $statusCode (ADMIN)] ───────────────────────');
|
||||
buffer.writeln('⬅️ Method: $method');
|
||||
buffer.writeln('🔗 URL: $uri');
|
||||
if (duration != null) {
|
||||
buffer.writeln('⏱️ Time: ${duration.inMilliseconds}ms');
|
||||
}
|
||||
if (responseBody != null) {
|
||||
buffer.writeln('📦 Data: ${responseBody is String ? responseBody : jsonEncode(responseBody)}');
|
||||
}
|
||||
buffer.writeln('───────────────────────────────────────────────────────────────');
|
||||
debugPrint(buffer.toString());
|
||||
}
|
||||
|
||||
static void error(String message, {dynamic error, StackTrace? stackTrace, String tag = 'ADMIN_ERROR'}) {
|
||||
if (!kDebugMode) return;
|
||||
|
||||
final buffer = StringBuffer();
|
||||
buffer.writeln('\n🚨 ─── [ERROR: $tag] ──────────────────────────────────────────');
|
||||
buffer.writeln('❌ Message: $message');
|
||||
if (error != null) {
|
||||
buffer.writeln('⚠️ Error: $error');
|
||||
}
|
||||
if (stackTrace != null) {
|
||||
buffer.writeln('📍 Trace: \n$stackTrace');
|
||||
}
|
||||
buffer.writeln('───────────────────────────────────────────────────────────────');
|
||||
debugPrint(buffer.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Ultra-Luxury Apple-Grade SnackBar / Toast Notification System for Saqel Apps
|
||||
class SaqelToast {
|
||||
SaqelToast._();
|
||||
|
||||
static const Color _teacherEmerald = Color(0xFF10B981);
|
||||
static const Color _errorRed = Color(0xFFEF4444);
|
||||
static const Color _appleBlue = Color(0xFF0071E3);
|
||||
static const Color _whatsappGreen = Color(0xFF25D366);
|
||||
|
||||
/// Show Success Toast (Emerald / Green)
|
||||
static void showSuccess(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
String? title,
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
}) {
|
||||
_show(
|
||||
context: context,
|
||||
message: message,
|
||||
title: title,
|
||||
icon: CupertinoIcons.checkmark_circle_fill,
|
||||
iconColor: _teacherEmerald,
|
||||
borderColor: _teacherEmerald.withAlpha(90),
|
||||
backgroundColor: const Color(0xE60D1A14),
|
||||
duration: duration,
|
||||
);
|
||||
}
|
||||
|
||||
/// Show Error Toast (Crimson / Red)
|
||||
static void showError(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
String? title,
|
||||
Duration duration = const Duration(seconds: 4),
|
||||
}) {
|
||||
_show(
|
||||
context: context,
|
||||
message: message,
|
||||
title: title,
|
||||
icon: CupertinoIcons.exclamationmark_circle_fill,
|
||||
iconColor: _errorRed,
|
||||
borderColor: _errorRed.withAlpha(90),
|
||||
backgroundColor: const Color(0xE61A0D0D),
|
||||
duration: duration,
|
||||
);
|
||||
}
|
||||
|
||||
/// Show Info Toast (Apple Blue / Cyan)
|
||||
static void showInfo(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
String? title,
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
}) {
|
||||
_show(
|
||||
context: context,
|
||||
message: message,
|
||||
title: title,
|
||||
icon: CupertinoIcons.info_circle_fill,
|
||||
iconColor: _appleBlue,
|
||||
borderColor: _appleBlue.withAlpha(90),
|
||||
backgroundColor: const Color(0xE60D1424),
|
||||
duration: duration,
|
||||
);
|
||||
}
|
||||
|
||||
/// Show WhatsApp Toast (WhatsApp Green)
|
||||
static void showWhatsApp(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
String? title,
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
}) {
|
||||
_show(
|
||||
context: context,
|
||||
message: message,
|
||||
title: title,
|
||||
icon: CupertinoIcons.chat_bubble_fill,
|
||||
iconColor: _whatsappGreen,
|
||||
borderColor: _whatsappGreen.withAlpha(100),
|
||||
backgroundColor: const Color(0xE6091A12),
|
||||
duration: duration,
|
||||
);
|
||||
}
|
||||
|
||||
static void _show({
|
||||
required BuildContext context,
|
||||
required String message,
|
||||
String? title,
|
||||
required IconData icon,
|
||||
required Color iconColor,
|
||||
required Color borderColor,
|
||||
required Color backgroundColor,
|
||||
required Duration duration,
|
||||
}) {
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
messenger.hideCurrentSnackBar();
|
||||
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
duration: duration,
|
||||
elevation: 0,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
margin: const EdgeInsets.only(bottom: 24, left: 16, right: 16),
|
||||
padding: EdgeInsets.zero,
|
||||
backgroundColor: Colors.transparent,
|
||||
content: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
border: Border.all(color: borderColor, width: 1.2),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x99000000),
|
||||
blurRadius: 25,
|
||||
offset: Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: iconColor.withAlpha(35),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, color: iconColor, size: 20),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (title != null && title.isNotEmpty) ...[
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
],
|
||||
Text(
|
||||
message,
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: Color(0xFFE2E8F0),
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user