Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create theme for the app both dark and light #41

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/dialogues/add_cartegory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AddCategoryDialog {
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Color.fromARGB(235, 255, 255, 255),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35.0),
),
Expand Down
8 changes: 4 additions & 4 deletions lib/dialogues/rate_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _AppRatingDialogState extends State<AppRatingDialog> {
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Theme.of(context).secondaryHeaderColor,
Theme.of(context).colorScheme.secondary,
Theme.of(context).cardColor,
],
),
Expand Down Expand Up @@ -97,7 +97,7 @@ class _AppRatingDialogState extends State<AppRatingDialog> {
style: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.bold,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.primary,
),
),
SizedBox(height: 10.0),
Expand All @@ -124,7 +124,7 @@ class _AppRatingDialogState extends State<AppRatingDialog> {
},
icon: Icon(
index < selectedStars ? Icons.star : Icons.star_border,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.secondary,
size: 40.0,
),
);
Expand Down Expand Up @@ -158,7 +158,7 @@ class _AppRatingDialogState extends State<AppRatingDialog> {
return Icon(
emojiIcon,
size: 80.0,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.secondary,
);
}

Expand Down
29 changes: 4 additions & 25 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:Organiser/firebase_options.dart';
import 'package:Organiser/providers/user_provider.dart';
import 'package:Organiser/pages/theme/theme_provider.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
Expand All @@ -21,7 +21,7 @@ Future<void> main() async {

runApp(
ChangeNotifierProvider(
create: (context) => UserProvider(),
create: (context) => ThemeProvider(),
child: OrganiserApp(),
),
);
Expand All @@ -40,29 +40,8 @@ class _OrganiserAppState extends State<OrganiserApp> {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
));

var colorPrimary = Colors.blue;

var myColor = ThemeData(
primarySwatch: colorPrimary,
).secondaryHeaderColor;
var textColor = ThemeData(
primarySwatch: colorPrimary,
).primaryColor;

return MaterialApp(
theme: ThemeData(
outlinedButtonTheme: OutlinedButtonThemeData(),
primarySwatch: colorPrimary,
appBarTheme: AppBarTheme(
backgroundColor: myColor,
foregroundColor: textColor,
elevation: 1,
),
expansionTileTheme: ExpansionTileThemeData(
shape: Border.all(color: Colors.transparent, width: 0),
collapsedShape: Border.all(color: Colors.transparent, width: 0),
childrenPadding: EdgeInsets.all(20))),
return MaterialApp(
theme: Provider.of<ThemeProvider>(context).themeData,
home: SplashScreen(
onSelectThemeColor: () {},
),
Expand Down
7 changes: 5 additions & 2 deletions lib/models/collection/sub/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

class Event with ChangeNotifier {
String id = "";
String priority;
String title;
String notes;
String category;
Expand All @@ -17,6 +18,7 @@ class Event with ChangeNotifier {
Event({
required this.title,
required this.notes,
required this.priority,
required this.category,
required this.tags,
required this.photoURL,
Expand All @@ -32,6 +34,7 @@ class Event with ChangeNotifier {
factory Event.fromMap(Map<String, dynamic> data, String documentId) {
return Event(
title: data['title'],
priority: data['priority'],
notes: data['description'],
category: data['category'],
tags: List<String>.from(data['tags']),
Expand All @@ -41,14 +44,15 @@ class Event with ChangeNotifier {
repetition: List<Map<RepeatFrequency, List>>.from(data['repetition']),
location: List<Map<String, String>>.from(data['location']),
ticketCost: data['ticketCost'],
numberOfTickets: data['numberOfTickets'],
numberOfTickets: data['numberOfTickets'],
);
}

// Method to convert Event instance to a map for Firebase
Map<String, dynamic> toMap() {
return {
'title': title,
'priority': priority,
'notes': notes,
'category': category,
'tags': tags,
Expand Down Expand Up @@ -78,7 +82,6 @@ enum RepeatFrequency {
Yearly,
}


enum ReferenceType {
task,
event,
Expand Down
21 changes: 17 additions & 4 deletions lib/pages/create/add_event.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:Organiser/widgets/styled/input_adder/repeat.dart';
import 'package:Organiser/widgets/styled/input_adder/timezone.dart';
import 'package:flutter/material.dart';
import 'package:Organiser/models/collection/sub/event.dart';
import 'package:Organiser/models/collection/sub/event_model.dart';
Expand All @@ -23,6 +25,7 @@ class CreateEventPage extends StatefulWidget {
class _CreateEventPageState extends State<CreateEventPage> {
//create a the required controllers for event model
final TextEditingController _titleController = TextEditingController();
final TextEditingController _priorityController = TextEditingController();
final TextEditingController _notesController = TextEditingController();
final TextEditingController _cartegoryController = TextEditingController();
final List<String> _tagsController = [];
Expand All @@ -47,7 +50,9 @@ class _CreateEventPageState extends State<CreateEventPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TitleAdder(titleController: _titleController),
TitleAdder(
titleController: _titleController,
priorityController: _priorityController),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expand All @@ -71,14 +76,21 @@ class _CreateEventPageState extends State<CreateEventPage> {
dateAndTimeController: _dateAndTimeController,
),
SizedBox(height: 16.0),
TicketsAdder(
ticketsController: _ticketsController,
costPerTicketController: _ticketCostController,
RepeatAdderWidget(
repeatOnController: _isRepetingController,
repeatController: _repetitionController,
),
SizedBox(height: 16.0),
LocationAdder(
locationController: _locationController,
),
SizedBox(height: 16.0),
TicketsAdder(
ticketsController: _ticketsController,
costPerTicketController: _ticketCostController,
),
SizedBox(height: 16.0),
TimeZoneAdder()
],
),
),
Expand All @@ -102,6 +114,7 @@ class _CreateEventPageState extends State<CreateEventPage> {
void createEvent() {
Event newEvent = Event(
title: _titleController.text,
priority: _priorityController.text,
notes: _notesController.text,
category: _cartegoryController.text,
tags: _tagsController,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home/screens/schedules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class _SchedulesState extends State<Schedules> {
return SingleChildScrollView(
child: IntrinsicHeight(
child: Column(
children: [Center(child: Text("Schedules"))],

),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/info/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _AboutPageState extends State<AboutPage> {
children: [
Icon(
icon,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.primary,
size: 25,
),
SizedBox(width: 8.0),
Expand Down
9 changes: 4 additions & 5 deletions lib/pages/info/tips.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ class _TipsPageState extends State<TipsPage> {
}) {

return Card(
elevation: 4,
elevation: 0,
margin: EdgeInsets.symmetric(vertical: 8),
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
Expand All @@ -94,7 +93,7 @@ class _TipsPageState extends State<TipsPage> {
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.primary,
),
),
SizedBox(height: 8),
Expand All @@ -112,15 +111,15 @@ class _TipsPageState extends State<TipsPage> {
onPressed: () => _handleAction(onLike),
icon: Icon(
isLiked ? Icons.thumb_up : Icons.thumb_up_outlined,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.primary,
),
),
Text("$likes Likes"),
IconButton(
onPressed: () => _handleAction(onDislike),
icon: Icon(
isDisliked ? Icons.thumb_down : Icons.thumb_down_outlined,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.primary,
),
),
Text("$dislikes Dislikes"),
Expand Down
1 change: 1 addition & 0 deletions lib/pages/landing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class _LandingPageState extends State<LandingPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
body: StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
Expand Down
5 changes: 2 additions & 3 deletions lib/pages/messages/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ class NotificationCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
elevation: 2,
margin: EdgeInsets.symmetric(vertical: 8),
child: Padding(
padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
Expand Down Expand Up @@ -137,7 +136,7 @@ class NotificationCard extends StatelessWidget {
Icon(
icon,
size: 25,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.primary,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class SettingsScreen extends StatelessWidget {
children: [
Icon(
icon,
color: Theme.of(context).primaryColor,
color: Theme.of(context).colorScheme.primary,
size: 25,
),
SizedBox(width: 20),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class _ThemeSelectionScreenState extends State<ThemeSelectionScreen> {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Theme.of(context).secondaryHeaderColor,
foregroundColor: Theme.of(context).primaryColor,
backgroundColor: Theme.of(context).colorScheme.secondary,
foregroundColor: Theme.of(context).colorScheme.primary,
title: Text("Select Theme Color"),
elevation: 1,
actions: [
Expand Down
31 changes: 31 additions & 0 deletions lib/pages/theme/dark.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';

ThemeData darkMode = ThemeData(
brightness: Brightness.dark,
colorScheme: ColorScheme.dark(
background: Colors.black,
primary: Colors.green.shade200,
secondary: Colors.green.shade800,
),
appBarTheme: AppBarTheme(
centerTitle: true,
backgroundColor: Colors.green.shade800,
foregroundColor: Colors.white,
elevation: 1),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
unselectedItemColor: Colors.grey.shade400.withOpacity(0.8),
selectedItemColor: Colors.green.shade200,
selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 8),
selectedIconTheme: IconThemeData(size: 35),
unselectedIconTheme: IconThemeData(size: 20),
backgroundColor: Colors.green.shade800),
scaffoldBackgroundColor: Colors.grey.shade900,
cardTheme: CardTheme(color: Colors.black12),
shadowColor: Colors.black,
drawerTheme: DrawerThemeData(backgroundColor: Colors.black54),
dialogTheme: DialogTheme(
backgroundColor: Colors.grey.shade800.withOpacity(0.9),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)),
),

);
32 changes: 32 additions & 0 deletions lib/pages/theme/light.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';

ThemeData lightMode = ThemeData(
cardTheme: CardTheme(color: Colors.white, elevation: 1),
drawerTheme:
DrawerThemeData(backgroundColor: Colors.green.shade50.withOpacity(0.9)),
scaffoldBackgroundColor: Colors.grey.shade50,
brightness: Brightness.light,
colorScheme: ColorScheme.light(
background: Colors.grey.shade400,
primary: Colors.green,
secondary: Colors.green.shade50,
),
appBarTheme: AppBarTheme(
centerTitle: true,
backgroundColor: Colors.green.shade50,
foregroundColor: Colors.black87,
elevation: 1),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
unselectedItemColor: Colors.black38,
selectedItemColor: Colors.green,
selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 8),
selectedIconTheme: IconThemeData(size: 35),
unselectedIconTheme: IconThemeData(size: 20),
backgroundColor: Colors.green.shade50),
dialogTheme: DialogTheme(
backgroundColor: Colors.green.shade50.withOpacity(0.95),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)),
),
shadowColor: Colors.grey.shade200,

);
Loading