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

Task creation form #47

Merged
merged 3 commits into from
May 26, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update input forms
Alidantech committed Mar 31, 2024
commit 2e7ad970c8b3b7736cd06405e6c422b41d358912
2 changes: 1 addition & 1 deletion 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/views/pages/splash.dart';
import 'package:Organiser/views/pages/splash.dart';
import 'package:Organiser/views/services/theme_provider.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
30 changes: 27 additions & 3 deletions lib/models/common/event_model.dart
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ class Event {
String category;
List<String> tags;
String photoURL;
List<Map<DateTime, TimeOfDay>> dateAndTime;
List<Map<DateTime, Map<TimeOfDay, TimeOfDay>>> dateAndTime;
bool isRepeating;
List<Map<RepeatFrequency, List>> repetition;
List<Map<String, String>> location;
@@ -43,7 +43,19 @@ class Event {
category: data['category'],
tags: List<String>.from(data['tags']),
photoURL: data['photoURL'],
dateAndTime: List<Map<DateTime, TimeOfDay>>.from(data['dateAndTime']),
dateAndTime: (data['dateAndTime'] as List<dynamic>).map((entry) {
return (entry as Map<String, dynamic>).map((key, value) {
return MapEntry(
DateTime.parse(key),
(value as Map<String, dynamic>).map((startTimeKey, startTimeValue) {
return MapEntry(
TimeOfDay.fromDateTime(DateTime.parse(startTimeKey)),
TimeOfDay.fromDateTime(DateTime.parse(startTimeValue)),
);
}),
);
});
}).toList(),
isRepeating: data['isRepeating'],
repetition: List<Map<RepeatFrequency, List>>.from(data['repetition']),
location: List<Map<String, String>>.from(data['location']),
@@ -61,7 +73,19 @@ class Event {
'category': category,
'tags': tags,
'photoURL': photoURL,
'dateAndTime': dateAndTime,
'dateAndTime': dateAndTime.map((entry) {
return entry.map((key, value) {
return MapEntry(
key.toIso8601String(),
value.map((startTimeKey, startTimeValue) {
return MapEntry(
startTimeKey,
startTimeValue,
);
}),
);
});
}).toList(),
'isRepeating': isRepeating,
'repetition': repetition,
'location': location,
47 changes: 27 additions & 20 deletions lib/views/pages/forms/add_event.dart
Original file line number Diff line number Diff line change
@@ -25,7 +25,8 @@ class _CreateEventPageState extends State<CreateEventPage> {
final TextEditingController _cartegoryController = TextEditingController();
final List<String> _tagsController = [];
final String _photoUrlController = '';
final Map<DateTime, TimeOfDay> _dateAndTimeController = {};
final List<Map<DateTime, Map<TimeOfDay, TimeOfDay>>> _dateAndTimeController =
[];
final bool _isRepetingController = true;
final Map<RepeatFrequency, List> _repetitionController = {};
final Map<String, String> _locationController = {};
@@ -50,22 +51,25 @@ class _CreateEventPageState extends State<CreateEventPage> {
titleController: _titleController,
priorityController: _priorityController),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
NotesAdder(
notesController: _notesController,
),
CartegoryAdder(
cartegoryController: _cartegoryController,
),
TagsAdder(
selectedTags: _tagsController,
),
ImageAdder(
imageUrlController: _photoUrlController,
),
],
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Wrap(
spacing: 8.0,
children: [
NotesAdder(
notesController: _notesController,
),
CartegoryAdder(
cartegoryController: _cartegoryController,
),
TagsAdder(
selectedTags: _tagsController,
),
ImageAdder(
imageUrlController: _photoUrlController,
),
],
),
),
SizedBox(height: 16.0),
DateAndTimeAdder(
@@ -85,7 +89,8 @@ class _CreateEventPageState extends State<CreateEventPage> {
ticketsController: _ticketsController,
costPerTicketController: _ticketCostController,
),
SizedBox(height: 16.0),
SizedBox(height: 16.0
),
TimezoneAdder(
timezoneConroller: _timezoneConroller,
)
@@ -110,20 +115,22 @@ class _CreateEventPageState extends State<CreateEventPage> {
}

void createEvent() {
// ignore: unused_local_variable
Event newEvent = Event(
title: _titleController.text,
priority: _priorityController.text,
notes: _notesController.text,
category: _cartegoryController.text,
tags: _tagsController,
photoURL: _photoUrlController,
dateAndTime: [_dateAndTimeController],
dateAndTime: _dateAndTimeController,
isRepeating: _isRepetingController,
repetition: [_repetitionController],
location: [_locationController],
ticketCost: _ticketCostController.text as double,
numberOfTickets: _ticketsController.text as int,
timezone: _timezoneConroller.text, id: '');
timezone: _timezoneConroller.text,
id: '');
Navigator.pop(context);
}

1 change: 0 additions & 1 deletion lib/views/widgets/common/action_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:Organiser/config/themes/light.dart';
import 'package:Organiser/controllers/common/event_controller.dart';
import 'package:Organiser/views/pages/forms/add_event.dart';
import 'package:Organiser/views/pages/forms/add_task.dart';
import 'package:Organiser/views/services/theme_provider.dart';
14 changes: 11 additions & 3 deletions lib/views/widgets/common/custom_appbar.dart
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
this.leading,
this.leadingWidth,
this.centerTitle,
this.bottom,
});

@override
@@ -19,9 +20,15 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
scrolledUnderElevation: 0.0,
bottom: PreferredSize(
preferredSize: Size.fromHeight(0.0),
child: Container(
color: Theme.of(context).colorScheme.primary.withOpacity(0.5),
height: 0.3,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (bottom != null) bottom!,
Container(
color: Theme.of(context).colorScheme.primary.withOpacity(0.5),
height: 0.3,
),
],
),
),
title: title,
@@ -37,6 +44,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
final Widget? leading;
final double? leadingWidth;
final bool? centerTitle;
final PreferredSizeWidget? bottom;

@override
Size get preferredSize => Size.fromHeight(kToolbarHeight);
66 changes: 66 additions & 0 deletions lib/views/widgets/common/custom_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';

class CustomDialog extends StatelessWidget {
final Widget child;
final String button1Text;
final String button2Text;
final VoidCallback? onButton1Pressed;
final VoidCallback? onButton2Pressed;

const CustomDialog({
Key? key,
required this.child,
required this.button1Text,
required this.button2Text,
required this.onButton1Pressed,
required this.onButton2Pressed,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Dialog(
insetPadding: EdgeInsets.symmetric(horizontal: 0, vertical: 0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
elevation: 0,
backgroundColor: Colors.transparent,
child: _buildDialogContent(context),
);
}

Widget _buildDialogContent(BuildContext context) {
return Container(
margin: EdgeInsets.all(16),
constraints: BoxConstraints(maxWidth: 500),
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Theme.of(context).scaffoldBackgroundColor.withOpacity(0.97),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Theme.of(context).primaryColor),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
child,
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
onPressed: onButton1Pressed,
child: Text(button1Text),
),
TextButton(
onPressed: onButton2Pressed,
child: Text(button2Text),
),
],
),
],
),
);
}
}
22 changes: 22 additions & 0 deletions lib/views/widgets/common/styled_container.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';

class StyledContainer extends StatelessWidget {
final Widget child;

const StyledContainer({Key? key, required this.child}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Theme.of(context).primaryColor.withOpacity(0.03),
border: Border.all(
color: Theme.of(context).primaryColor.withOpacity(0.5),
width: 0.5,
),
),
child: child,
);
}
}
Loading