Skip to content

Commit

Permalink
Fixes issue AOSSIE-Org#28
Browse files Browse the repository at this point in the history
  • Loading branch information
khushi-hura committed Dec 27, 2024
1 parent b2757a0 commit ba28465
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lib/pages/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../database/database_helper.dart';

/// This the home screen. This can also be considered as the
/// main screen of the application.
/// main screen of the application.
/// As the app launches and navigates to the HomeScreen from the Profile screen,
/// all the processes of message hopping are being initiated from this page.
Expand Down Expand Up @@ -66,7 +66,6 @@ class _HomeScreenState extends State<HomeScreen> {
@override
void initState() {
super.initState();
// init(context);
refreshMessages();
_loadTheme();
}
Expand Down Expand Up @@ -110,11 +109,9 @@ class _HomeScreenState extends State<HomeScreen> {
await prefs.setInt(themePreferenceKey, mode.index);
}

void _toggleTheme() {
void _toggleTheme(bool value) {
setState(() {
_themeMode = _themeMode == ThemeMode.light
? ThemeMode.dark
: ThemeMode.light;
_themeMode = value ? ThemeMode.dark : ThemeMode.light;
});
_saveTheme(_themeMode);
}
Expand All @@ -127,18 +124,19 @@ class _HomeScreenState extends State<HomeScreen> {
data: ThemeData(
brightness: _themeMode == ThemeMode.dark
? Brightness.dark
: Brightness.light,
// You can further customize the theme here if needed
: Brightness.light,
),
child: Scaffold(
key: Global.scaffoldKey,
appBar: AppBar(
title: const Text("AOSSIE"),
actions: [
//toggle button fro light and dark themes
IconButton(
onPressed: _toggleTheme,
icon: Icon(Icons.toggle_off_outlined),
// Slider toggle button for light and dark themes
Switch(
value: _themeMode == ThemeMode.dark,
onChanged: _toggleTheme,
activeColor: Colors.blueAccent,
inactiveThumbColor: Colors.grey,
),
IconButton(
icon: const Icon(Icons.person),
Expand Down Expand Up @@ -177,4 +175,4 @@ class _HomeScreenState extends State<HomeScreen> {
),
);
}
}
}

0 comments on commit ba28465

Please sign in to comment.