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';
|
||||
|
||||
/// A button that represents a card action.
|
||||
class ActionButton extends StatelessWidget {
|
||||
/// Function to be called when the button is pressed
|
||||
final VoidCallback onPressed;
|
||||
|
|
@ -29,7 +30,7 @@ class ActionButton extends StatelessWidget {
|
|||
final double radius;
|
||||
|
||||
ActionButton({
|
||||
this.onPressed,
|
||||
@required this.onPressed,
|
||||
this.color = const Color(0xFF2C2F34),
|
||||
this.textColor = Colors.white,
|
||||
this.leadingIconData,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,20 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A 3 line text input with progress indicator that matches the mocks.
|
||||
class BigTextInput extends StatefulWidget {
|
||||
/// The height of the input.
|
||||
final double height;
|
||||
|
||||
/// The width of the input.
|
||||
final double width;
|
||||
|
||||
/// Wether the containing card show elevation or not.
|
||||
final bool elevated;
|
||||
|
||||
/// Method to be executed when the text is updated.
|
||||
final Function(String) onChanged;
|
||||
|
||||
/// The initial value for the input.
|
||||
final String initialValue;
|
||||
|
||||
BigTextInput({
|
||||
|
|
@ -20,14 +30,17 @@ class BigTextInput extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _BigTextInputState extends State<BigTextInput> {
|
||||
/// Custom controller for the text input.
|
||||
TextEditingController _controller;
|
||||
|
||||
/// Setus up the controller.
|
||||
void initState() {
|
||||
_controller = TextEditingController(text: widget.initialValue);
|
||||
_controller.addListener(controllerListener);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
/// Calls [onChanged] when updates are sent by the controller.
|
||||
void controllerListener() {
|
||||
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
|
||||
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({
|
||||
this.child,
|
||||
this.widthFactor,
|
||||
this.heightFactor,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final double widthFactor;
|
||||
final double heightFactor;
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
final size = MediaQuery.of(context).size;
|
||||
return Container(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ import 'package:flutter/material.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 {
|
||||
/// The border radius of the button.
|
||||
final double radius;
|
||||
|
|
@ -18,10 +22,18 @@ class GradientTouchableContainer extends StatelessWidget {
|
|||
/// Function to be called when the button is pressed.
|
||||
final VoidCallback onTap;
|
||||
|
||||
/// Shadow to be casted by the container.
|
||||
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;
|
||||
|
||||
/// Whether or not the tap functionality is enabled.
|
||||
///
|
||||
/// Changes the background to grey if set to false.
|
||||
final bool enabled;
|
||||
|
||||
GradientTouchableContainer({
|
||||
|
|
|
|||
|
|
@ -3,8 +3,18 @@ import 'package:font_awesome_flutter/font_awesome_flutter.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 {
|
||||
/// Url for the user avatar.
|
||||
///
|
||||
/// A placeholder is shown if null.
|
||||
final String avatarUrl;
|
||||
|
||||
/// Text to be shown as a subtitle.
|
||||
final String subtitle;
|
||||
|
||||
HomeAppBar({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import 'package:flare_flutter/flare_actor.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Loading indicator.
|
||||
///
|
||||
/// Shows an animation of the logo.
|
||||
class LoadingIndicator extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
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
|
||||
/// button is pressed.
|
||||
class NewItemDialogButton extends StatelessWidget {
|
||||
/// Function to be called on tap gesture.
|
||||
final VoidCallback onTap;
|
||||
|
||||
/// Label to be shown on top of the action button.
|
||||
final String label;
|
||||
|
||||
NewItemDialogButton({
|
||||
|
|
|
|||
|
|
@ -4,8 +4,14 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|||
import '../models/task_model.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
/// A wdiget that lets you select the priority of a task.
|
||||
class PrioritySelector extends StatefulWidget {
|
||||
/// Width of the selector.
|
||||
///
|
||||
/// If none is provided it expands as much as it can horizontally.
|
||||
final double width;
|
||||
|
||||
/// Function to be called when the current selected priority changes.
|
||||
final Function(TaskPriority) onChage;
|
||||
|
||||
PrioritySelector({
|
||||
|
|
@ -35,7 +41,7 @@ class _PrioritySelectorState extends State<PrioritySelector> {
|
|||
Expanded(
|
||||
flex: 8,
|
||||
child: GestureDetector(
|
||||
onTap: () => setPriority(TaskPriority.high),
|
||||
onTap: () => updatePriority(TaskPriority.high),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: kHighPriorityColor,
|
||||
|
|
@ -52,7 +58,7 @@ class _PrioritySelectorState extends State<PrioritySelector> {
|
|||
Expanded(
|
||||
flex: 8,
|
||||
child: GestureDetector(
|
||||
onTap: () => setPriority(TaskPriority.medium),
|
||||
onTap: () => updatePriority(TaskPriority.medium),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: kMediumPriorityColor,
|
||||
|
|
@ -68,7 +74,7 @@ class _PrioritySelectorState extends State<PrioritySelector> {
|
|||
),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => setPriority(TaskPriority.low),
|
||||
onTap: () => updatePriority(TaskPriority.low),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
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);
|
||||
setState(() {
|
||||
selectedPriority = priority;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|||
import './gradient_touchable_container.dart';
|
||||
|
||||
//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 {
|
||||
/// Height of the sarch box.
|
||||
final double height;
|
||||
|
||||
SearchBox({@required this.height}) : assert(height >= 50);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import '../models/task_model.dart';
|
|||
import '../utils.dart';
|
||||
import '../widgets/action_button.dart';
|
||||
|
||||
/// A card that visually represents a task.
|
||||
class TaskListTile extends StatelessWidget {
|
||||
/// Task model which this card represents.
|
||||
final TaskModel task;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue