Removed helpers lib and updated to flutter 3.22
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import 'package:colorful_print/colorful_print.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
import 'package:rluv/global/utils.dart';
|
||||
import 'package:rluv/models/shared_note.dart';
|
||||
|
||||
@@ -22,7 +21,7 @@ class SharedNotesScreen extends ConsumerStatefulWidget {
|
||||
class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
final sharedNotes = ref.watch(sharedNotesProvider);
|
||||
return Column(
|
||||
children: [
|
||||
@@ -47,14 +46,10 @@ class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final note = sharedNotes[index];
|
||||
final colorBrightness = note.color == null
|
||||
? Brightness.light
|
||||
: getBrightness(note.color!);
|
||||
final colorBrightness = note.color == null ? Brightness.light : getBrightness(note.color!);
|
||||
final textStyle = TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: colorBrightness == Brightness.light
|
||||
? Colors.black54
|
||||
: Colors.white70,
|
||||
color: colorBrightness == Brightness.light ? Colors.black54 : Colors.white70,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -67,14 +62,10 @@ class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
FittedBox(
|
||||
child: Text(note.title,
|
||||
style: const TextStyle(fontSize: 20))),
|
||||
FittedBox(child: Text(note.title, style: const TextStyle(fontSize: 20))),
|
||||
Flexible(
|
||||
child: Text(
|
||||
note.content.length > 80
|
||||
? "${note.content.substring(0, 75)}..."
|
||||
: note.content,
|
||||
note.content.length > 80 ? "${note.content.substring(0, 75)}..." : note.content,
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
@@ -93,9 +84,7 @@ class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom:
|
||||
MediaQuery.of(context).viewInsets.bottom),
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
child: NoteBottomSheet(
|
||||
index: index,
|
||||
),
|
||||
@@ -121,8 +110,7 @@ class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
child: const NoteBottomSheet(
|
||||
index: null,
|
||||
),
|
||||
@@ -182,19 +170,14 @@ class _NoteBottomSheetState extends ConsumerState<NoteBottomSheet> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
return Container(
|
||||
width: screen.width,
|
||||
decoration: BoxDecoration(
|
||||
color: newNote.color ?? Styles.washedStone,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
spreadRadius: 5.0,
|
||||
blurRadius: 2.0,
|
||||
offset: Offset(0, -2))
|
||||
BoxShadow(color: Colors.black26, spreadRadius: 5.0, blurRadius: 2.0, offset: Offset(0, -2))
|
||||
]),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -218,8 +201,7 @@ class _NoteBottomSheetState extends ConsumerState<NoteBottomSheet> {
|
||||
// decoration: Styles.inputLavenderBubble(),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 28.0, horizontal: 36.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 28.0, horizontal: 36.0),
|
||||
child: UiButton(
|
||||
onPressed: !noteChanged(oldNote, newNote)
|
||||
? null
|
||||
@@ -229,41 +211,26 @@ class _NoteBottomSheetState extends ConsumerState<NoteBottomSheet> {
|
||||
try {
|
||||
Response? res;
|
||||
if (widget.index == null) {
|
||||
res = await ref
|
||||
.read(apiProvider)
|
||||
.post('shared_note', data: newNote.toJson());
|
||||
res = await ref.read(apiProvider).post('shared_note', data: newNote.toJson());
|
||||
} else {
|
||||
res = await ref
|
||||
.read(apiProvider)
|
||||
.put('shared_note', data: newNote.toJson());
|
||||
res = await ref.read(apiProvider).put('shared_note', data: newNote.toJson());
|
||||
}
|
||||
if (res.data != null && res.data['success']) {
|
||||
if (widget.index == null) {
|
||||
ref
|
||||
.read(dashboardProvider.notifier)
|
||||
.add({'shared_notes': res.data});
|
||||
ref.read(dashboardProvider.notifier).add({'shared_notes': res.data});
|
||||
} else {
|
||||
ref
|
||||
.read(dashboardProvider.notifier)
|
||||
.update({'shared_notes': res.data});
|
||||
ref.read(dashboardProvider.notifier).update({'shared_notes': res.data});
|
||||
}
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: 'Added note',
|
||||
type: SnackType.success);
|
||||
showSnack(ref: ref, text: 'Added note', type: SnackType.success);
|
||||
} else {
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: res.data['message'] ??
|
||||
'Unexpected error occurred',
|
||||
text: res.data['message'] ?? 'Unexpected error occurred',
|
||||
type: SnackType.error);
|
||||
}
|
||||
} catch (err) {
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: 'Unexpected error occurred',
|
||||
type: SnackType.error);
|
||||
printRed(err);
|
||||
showSnack(ref: ref, text: 'Unexpected error occurred', type: SnackType.error);
|
||||
printColor(err, textColor: TextColor.red);
|
||||
}
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pop(context);
|
||||
|
||||
Reference in New Issue
Block a user