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

Event expression #1215

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ class ChooseExpressionSheet extends StatelessWidget {
currentExpressionType: currentExpressionType,
switchExpressionType: chooseExpressionType,
),
// Temp disable event expression
// CreateExpressionIcon(
// expressionType: ExpressionType.event,
// currentExpressionType: currentExpressionType,
// switchExpressionType: chooseExpressionType,
// ),
CreateExpressionIcon(
expressionType: ExpressionType.event,
currentExpressionType: currentExpressionType,
switchExpressionType: chooseExpressionType,
),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class CreateExpressionScaffoldState extends State<CreateExpressionScaffold>
break;
case ExpressionType.event:
expressionHasData = _eventKey.currentState.expressionHasData();
validationText = 'Make sure text fields are blank.';
validationText = 'Make sure name of the event & phot is not empty.';
break;

default:
Expand Down
54 changes: 53 additions & 1 deletion lib/screens/create/create_review/event_review.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

class CreateEventReview extends StatelessWidget {
const CreateEventReview({Key key, this.expression}) : super(key: key);
Expand All @@ -7,6 +8,57 @@ class CreateEventReview extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container();
final startDate = DateTime.parse(expression['startTime']);
final endDate = DateTime.parse(expression['endTime']);

final formatter = DateFormat('dd-MMM-yyyy hh:m:s');

final startTime = formatter.format(startDate);
final endTime = formatter.format(endDate);

return Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
expression['title'],
style: Theme.of(context).textTheme.headline6,
),
const SizedBox(height: 10),
Container(
width: MediaQuery.of(context).size.width,
height: (MediaQuery.of(context).size.width / 3) * 2,
color: Theme.of(context).dividerColor,
child: Image.file(
expression['photo'],
fit: BoxFit.cover,
),
),
const SizedBox(height: 10),
Text(
'Start Time: $startTime',
style: Theme.of(context).textTheme.caption,
),
const SizedBox(height: 10),
Text(
'End Time: $endTime',
style: Theme.of(context).textTheme.caption,
),
const SizedBox(height: 10),
if (expression['location'].length != 0)
Text(
'Location: ${expression['location']}',
style: Theme.of(context).textTheme.caption,
),
const SizedBox(height: 10),
if (expression['description'].length != 0)
Text(
'Details: ${expression['description']}',
style: Theme.of(context).textTheme.caption,
),
],
),
);
}
}
6 changes: 3 additions & 3 deletions lib/screens/create/create_templates/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class CreateEventState extends State<CreateEvent> with DateParser {
Map<String, dynamic> createExpression() {
return {
'title': titleController.value.text.trim(),
'description': detailsController.value.text.trim(),
'location': locationController.value.text.trim(),
'description': detailsController.value.text.trim() ?? '',
'location': locationController.value.text.trim() ?? '',
'photo': imageFile.value != null ? File(imageFile.value.path) : null,
'startTime': startTime.value.toUtc().toIso8601String(),
'endTime': endTime.value.toUtc().toIso8601String(),
Expand All @@ -84,7 +84,7 @@ class CreateEventState extends State<CreateEvent> with DateParser {
bool expressionHasData() {
final dynamic expression = createExpression();

if (expression['title'].isNotEmpty) {
if (expression['title'].isNotEmpty && expression['photo'] != null) {
return true;
}

Expand Down
47 changes: 34 additions & 13 deletions lib/screens/expression_open/expressions/event_open.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:junto_beta_mobile/models/expression.dart';
import 'package:junto_beta_mobile/widgets/image_wrapper.dart';
import 'package:intl/intl.dart';

class EventOpen extends StatelessWidget {
const EventOpen(this.expression);
Expand All @@ -20,6 +21,14 @@ class EventOpen extends StatelessWidget {
final String eventImage = eventExpression.photo;
final String eventDescription = eventExpression.description;

final startDate = DateTime.parse(eventStartTime);
final endDate = DateTime.parse(eventEndTime);

final formatter = DateFormat('dd-MMM-yyyy hh:m:s');

final startTime = formatter.format(startDate);
final endTime = formatter.format(endDate);

return Container(
child: Column(
children: <Widget>[
Expand Down Expand Up @@ -69,19 +78,31 @@ class EventOpen extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Padding(
// padding: const EdgeInsets.symmetric(
// horizontal: 10, vertical: 10),
// child: Row(
// children: <Widget>[
// Icon(Icons.timer,
// color: Theme.of(context).primaryColor, size: 20),
// const SizedBox(width: 5),
// Text(eventStartTime,
// style: Theme.of(context).textTheme.caption),
// ],
// ),
// ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
children: <Widget>[
Icon(Icons.timer,
color: Theme.of(context).primaryColor, size: 20),
const SizedBox(width: 5),
Text(startTime,
style: Theme.of(context).textTheme.caption),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 10),
child: Row(
children: <Widget>[
Icon(Icons.timer,
color: Theme.of(context).primaryColor, size: 20),
const SizedBox(width: 5),
Text(endTime,
style: Theme.of(context).textTheme.caption),
],
),
),
eventLocation != ''
? Padding(
padding: const EdgeInsets.only(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ class EventPreview extends StatelessWidget {
Text(expression.expressionData.title,
style: Theme.of(context).textTheme.headline6),
const SizedBox(height: 2.5),
Text(
expression.expressionData.location,
style: Theme.of(context).textTheme.bodyText1,
),
if (expression.expressionData.location.length > 0)
Text(
expression.expressionData.location,
style: Theme.of(context).textTheme.bodyText1,
),
],
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class TwoColumnExpressionPreview extends StatelessWidget with MemberValidation {
else if (expression.type == 'PhotoForm')
PhotoPreview(expression: expression)
else if (expression.type == 'EventForm')
SizedBox()
// EventPreview(expression: expression)
EventPreview(expression: expression)
else if (expression.type == 'AudioForm')
AudioPreview(expression: expression)
else if (expression.type == 'LongForm')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class EventPreview extends StatelessWidget {
Text(expression.expressionData.title,
style: Theme.of(context).textTheme.headline6),
const SizedBox(height: 2.5),
Text(
expression.expressionData.location,
style: Theme.of(context).textTheme.bodyText1,
),
if (expression.expressionData.location.length > 0)
Text(
expression.expressionData.location,
style: Theme.of(context).textTheme.bodyText1,
),
],
),
)
Expand Down