From 6c564cc2d0705af1f8baf4570ab72be09e55ed2b Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Fri, 5 Apr 2019 16:19:00 -0600 Subject: [PATCH] Added docs for all widgets --- lib/src/widgets/action_button.dart | 3 ++- lib/src/widgets/big_text_input.dart | 13 +++++++++++++ .../widgets/fractionally_screen_sized_box.dart | 13 +++++++++---- lib/src/widgets/gradient_touchable_container.dart | 12 ++++++++++++ lib/src/widgets/home_app_bar.dart | 10 ++++++++++ lib/src/widgets/loading_indicator.dart | 3 +++ lib/src/widgets/new_item_dialog_button.dart | 3 +++ lib/src/widgets/priority_selector.dart | 15 +++++++++++---- lib/src/widgets/search-box.dart | 3 +++ lib/src/widgets/task_list_tile.dart | 1 + 10 files changed, 67 insertions(+), 9 deletions(-) diff --git a/lib/src/widgets/action_button.dart b/lib/src/widgets/action_button.dart index d0fa1ff..03047d6 100644 --- a/lib/src/widgets/action_button.dart +++ b/lib/src/widgets/action_button.dart @@ -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, diff --git a/lib/src/widgets/big_text_input.dart b/lib/src/widgets/big_text_input.dart index 9f0f748..3e5d61d 100644 --- a/lib/src/widgets/big_text_input.dart +++ b/lib/src/widgets/big_text_input.dart @@ -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 { + /// 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); } diff --git a/lib/src/widgets/fractionally_screen_sized_box.dart b/lib/src/widgets/fractionally_screen_sized_box.dart index f14eeb9..e2a54d6 100644 --- a/lib/src/widgets/fractionally_screen_sized_box.dart +++ b/lib/src/widgets/fractionally_screen_sized_box.dart @@ -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( diff --git a/lib/src/widgets/gradient_touchable_container.dart b/lib/src/widgets/gradient_touchable_container.dart index 5bad018..32b86c0 100644 --- a/lib/src/widgets/gradient_touchable_container.dart +++ b/lib/src/widgets/gradient_touchable_container.dart @@ -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({ diff --git a/lib/src/widgets/home_app_bar.dart b/lib/src/widgets/home_app_bar.dart index 05e4a5c..590b537 100644 --- a/lib/src/widgets/home_app_bar.dart +++ b/lib/src/widgets/home_app_bar.dart @@ -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({ diff --git a/lib/src/widgets/loading_indicator.dart b/lib/src/widgets/loading_indicator.dart index 7bdbe48..91b0c7a 100644 --- a/lib/src/widgets/loading_indicator.dart +++ b/lib/src/widgets/loading_indicator.dart @@ -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( diff --git a/lib/src/widgets/new_item_dialog_button.dart b/lib/src/widgets/new_item_dialog_button.dart index f4d9175..c677605 100644 --- a/lib/src/widgets/new_item_dialog_button.dart +++ b/lib/src/widgets/new_item_dialog_button.dart @@ -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({ diff --git a/lib/src/widgets/priority_selector.dart b/lib/src/widgets/priority_selector.dart index 4899f9e..4a8b2f2 100644 --- a/lib/src/widgets/priority_selector.dart +++ b/lib/src/widgets/priority_selector.dart @@ -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 { 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 { 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 { ), 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 { ); } - 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; diff --git a/lib/src/widgets/search-box.dart b/lib/src/widgets/search-box.dart index be62b1e..3add018 100644 --- a/lib/src/widgets/search-box.dart +++ b/lib/src/widgets/search-box.dart @@ -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); diff --git a/lib/src/widgets/task_list_tile.dart b/lib/src/widgets/task_list_tile.dart index d9e869b..d6922bd 100644 --- a/lib/src/widgets/task_list_tile.dart +++ b/lib/src/widgets/task_list_tile.dart @@ -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;