Added docs for all widgets
This commit is contained in:
parent
a1ca34495e
commit
6c564cc2d0
10 changed files with 67 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// A button that represents a card action.
|
||||||
class ActionButton extends StatelessWidget {
|
class ActionButton extends StatelessWidget {
|
||||||
/// Function to be called when the button is pressed
|
/// Function to be called when the button is pressed
|
||||||
final VoidCallback onPressed;
|
final VoidCallback onPressed;
|
||||||
|
|
@ -29,7 +30,7 @@ class ActionButton extends StatelessWidget {
|
||||||
final double radius;
|
final double radius;
|
||||||
|
|
||||||
ActionButton({
|
ActionButton({
|
||||||
this.onPressed,
|
@required this.onPressed,
|
||||||
this.color = const Color(0xFF2C2F34),
|
this.color = const Color(0xFF2C2F34),
|
||||||
this.textColor = Colors.white,
|
this.textColor = Colors.white,
|
||||||
this.leadingIconData,
|
this.leadingIconData,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,20 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// A 3 line text input with progress indicator that matches the mocks.
|
||||||
class BigTextInput extends StatefulWidget {
|
class BigTextInput extends StatefulWidget {
|
||||||
|
/// The height of the input.
|
||||||
final double height;
|
final double height;
|
||||||
|
|
||||||
|
/// The width of the input.
|
||||||
final double width;
|
final double width;
|
||||||
|
|
||||||
|
/// Wether the containing card show elevation or not.
|
||||||
final bool elevated;
|
final bool elevated;
|
||||||
|
|
||||||
|
/// Method to be executed when the text is updated.
|
||||||
final Function(String) onChanged;
|
final Function(String) onChanged;
|
||||||
|
|
||||||
|
/// The initial value for the input.
|
||||||
final String initialValue;
|
final String initialValue;
|
||||||
|
|
||||||
BigTextInput({
|
BigTextInput({
|
||||||
|
|
@ -20,14 +30,17 @@ class BigTextInput extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BigTextInputState extends State<BigTextInput> {
|
class _BigTextInputState extends State<BigTextInput> {
|
||||||
|
/// Custom controller for the text input.
|
||||||
TextEditingController _controller;
|
TextEditingController _controller;
|
||||||
|
|
||||||
|
/// Setus up the controller.
|
||||||
void initState() {
|
void initState() {
|
||||||
_controller = TextEditingController(text: widget.initialValue);
|
_controller = TextEditingController(text: widget.initialValue);
|
||||||
_controller.addListener(controllerListener);
|
_controller.addListener(controllerListener);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Calls [onChanged] when updates are sent by the controller.
|
||||||
void controllerListener() {
|
void controllerListener() {
|
||||||
widget.onChanged(_controller.text);
|
widget.onChanged(_controller.text);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,21 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// A widget that sizes its child to a fraction of the size of the screen
|
/// A widget that sizes its child to a fraction of the size of the screen
|
||||||
class FractionallyScreenSizedBox extends StatelessWidget {
|
class FractionallyScreenSizedBox extends StatelessWidget {
|
||||||
|
/// The child to be rendered inside the box.
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
/// The fraction of the screen width the child will use.
|
||||||
|
final double widthFactor;
|
||||||
|
|
||||||
|
/// The fraction of the screen height the child will use.
|
||||||
|
final double heightFactor;
|
||||||
|
|
||||||
FractionallyScreenSizedBox({
|
FractionallyScreenSizedBox({
|
||||||
this.child,
|
this.child,
|
||||||
this.widthFactor,
|
this.widthFactor,
|
||||||
this.heightFactor,
|
this.heightFactor,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Widget child;
|
|
||||||
final double widthFactor;
|
|
||||||
final double heightFactor;
|
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
return Container(
|
return Container(
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../utils.dart';
|
import '../utils.dart';
|
||||||
|
|
||||||
|
/// A container that has the apps custom gradient as its background.
|
||||||
|
///
|
||||||
|
/// The optional [onTap] gets called if provided when the onTap gesture is
|
||||||
|
/// detected.
|
||||||
class GradientTouchableContainer extends StatelessWidget {
|
class GradientTouchableContainer extends StatelessWidget {
|
||||||
/// The border radius of the button.
|
/// The border radius of the button.
|
||||||
final double radius;
|
final double radius;
|
||||||
|
|
@ -18,10 +22,18 @@ class GradientTouchableContainer extends StatelessWidget {
|
||||||
/// Function to be called when the button is pressed.
|
/// Function to be called when the button is pressed.
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
/// Shadow to be casted by the container.
|
||||||
final BoxShadow shadow;
|
final BoxShadow shadow;
|
||||||
|
|
||||||
|
/// Whether the container is expanded horizontally or not.
|
||||||
|
///
|
||||||
|
/// The container will have an unbound width if set to true and it should not
|
||||||
|
/// be put inside a row without constraints.
|
||||||
final bool isExpanded;
|
final bool isExpanded;
|
||||||
|
|
||||||
|
/// Whether or not the tap functionality is enabled.
|
||||||
|
///
|
||||||
|
/// Changes the background to grey if set to false.
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
|
|
||||||
GradientTouchableContainer({
|
GradientTouchableContainer({
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,18 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
import './logo.dart';
|
import './logo.dart';
|
||||||
|
|
||||||
|
//TODO: Add callback for the menu button.
|
||||||
|
|
||||||
|
/// Custom app bar with avatar and menu button.
|
||||||
|
///
|
||||||
|
/// Only to be used in the home scree.
|
||||||
class HomeAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class HomeAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
/// Url for the user avatar.
|
||||||
|
///
|
||||||
|
/// A placeholder is shown if null.
|
||||||
final String avatarUrl;
|
final String avatarUrl;
|
||||||
|
|
||||||
|
/// Text to be shown as a subtitle.
|
||||||
final String subtitle;
|
final String subtitle;
|
||||||
|
|
||||||
HomeAppBar({
|
HomeAppBar({
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
import 'package:flare_flutter/flare_actor.dart';
|
import 'package:flare_flutter/flare_actor.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// Loading indicator.
|
||||||
|
///
|
||||||
|
/// Shows an animation of the logo.
|
||||||
class LoadingIndicator extends StatelessWidget {
|
class LoadingIndicator extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
/// Let's you specify the text shown and the action to perform when the circular
|
/// Let's you specify the text shown and the action to perform when the circular
|
||||||
/// button is pressed.
|
/// button is pressed.
|
||||||
class NewItemDialogButton extends StatelessWidget {
|
class NewItemDialogButton extends StatelessWidget {
|
||||||
|
/// Function to be called on tap gesture.
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
/// Label to be shown on top of the action button.
|
||||||
final String label;
|
final String label;
|
||||||
|
|
||||||
NewItemDialogButton({
|
NewItemDialogButton({
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,14 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import '../models/task_model.dart';
|
import '../models/task_model.dart';
|
||||||
import '../utils.dart';
|
import '../utils.dart';
|
||||||
|
|
||||||
|
/// A wdiget that lets you select the priority of a task.
|
||||||
class PrioritySelector extends StatefulWidget {
|
class PrioritySelector extends StatefulWidget {
|
||||||
|
/// Width of the selector.
|
||||||
|
///
|
||||||
|
/// If none is provided it expands as much as it can horizontally.
|
||||||
final double width;
|
final double width;
|
||||||
|
|
||||||
|
/// Function to be called when the current selected priority changes.
|
||||||
final Function(TaskPriority) onChage;
|
final Function(TaskPriority) onChage;
|
||||||
|
|
||||||
PrioritySelector({
|
PrioritySelector({
|
||||||
|
|
@ -35,7 +41,7 @@ class _PrioritySelectorState extends State<PrioritySelector> {
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 8,
|
flex: 8,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => setPriority(TaskPriority.high),
|
onTap: () => updatePriority(TaskPriority.high),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: kHighPriorityColor,
|
color: kHighPriorityColor,
|
||||||
|
|
@ -52,7 +58,7 @@ class _PrioritySelectorState extends State<PrioritySelector> {
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 8,
|
flex: 8,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => setPriority(TaskPriority.medium),
|
onTap: () => updatePriority(TaskPriority.medium),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: kMediumPriorityColor,
|
color: kMediumPriorityColor,
|
||||||
|
|
@ -68,7 +74,7 @@ class _PrioritySelectorState extends State<PrioritySelector> {
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => setPriority(TaskPriority.low),
|
onTap: () => updatePriority(TaskPriority.low),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: kLowPriorityColor,
|
color: kLowPriorityColor,
|
||||||
|
|
@ -84,7 +90,8 @@ class _PrioritySelectorState extends State<PrioritySelector> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPriority(TaskPriority priority) {
|
/// Sets the selected priority and calls the onChange method with it.
|
||||||
|
void updatePriority(TaskPriority priority) {
|
||||||
widget.onChage(priority);
|
widget.onChage(priority);
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedPriority = priority;
|
selectedPriority = priority;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import './gradient_touchable_container.dart';
|
import './gradient_touchable_container.dart';
|
||||||
|
|
||||||
//TODO: Add neccessary properties to be able to inform of changes in text field.
|
//TODO: Add neccessary properties to be able to inform of changes in text field.
|
||||||
|
|
||||||
|
/// A search box that mathces the app mocks.
|
||||||
class SearchBox extends StatelessWidget {
|
class SearchBox extends StatelessWidget {
|
||||||
|
/// Height of the sarch box.
|
||||||
final double height;
|
final double height;
|
||||||
|
|
||||||
SearchBox({@required this.height}) : assert(height >= 50);
|
SearchBox({@required this.height}) : assert(height >= 50);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import '../models/task_model.dart';
|
||||||
import '../utils.dart';
|
import '../utils.dart';
|
||||||
import '../widgets/action_button.dart';
|
import '../widgets/action_button.dart';
|
||||||
|
|
||||||
|
/// A card that visually represents a task.
|
||||||
class TaskListTile extends StatelessWidget {
|
class TaskListTile extends StatelessWidget {
|
||||||
/// Task model which this card represents.
|
/// Task model which this card represents.
|
||||||
final TaskModel task;
|
final TaskModel task;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue