Moved repeated text styles to utils, Finished the UI for the Add image screen
This commit is contained in:
parent
85aadb15b5
commit
59f4cc099e
6 changed files with 122 additions and 16 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
|
||||
|
|
@ -7,4 +8,16 @@ import '../models/user_model.dart';
|
|||
import '../resources/authService.dart';
|
||||
import '../resources/firestore_provider.dart';
|
||||
|
||||
class NewImageBloc {}
|
||||
class NewImageBloc {
|
||||
final _picture = BehaviorSubject<File>();
|
||||
|
||||
//Stream getters.
|
||||
Observable<File> get picture => _picture.stream;
|
||||
|
||||
//Sink getters.
|
||||
Function(File) get addPicture => _picture.sink.add;
|
||||
|
||||
void dispose() {
|
||||
_picture.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import '../blocs/new_image_bloc.dart';
|
||||
import '../widgets/custom_app_bar.dart';
|
||||
import '../widgets/custom_dropdown.dart';
|
||||
import '../widgets/gradient_touchable_container.dart';
|
||||
|
||||
class NewImageScreen extends StatefulWidget {
|
||||
_NewImageScreenState createState() => _NewImageScreenState();
|
||||
|
|
@ -15,6 +22,87 @@ class _NewImageScreenState extends State<NewImageScreen> {
|
|||
appBar: CustomAppBar(
|
||||
title: 'Add image',
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(left: 10.0, right: 10.0, top: 10.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => takePicture(),
|
||||
child: Container(
|
||||
height: 300,
|
||||
color: Theme.of(context).cardColor,
|
||||
child: StreamBuilder(
|
||||
stream: bloc.picture,
|
||||
builder: (BuildContext context, AsyncSnapshot<File> snap) {
|
||||
if (!snap.hasData) {
|
||||
return Center(
|
||||
child: Text(
|
||||
'Tap to take picture',
|
||||
style: kSmallTextStyle,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Image.file(
|
||||
snap.data,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
buildEventSection(),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
GradientTouchableContainer(
|
||||
height: 40,
|
||||
width: 350,
|
||||
radius: 8,
|
||||
onTap: () {},
|
||||
child: Text(
|
||||
'Submit',
|
||||
style: kSmallTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> takePicture() async {
|
||||
final File imgFile = await ImagePicker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
);
|
||||
bloc.addPicture(imgFile);
|
||||
}
|
||||
|
||||
Widget buildEventSection() {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Event',
|
||||
style: kBigTextStyle,
|
||||
),
|
||||
Spacer(),
|
||||
CustomDropdownButton(
|
||||
width: 200,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
bloc.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import '../blocs/new_task_bloc.dart';
|
||||
import '../models/user_model.dart';
|
||||
import '../widgets/custom_app_bar.dart';
|
||||
|
|
@ -14,17 +15,6 @@ class NewTaskScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _NewTaskScreenState extends State<NewTaskScreen> {
|
||||
static const kLabelStyle = TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
static const kButtonStyle = TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
|
||||
final NewTaskBloc bloc = NewTaskBloc();
|
||||
String dropdownValue;
|
||||
|
||||
|
|
@ -68,7 +58,7 @@ class _NewTaskScreenState extends State<NewTaskScreen> {
|
|||
onTap: () => onSubmit(context, bloc),
|
||||
child: Text(
|
||||
'Submit',
|
||||
style: kButtonStyle,
|
||||
style: kSmallTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -84,7 +74,7 @@ class _NewTaskScreenState extends State<NewTaskScreen> {
|
|||
children: <Widget>[
|
||||
Text(
|
||||
'Event',
|
||||
style: kLabelStyle,
|
||||
style: kBigTextStyle,
|
||||
),
|
||||
Spacer(),
|
||||
CustomDropdownButton(
|
||||
|
|
@ -111,7 +101,7 @@ class _NewTaskScreenState extends State<NewTaskScreen> {
|
|||
children: <Widget>[
|
||||
Text(
|
||||
'Priority',
|
||||
style: kLabelStyle,
|
||||
style: kBigTextStyle,
|
||||
),
|
||||
Spacer(),
|
||||
PrioritySelector(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,17 @@ const kLowPriorityColor = Color(0xFF06AD12);
|
|||
const kMediumPriorityColor = Color(0xFFF6A93B);
|
||||
const kHighPriorityColor = Color(0xFFF42850);
|
||||
|
||||
const kBigTextStyle = TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
const kSmallTextStyle = TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
|
||||
Color getColorFromPriority(TaskPriority priority) {
|
||||
switch (priority) {
|
||||
case TaskPriority.low:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ const EdgeInsets _kAlignedMenuMargin = EdgeInsets.zero;
|
|||
const EdgeInsetsGeometry _kUnalignedMenuMargin =
|
||||
EdgeInsetsDirectional.only(start: 16.0, end: 24.0);
|
||||
|
||||
//TODO: Refactor to allow expansion if no width is provided.
|
||||
|
||||
class _DropdownMenuPainter extends CustomPainter {
|
||||
_DropdownMenuPainter({
|
||||
this.color,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
//TODO: Refactor to allow expansion if no width is provided.
|
||||
|
||||
class GradientTouchableContainer extends StatelessWidget {
|
||||
/// The border radius of the button.
|
||||
final double radius;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue