save before flutter upgrade

This commit is contained in:
Abraham
2025-07-15 16:40:14 -07:00
commit 813c586a1c
197 changed files with 11144 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import 'dart:ui';
extension ColorExtension on Color {
/// Convert the color to a darken color based on the [percent]
Color darken([int percent = 40]) {
assert(1 <= percent && percent <= 100);
final value = 1 - percent / 100;
return Color.fromARGB(
alpha,
(red * value).round(),
(green * value).round(),
(blue * value).round(),
);
}
Color lighten([int percent = 40]) {
assert(1 <= percent && percent <= 100);
final value = percent / 100;
return Color.fromARGB(
alpha,
(red + ((255 - red) * value)).round(),
(green + ((255 - green) * value)).round(),
(blue + ((255 - blue) * value)).round(),
);
}
Color avg(Color other) {
final red = (this.red + other.red) ~/ 2;
final green = (this.green + other.green) ~/ 2;
final blue = (this.blue + other.blue) ~/ 2;
final alpha = (this.alpha + other.alpha) ~/ 2;
return Color.fromARGB(alpha, red, green, blue);
}
}

View File

@@ -0,0 +1,30 @@
//////// DEV CBLUNA ////////
const String supabaseUrl = 'https://cbl-supabase.virtalus.cbluna-dev.com';
const String anonKey =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzE1MjM4MDAwLAogICJleHAiOiAxODczMDA0NDAwCn0.qKqYn2vjtHqKqyt1FAghuIjvNsyr9b1ElpVfvJg6zJ4';
const String storageBooksCover =
'https://cbl-supabase.virtalus.cbluna-dev.com/storage/v1/object/public/lectores_urb/books_cover/';
const String storageBooks = 'lectores_urb/books';
const redirectUrl = '$supabaseUrl/change-pass/change-password/token';
const String apiGatewayUrl = 'https://cbl.virtalus.cbluna-dev.com/uapi/lu/api';
const String n8nUrl = 'https://u-n8n.virtalus.cbluna-dev.com/webhook';
const bearerApiGateway = "Basic YWlyZmxvdzpjYiF1bmEyMDIz";
const int organizationId = 10;
const String lectoresUrl = 'https://lectoresurbanos.com/';
const themeId = String.fromEnvironment('themeId', defaultValue: '2');
const int mobileSize = 800;
//GoogleMaps
const apiKey = '-plDP_dR7XAGxBSiHgTFyxkxNdjFFHqjQK9ge8b92CE';
//Stripe
const stripeKey =
'sk_test_51QB3lZRxye2e7dlWyeWcHWmgsJ9kEbIz4lrgJtUIKuC7WEB0HM0njk6Mcgq1q1H9GTs7fByRZdvxHaSAGhzcBqYF00fLxZU9E9';
const authorizationKey = 'Bearer $stripeKey';
const urlStripe = 'https://api.stripe.com';
const idPricePlanRentaQR = 'price_1QPaDnRxye2e7dlWORf4GoHS';

325
lib/helpers/globals.dart Normal file
View File

@@ -0,0 +1,325 @@
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pluto_grid/pluto_grid.dart';
import 'package:supabase_flutter/supabase_flutter.dart' hide User;
import 'package:nethive_neo/helpers/supabase/queries.dart';
import 'package:nethive_neo/models/models.dart';
import 'package:nethive_neo/theme/theme.dart';
final GlobalKey<ScaffoldMessengerState> snackbarKey =
GlobalKey<ScaffoldMessengerState>();
const storage = FlutterSecureStorage();
final supabase = Supabase.instance.client;
late SupabaseClient supabaseLU;
late final SharedPreferences prefs;
late Configuration? theme;
User? currentUser;
Future<void> initGlobals() async {
prefs = await SharedPreferences.getInstance();
currentUser = await SupabaseQueries.getCurrentUserData();
/* //Temas de la aplicacion
if (currentUser == null) {
Configuration? conf = await SupabaseQueries.getDefaultTheme();
AppTheme.initConfiguration(conf);
} else {
theme = await SupabaseQueries.getUserTheme();
AppTheme.initConfiguration(theme);
}
*/
if (currentUser == null) return;
}
PlutoGridScrollbarConfig plutoGridScrollbarConfig(BuildContext context) {
return PlutoGridScrollbarConfig(
isAlwaysShown: true,
scrollbarThickness: 5,
hoverWidth: 20,
scrollBarColor: AppTheme.of(context).primaryColor,
);
}
PlutoGridStyleConfig plutoGridStyleConfig(BuildContext context,
{double rowHeight = 50}) {
return AppTheme.themeMode == ThemeMode.light
? PlutoGridStyleConfig(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: false,
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: true,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: AppTheme.of(context).bodyText3Family,
color: AppTheme.of(context).primaryColor,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: const Color(0xFFF1F4FA),
rowHeight: rowHeight,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
)
: PlutoGridStyleConfig.dark(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: false,
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: true,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: 'Quicksand',
color: AppTheme.of(context).alternate,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: const Color(0xFFF1F4FA),
rowHeight: rowHeight,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
);
}
PlutoGridStyleConfig plutoGridBigStyleConfig(BuildContext context) {
return AppTheme.themeMode == ThemeMode.light
? PlutoGridStyleConfig(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: false,
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: true,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: 'Quicksand',
color: AppTheme.of(context).hintText,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: Colors.transparent,
rowHeight: 50,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
columnHeight: 100,
gridBorderRadius: BorderRadius.circular(16),
)
: PlutoGridStyleConfig.dark(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: false,
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: true,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: 'Quicksand',
color: AppTheme.of(context).alternate,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: const Color(0xFFF1F4FA),
rowHeight: 50,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
columnHeight: 100,
gridBorderRadius: BorderRadius.circular(16),
);
}
PlutoGridStyleConfig plutoGridDashboardStyleConfig(BuildContext context) {
return AppTheme.themeMode == ThemeMode.light
? PlutoGridStyleConfig(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: false,
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: true,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: 'Quicksand',
color: AppTheme.of(context).hintText,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: const Color(0xFFF1F4FA),
rowHeight: 50,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
)
: PlutoGridStyleConfig.dark(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: false,
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: true,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: 'Quicksand',
color: AppTheme.of(context).alternate,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: const Color(0xFFF1F4FA),
rowHeight: 50,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
);
}
double rowHeight = 60;
PlutoGridStyleConfig plutoGridPopUpStyleConfig(BuildContext context) {
return AppTheme.themeMode == ThemeMode.light
? PlutoGridStyleConfig(
menuBackgroundColor: AppTheme.of(context).secondaryBackground,
gridPopupBorderRadius: BorderRadius.circular(16),
//
enableColumnBorderVertical: false,
columnTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
borderColor: Colors.transparent,
//
rowHeight: 40,
rowColor: Colors.transparent,
cellTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: AppTheme.of(context).bodyText3Family,
color: AppTheme.of(context).primaryText,
),
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: false,
checkedColor: Colors.transparent,
enableRowColorAnimation: false,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
//
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
)
: PlutoGridStyleConfig.dark(
menuBackgroundColor: Colors.transparent,
//
enableColumnBorderVertical: false,
columnTextStyle: AppTheme.of(context).copyRightText,
iconColor: AppTheme.of(context).tertiaryColor,
borderColor: Colors.transparent,
//
rowHeight: 40,
rowColor: Colors.transparent,
cellTextStyle: AppTheme.of(context).copyRightText,
enableColumnBorderHorizontal: false,
enableCellBorderVertical: false,
enableCellBorderHorizontal: false,
checkedColor: Colors.transparent,
enableRowColorAnimation: false,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
//
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
);
}
PlutoGridStyleConfig plutoGridStyleConfigContentManager(BuildContext context,
{double rowHeight = 50}) {
return AppTheme.themeMode == ThemeMode.light
? PlutoGridStyleConfig(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: true,
enableColumnBorderHorizontal: true,
enableCellBorderVertical: true,
enableCellBorderHorizontal: true,
columnHeight: 100,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: AppTheme.of(context).bodyText3Family,
color: AppTheme.of(context).primaryColor,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: const Color(0xFFF1F4FA),
rowHeight: rowHeight,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
gridBorderRadius: BorderRadius.circular(16),
)
: PlutoGridStyleConfig.dark(
menuBackgroundColor: AppTheme.of(context).secondaryColor,
gridPopupBorderRadius: BorderRadius.circular(16),
enableColumnBorderVertical: true,
enableColumnBorderHorizontal: true,
enableCellBorderVertical: true,
enableCellBorderHorizontal: true,
columnHeight: 100,
columnTextStyle: AppTheme.of(context).bodyText3.override(
fontFamily: 'Quicksand',
color: AppTheme.of(context).alternate,
),
cellTextStyle: AppTheme.of(context).bodyText3,
iconColor: AppTheme.of(context).tertiaryColor,
rowColor: Colors.transparent,
borderColor: const Color(0xFFF1F4FA),
rowHeight: rowHeight,
checkedColor: AppTheme.themeMode == ThemeMode.light
? AppTheme.of(context).secondaryColor
: const Color(0XFF4B4B4B),
enableRowColorAnimation: true,
gridBackgroundColor: Colors.transparent,
gridBorderColor: Colors.transparent,
activatedColor: AppTheme.of(context).primaryBackground,
activatedBorderColor: AppTheme.of(context).tertiaryColor,
);
}

View File

@@ -0,0 +1,12 @@
// Create Custom Scroll Class for web Drap Behaviour:
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class MyCustomScrollBehavior extends MaterialScrollBehavior {
// Override behavior methods and getters like dragDevices
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
};
}

View File

@@ -0,0 +1,87 @@
import 'dart:convert';
import 'dart:developer';
import 'package:supabase_flutter/supabase_flutter.dart' hide User;
import 'package:nethive_neo/helpers/globals.dart';
import 'package:nethive_neo/models/models.dart';
class SupabaseQueries {
static Future<User?> getCurrentUserData() async {
try {
final user = supabase.auth.currentUser;
if (user == null) return null;
final PostgrestFilterBuilder query =
supabase.from('users').select().eq('user_profile_id', user.id);
final res = await query;
final userProfile = res[0];
userProfile['id'] = user.id;
userProfile['email'] = user.email!;
final usuario = User.fromMap(userProfile);
return usuario;
} catch (e) {
log('Error en getCurrentUserData() - $e');
return null;
}
}
static Future<Configuration?> getDefaultTheme() async {
try {
final res = await supabase.from('theme').select().eq('id', 1);
return Configuration.fromJson(jsonEncode(res[0]));
} catch (e) {
log('Error en getDefaultTheme() - $e');
return null;
}
}
static Future<Configuration?> getUserTheme() async {
try {
if (currentUser == null) return null;
final res = await supabase.from('users').select('config').eq(
'sequential_id',
currentUser!
.sequentialId); //final res = await supabase.from('theme').select().eq('id', 2);
return Configuration.fromJson(jsonEncode(res[0]));
} catch (e) {
log('Error en getUserTheme() - $e');
return null;
}
}
static Future<bool> tokenChangePassword(String id, String newPassword) async {
try {
final res = await supabase.rpc('token_change_password', params: {
'user_id': id,
'new_password': newPassword,
});
if (res['data'] == true) {
return true;
}
} catch (e) {
log('Error en tokenChangePassword() - $e');
}
return false;
}
static Future<bool> saveToken(
String userId,
String tokenType,
String token,
) async {
try {
await supabase
.from('token')
.upsert({'user_id': userId, tokenType: token});
return true;
} catch (e) {
log('Error en saveToken() - $e');
}
return false;
}
}