Skip to content

Commit

Permalink
Small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
MoazSalem committed Oct 22, 2023
1 parent 99af76a commit ba418a6
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 180 deletions.
2 changes: 1 addition & 1 deletion assets/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Amoled Mode": "وضع الاموليد",
"sAmoled Mode": "تغير الوضع الداكن",
"Darker Colors": "الوان داكنة",
"sDarker Colors": "جعل الالوان المستخدمة داكنة اكثر",
"sDarker Colors": "جعل الالوان المستخدمة في الوان اكثر داكنة قليلا",
"Light": "فاتح",
"Dark": "داكن",
"Amoled": "أموليد",
Expand Down
2 changes: 1 addition & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Amoled Mode": "Amoled Mode",
"sAmoled Mode": "Change dark modes style",
"Darker Colors": "Darker Colors",
"sDarker Colors": "Make colors used a bit darker",
"sDarker Colors": "Make the colorful option use a bit darker colors",
"Empty": "Empty",
"Side Bar": "Sidebar",
"sSide Bar": "Change Sidebars Location",
Expand Down
18 changes: 14 additions & 4 deletions lib/Screens/Actions/create_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:notes/Cubit/notes_cubit.dart';
import 'package:notes/main.dart';

class CreateNote extends StatefulWidget {
const CreateNote({Key? key}) : super(key: key);
const CreateNote({super.key});

@override
State<CreateNote> createState() => _CreateNoteState();
Expand All @@ -30,6 +30,15 @@ class _CreateNoteState extends State<CreateNote> {
setState(() => pickerColor = color);
}

@override
void dispose() {
titleC.dispose();
contentC.dispose();
titleDir.dispose();
contentDir.dispose();
super.dispose();
}

@override
void initState() {
titleDir = ValueNotifier(TextDirection.ltr);
Expand Down Expand Up @@ -95,7 +104,8 @@ class _CreateNoteState extends State<CreateNote> {
content: content,
index: chosenIndex,
tIndex: textColor,
extra: chosenIndex == 99 ? pickerColor.value.toString() : "",
extra:
chosenIndex == 99 ? pickerColor.value.toString() : "",
layout: getLayout()),
titleC.text = "",
contentC.text = "",
Expand Down Expand Up @@ -128,7 +138,7 @@ class _CreateNoteState extends State<CreateNote> {
flex: C.isTablet ? 8 : 4,
child: ListView(children: [
Padding(
padding: C.settings["lang"] == 'en'
padding: C.settings["lang"] == 'en'
? EdgeInsets.only(left: C.isTablet ? 60 : 20)
: EdgeInsets.only(right: C.isTablet ? 60 : 20),
child: ValueListenableBuilder<TextDirection>(
Expand Down Expand Up @@ -163,7 +173,7 @@ class _CreateNoteState extends State<CreateNote> {
height: 10,
),
Padding(
padding: C.settings["lang"] == 'en'
padding: C.settings["lang"] == 'en'
? EdgeInsets.only(left: C.isTablet ? 60 : 20)
: EdgeInsets.only(right: C.isTablet ? 60 : 20),
child: ValueListenableBuilder<TextDirection>(
Expand Down
11 changes: 10 additions & 1 deletion lib/Screens/Actions/create_voice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:notes/Cubit/notes_cubit.dart';
import 'package:record/record.dart';

class CreateVoice extends StatefulWidget {
const CreateVoice({Key? key}) : super(key: key);
const CreateVoice({super.key});

@override
State<CreateVoice> createState() => _CreateVoiceState();
Expand Down Expand Up @@ -36,6 +36,15 @@ class _CreateVoiceState extends State<CreateVoice> {
setState(() => pickerColor = color);
}

@override
void dispose() {
titleC.dispose();
titleFocusNode.dispose();
stopWatchTimer.dispose();
record.dispose();
super.dispose();
}

@override
void didChangeDependencies() {
height = MediaQuery.of(context).size.height;
Expand Down
11 changes: 10 additions & 1 deletion lib/Screens/Actions/edit_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:notes/main.dart';
class EditNote extends StatefulWidget {
final Map note;

const EditNote({Key? key, required this.note}) : super(key: key);
const EditNote({super.key, required this.note});

@override
State<EditNote> createState() => _EditNoteState();
Expand All @@ -30,6 +30,15 @@ class _EditNoteState extends State<EditNote> {
setState(() => pickerColor = color);
}

@override
void dispose() {
titleC.dispose();
contentC.dispose();
_titleDir.dispose();
_contentDir.dispose();
super.dispose();
}

@override
void initState() {
titleC.text = widget.note["title"];
Expand Down
8 changes: 7 additions & 1 deletion lib/Screens/Actions/edit_voice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:notes/main.dart';
class EditVoice extends StatefulWidget {
final Map note;

const EditVoice({Key? key, required this.note}) : super(key: key);
const EditVoice({super.key, required this.note});

@override
State<EditVoice> createState() => _EditVoiceState();
Expand All @@ -26,6 +26,12 @@ class _EditVoiceState extends State<EditVoice> {
setState(() => pickerColor = color);
}

@override
void dispose() {
titleC.dispose();
super.dispose();
}

@override
void initState() {
titleC.text = widget.note["title"];
Expand Down
2 changes: 1 addition & 1 deletion lib/Screens/SideBar/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'dart:ui' as ui;
final TextEditingController searchController = TextEditingController();

class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
const HomePage({super.key});

@override
State<HomePage> createState() => _HomePageState();
Expand Down
2 changes: 1 addition & 1 deletion lib/Screens/SideBar/info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:notes/main.dart';
import 'package:url_launcher/url_launcher.dart';

class InfoPage extends StatefulWidget {
const InfoPage({Key? key}) : super(key: key);
const InfoPage({super.key});

@override
State<InfoPage> createState() => _InfoPageState();
Expand Down
6 changes: 2 additions & 4 deletions lib/Screens/SideBar/notes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:notes/Widgets/notes.dart';
import 'package:notes/main.dart';

class NotesPage extends StatefulWidget {
const NotesPage({Key? key}) : super(key: key);
const NotesPage({super.key});

@override
State<NotesPage> createState() => _NotesPageState();
Expand All @@ -36,9 +36,7 @@ class _NotesPageState extends State<NotesPage> {
builder: (context, state) {
notes = (searchOn ? C.notes['textSearched'] : C.notes['textNotes'])!;
return Scaffold(
backgroundColor: C.isDark
? C.theme.background
: C.theme.surfaceVariant.withOpacity(0.6),
backgroundColor: C.isDark ? C.theme.background : C.theme.surfaceVariant.withOpacity(0.6),
floatingActionButtonLocation: C.settings["fabIndex"] == 0
? FloatingActionButtonLocation.endFloat
: FloatingActionButtonLocation.startFloat,
Expand Down
42 changes: 21 additions & 21 deletions lib/Screens/SideBar/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,64 +399,64 @@ class _SettingsPageState extends State<SettingsPage> {
),
C.divider(),
SizedBox(
height: height,
height: C.isTablet ? 140 : 100,
child: Center(
child: ListTile(
title: Text(
"Darker Colors".tr(),
"harmonize Colors".tr(),
style: TextStyle(
fontSize: title,
fontWeight: FontWeight.w400,
color: C.theme.onSurfaceVariant),
),
subtitle: Text(
"sDarker Colors".tr(),
"sHarmonizeColors".tr(),
style: TextStyle(
fontSize: subtitle,
fontWeight: FontWeight.w300,
color: C.theme.onSurfaceVariant),
),
trailing: SwitcherButton(
onColor: C.settings["colorful"] ? C.colors[6] : primaryColor,
onColor: C.settings["colorful"] ? C.colors[4] : primaryColor,
offColor: C.theme.primaryContainer,
size: switchSize,
value: C.settings["darkColors"],
value: C.settings["harmonizeColor"],
onChange: (bool value) {
C.box.put("darkColors", value);
C.settings["darkColors"] = value;
C.box.put("harmonizeColor", value);
C.settings["harmonizeColor"] = value;
C.harmonizeColors();
C.onChanged();
},
)),
),
),
C.divider(),
SizedBox(
height: C.isTablet ? 140 : 100,
height: height,
child: Center(
child: ListTile(
title: Text(
"harmonize Colors".tr(),
"Colorful".tr(),
style: TextStyle(
fontSize: title,
fontWeight: FontWeight.w400,
color: C.theme.onSurfaceVariant),
),
subtitle: Text(
"sHarmonizeColors".tr(),
"sColorful".tr(),
style: TextStyle(
fontSize: subtitle,
fontWeight: FontWeight.w300,
color: C.theme.onSurfaceVariant),
),
trailing: SwitcherButton(
onColor: C.settings["colorful"] ? C.colors[4] : primaryColor,
onColor: C.settings["colorful"] ? C.colors[8] : primaryColor,
offColor: C.theme.primaryContainer,
size: switchSize,
value: C.settings["harmonizeColor"],
value: C.settings["colorful"],
onChange: (bool value) {
C.box.put("harmonizeColor", value);
C.settings["harmonizeColor"] = value;
C.harmonizeColors();
C.box.put("colorful", value);
C.settings["colorful"] = value;
C.onChanged();
},
)),
Expand All @@ -468,27 +468,27 @@ class _SettingsPageState extends State<SettingsPage> {
child: Center(
child: ListTile(
title: Text(
"Colorful".tr(),
"Darker Colors".tr(),
style: TextStyle(
fontSize: title,
fontWeight: FontWeight.w400,
color: C.theme.onSurfaceVariant),
),
subtitle: Text(
"sColorful".tr(),
"sDarker Colors".tr(),
style: TextStyle(
fontSize: subtitle,
fontWeight: FontWeight.w300,
color: C.theme.onSurfaceVariant),
),
trailing: SwitcherButton(
onColor: C.settings["colorful"] ? C.colors[8] : primaryColor,
onColor: C.settings["colorful"] ? C.colors[6] : primaryColor,
offColor: C.theme.primaryContainer,
size: switchSize,
value: C.settings["colorful"],
value: C.settings["darkColors"],
onChange: (bool value) {
C.box.put("colorful", value);
C.settings["colorful"] = value;
C.box.put("darkColors", value);
C.settings["darkColors"] = value;
C.onChanged();
},
)),
Expand Down
6 changes: 2 additions & 4 deletions lib/Screens/SideBar/voice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:notes/Screens/Actions/create_voice.dart';
import 'package:notes/main.dart';

class VoiceNotesPage extends StatefulWidget {
const VoiceNotesPage({Key? key}) : super(key: key);
const VoiceNotesPage({super.key});

@override
State<VoiceNotesPage> createState() => _VoiceNotesPageState();
Expand All @@ -34,9 +34,7 @@ class _VoiceNotesPageState extends State<VoiceNotesPage> {
builder: (context, state) {
notes = (searchOn ? C.notes['voiceSearched'] : C.notes['voiceNotes'])!;
return Scaffold(
backgroundColor: C.isDark
? C.theme.background
: C.theme.surfaceVariant.withOpacity(0.6),
backgroundColor: C.isDark ? C.theme.background : C.theme.surfaceVariant.withOpacity(0.6),
floatingActionButtonLocation: C.settings["fabIndex"] == 0
? FloatingActionButtonLocation.endFloat
: FloatingActionButtonLocation.startFloat,
Expand Down
2 changes: 1 addition & 1 deletion lib/Screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:notes/main.dart';
late Color primaryColor;

class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
const Home({super.key});

@override
State<Home> createState() => _HomeState();
Expand Down
8 changes: 7 additions & 1 deletion lib/Screens/on_boarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:lottie/lottie.dart';
import 'package:notes/Screens/home_screen.dart';

class IntroPage extends StatefulWidget {
const IntroPage({Key? key}) : super(key: key);
const IntroPage({super.key});

@override
State<IntroPage> createState() => _IntroPageState();
Expand All @@ -20,6 +20,12 @@ class _IntroPageState extends State<IntroPage> {
bool lang = false;
late bool isDarkMode;

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
void didChangeDependencies() {
C.theme = Theme.of(context).colorScheme;
Expand Down
Loading

0 comments on commit ba418a6

Please sign in to comment.