Working auth and added shared notes
This commit is contained in:
@@ -2,8 +2,11 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:rluv/global/styles.dart';
|
||||
import 'package:rluv/main.dart';
|
||||
|
||||
String formatDate(DateTime time) {
|
||||
return DateFormat('EEEE, dd MMMM yyyy').format(time);
|
||||
@@ -70,3 +73,59 @@ void setDevicePortraitOrientation() {
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
}
|
||||
|
||||
enum SnackType { info, success, error }
|
||||
|
||||
void showSnack(
|
||||
{required WidgetRef ref,
|
||||
required String text,
|
||||
SnackType type = SnackType.info,
|
||||
Duration duration = const Duration(seconds: 2)}) {
|
||||
final messengerKey = ref.read(scaffoldMessengerKeyProvider);
|
||||
if (messengerKey.currentState == null) {
|
||||
printPink('Cannot show snackbar, state == null');
|
||||
return;
|
||||
}
|
||||
final color = type == SnackType.info
|
||||
? Styles.washedStone
|
||||
: type == SnackType.success
|
||||
? Styles.seaweedGreen
|
||||
: Styles.expensesRed;
|
||||
final textStyle = TextStyle(
|
||||
fontSize: 16,
|
||||
color: color,
|
||||
);
|
||||
messengerKey.currentState!.showSnackBar(SnackBar(
|
||||
elevation: 8,
|
||||
backgroundColor: Styles.deepPurpleNurple,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
|
||||
),
|
||||
content: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 14.0),
|
||||
child: Icon(
|
||||
type == SnackType.success ? Icons.check_circle : Icons.info,
|
||||
color: color),
|
||||
),
|
||||
Text(text, style: textStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
bool isEmailValid(String email) {
|
||||
final RegExp regex =
|
||||
RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$");
|
||||
return regex.hasMatch(email);
|
||||
}
|
||||
|
||||
bool isUsernameValid(String username) {
|
||||
final RegExp regex = RegExp(r"[a-zA-Z0-9._-]");
|
||||
return regex.hasMatch(username);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user