Browse Source

docs(neon): document exported widgets

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/1032/head
Nikolas Rimikis 1 year ago
parent
commit
1e6febb74e
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 26
      packages/neon/neon/lib/src/widgets/account_tile.dart
  2. 6
      packages/neon/neon/lib/src/widgets/app_bar.dart
  3. 34
      packages/neon/neon/lib/src/widgets/app_implementation_icon.dart
  4. 13
      packages/neon/neon/lib/src/widgets/dialog.dart
  5. 11
      packages/neon/neon/lib/src/widgets/drawer.dart
  6. 11
      packages/neon/neon/lib/src/widgets/linear_progress_indicator.dart
  7. 14
      packages/neon/neon/lib/src/widgets/user_avatar.dart
  8. 18
      packages/neon/neon/lib/src/widgets/validation_tile.dart

26
packages/neon/neon/lib/src/widgets/account_tile.dart

@ -10,8 +10,10 @@ import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:neon/src/widgets/user_avatar.dart'; import 'package:neon/src/widgets/user_avatar.dart';
import 'package:nextcloud/provisioning_api.dart' as provisioning_api; import 'package:nextcloud/provisioning_api.dart' as provisioning_api;
/// List tile to display account information.
@internal @internal
class NeonAccountTile extends StatelessWidget { class NeonAccountTile extends StatelessWidget {
/// Creates a new account list tile.
const NeonAccountTile({ const NeonAccountTile({
required this.account, required this.account,
this.trailing, this.trailing,
@ -20,9 +22,33 @@ class NeonAccountTile extends StatelessWidget {
super.key, super.key,
}); });
/// {@template neon.AccountTile.account}
/// The account to display inside the tile.
/// {@endtemplate}
final Account account; final Account account;
/// {@template neon.AccountTile.trailing}
/// A widget to display after the title.
///
/// Typically an [Icon] widget.
///
/// To show right-aligned metadata (assuming left-to-right reading order;
/// left-aligned for right-to-left reading order), consider using a [Row] with
/// [CrossAxisAlignment.baseline] alignment whose first item is [Expanded] and
/// whose second child is the metadata text, instead of using the [trailing]
/// property.
/// {@endtemplate}
final Widget? trailing; final Widget? trailing;
/// {@template neon.AccountTile.onTap}
/// Called when the user taps this list tile.
/// {@endtemplate}
final GestureTapCallback? onTap; final GestureTapCallback? onTap;
/// Whether to also show the status on the avatar.
///
/// See:
/// * [NeonUserAvatar.showStatus]
final bool showStatus; final bool showStatus;
@override @override

6
packages/neon/neon/lib/src/widgets/app_bar.dart

@ -17,8 +17,10 @@ import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
/// Global app bar for the Neon app.
@internal @internal
class NeonAppBar extends StatefulWidget implements PreferredSizeWidget { class NeonAppBar extends StatefulWidget implements PreferredSizeWidget {
/// Creates a new Neon app bar.
const NeonAppBar({super.key}); const NeonAppBar({super.key});
@override @override
@ -149,8 +151,10 @@ class _NeonAppBarState extends State<NeonAppBar> {
); );
} }
/// Button opening the unified search page.
@internal @internal
class SearchIconButton extends StatelessWidget { class SearchIconButton extends StatelessWidget {
/// Creates a new unified search button.
const SearchIconButton({ const SearchIconButton({
super.key, super.key,
}); });
@ -167,8 +171,10 @@ class SearchIconButton extends StatelessWidget {
); );
} }
/// Button opening the notifications page.
@internal @internal
class NotificationIconButton extends StatefulWidget { class NotificationIconButton extends StatefulWidget {
/// Creates a new notifications button.
const NotificationIconButton({ const NotificationIconButton({
super.key, super.key,
}); });

34
packages/neon/neon/lib/src/widgets/app_implementation_icon.dart

@ -2,8 +2,10 @@ import 'package:flutter/material.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:neon/src/models/app_implementation.dart'; import 'package:neon/src/models/app_implementation.dart';
/// An icon widget displaying the app icon of a client with an overlay displaying the [unreadCount].
@internal @internal
class NeonAppImplementationIcon extends StatelessWidget { class NeonAppImplementationIcon extends StatelessWidget {
/// Creates a new app implementation icon.
const NeonAppImplementationIcon({ const NeonAppImplementationIcon({
required this.appImplementation, required this.appImplementation,
this.unreadCount, this.unreadCount,
@ -12,12 +14,44 @@ class NeonAppImplementationIcon extends StatelessWidget {
super.key, super.key,
}); });
/// The client for which to build the icon.
///
/// Uses [AppImplementation.buildIcon] for the icon data.
final AppImplementation appImplementation; final AppImplementation appImplementation;
/// The number of unread notifications.
final int? unreadCount; final int? unreadCount;
/// The color to use when drawing the icon.
///
/// Defaults to the nearest [IconTheme]'s [IconThemeData.color].
///
/// The color (whether specified explicitly here or obtained from the
/// [IconTheme]) will be further adjusted by the nearest [IconTheme]'s
/// [IconThemeData.opacity].
///
/// {@tool snippet}
/// Typically, a Material Design color will be used, as follows:
///
/// ```dart
/// Icon(
/// Icons.widgets,
/// color: Colors.blue.shade400,
/// )
/// ```
/// {@end-tool}
final Color? color; final Color? color;
/// The size of the icon in logical pixels.
///
/// Icons occupy a square with width and height equal to size.
///
/// Defaults to the nearest [IconTheme]'s [IconThemeData.size].
///
/// If this [NeonAppImplementationIcon] is being placed inside an [IconButton],
/// then use [IconButton.iconSize] instead, so that the [IconButton] can make
/// the splash area the appropriate size as well. The [IconButton] uses an
/// [IconTheme] to pass down the size to the [NeonAppImplementationIcon].
final double? size; final double? size;
@override @override

13
packages/neon/neon/lib/src/widgets/dialog.dart

@ -1,13 +1,26 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// A Neon material design dialog based on [SimpleDialog].
class NeonDialog extends StatelessWidget { class NeonDialog extends StatelessWidget {
/// Creates a Neon dialog.
///
/// Typically used in conjunction with [showDialog].
const NeonDialog({ const NeonDialog({
this.title, this.title,
this.children, this.children,
super.key, super.key,
}); });
/// The (optional) title of the dialog is displayed in a large font at the top
/// of the dialog.
///
/// Typically a [Text] widget.
final Widget? title; final Widget? title;
/// The (optional) content of the dialog is displayed in a
/// [SingleChildScrollView] underneath the title.
///
/// Typically a list of [SimpleDialogOption]s.
final List<Widget>? children; final List<Widget>? children;
@override @override

11
packages/neon/neon/lib/src/widgets/drawer.dart

@ -15,8 +15,13 @@ import 'package:neon/src/widgets/image.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart'; import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:nextcloud/core.dart' as core; import 'package:nextcloud/core.dart' as core;
/// A custom pre populated [Drawer] side panel.
///
/// Displays an entry for every registered and supported client and one for
/// the settings page.
@internal @internal
class NeonDrawer extends StatelessWidget { class NeonDrawer extends StatelessWidget {
/// Created a new Neon drawer.
const NeonDrawer({ const NeonDrawer({
super.key, super.key,
}); });
@ -112,8 +117,14 @@ class __NeonDrawerState extends State<_NeonDrawer> {
} }
} }
/// Custom styled [DrawerHeader] used inside a [Drawer] or [NeonDrawer].
///
/// The neon drawer will display the [core.ThemingPublicCapabilities_Theming.name]
/// and [core.ThemingPublicCapabilities_Theming.logo] and automatically rebuild
/// when the current theme changes.
@internal @internal
class NeonDrawerHeader extends StatelessWidget { class NeonDrawerHeader extends StatelessWidget {
/// Creates a new Neon drawer header.
const NeonDrawerHeader({super.key}); const NeonDrawerHeader({super.key});
@override @override

11
packages/neon/neon/lib/src/widgets/linear_progress_indicator.dart

@ -1,6 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Wrapped [LinearProgressIndicator].
///
/// Adds default styling to the [LinearProgressIndicator].
class NeonLinearProgressIndicator extends StatelessWidget { class NeonLinearProgressIndicator extends StatelessWidget {
/// Creates a new Neon styled [LinearProgressIndicator].
const NeonLinearProgressIndicator({ const NeonLinearProgressIndicator({
this.visible = true, this.visible = true,
this.margin = const EdgeInsets.symmetric(horizontal: 10), this.margin = const EdgeInsets.symmetric(horizontal: 10),
@ -9,9 +13,16 @@ class NeonLinearProgressIndicator extends StatelessWidget {
super.key, super.key,
}); });
/// Whether the indicator is visible.
final bool visible; final bool visible;
/// Empty space to surround the indicator.
final EdgeInsets? margin; final EdgeInsets? margin;
/// {@macro flutter.progress_indicator.ProgressIndicator.color}
final Color? color; final Color? color;
/// {@macro flutter.material.LinearProgressIndicator.trackColor}
final Color? backgroundColor; final Color? backgroundColor;
@override @override

14
packages/neon/neon/lib/src/widgets/user_avatar.dart

@ -12,7 +12,9 @@ import 'package:nextcloud/core.dart' as core;
import 'package:nextcloud/user_status.dart' as user_status; import 'package:nextcloud/user_status.dart' as user_status;
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
/// A circle that contains the user profile image and status.
class NeonUserAvatar extends StatefulWidget { class NeonUserAvatar extends StatefulWidget {
/// Creates a new Neon user avatar.
NeonUserAvatar({ NeonUserAvatar({
required this.account, required this.account,
final String? username, final String? username,
@ -23,11 +25,23 @@ class NeonUserAvatar extends StatefulWidget {
super.key, super.key,
}) : username = username ?? account.username; }) : username = username ?? account.username;
/// The account used to fetch the image.
final Account account; final Account account;
/// The user profile to display
final String username; final String username;
/// Whether to show the status.
final bool showStatus; final bool showStatus;
/// The size of the avatar.
final double? size; final double? size;
/// The color with which to fill the circle. Changing the background
/// color will cause the avatar to animate to the new color.
final Color? backgroundColor; final Color? backgroundColor;
/// The color used to render the loading animation.
final Color? foregroundColor; final Color? foregroundColor;
@override @override

18
packages/neon/neon/lib/src/widgets/validation_tile.dart

@ -1,13 +1,23 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Validation list tile.
///
/// A [ListTile] used to display the progress of a validation.
///
/// See:
/// * [ValidationState] for the possible states
class NeonValidationTile extends StatelessWidget { class NeonValidationTile extends StatelessWidget {
/// Creates a new validation list tile.
const NeonValidationTile({ const NeonValidationTile({
required this.title, required this.title,
required this.state, required this.state,
super.key, super.key,
}); });
/// The title of this tile.
final String title; final String title;
/// The state to display.
final ValidationState state; final ValidationState state;
@override @override
@ -48,9 +58,17 @@ class NeonValidationTile extends StatelessWidget {
} }
} }
/// Validation states for [NeonValidationTile].
enum ValidationState { enum ValidationState {
/// Indicates a loading state.
loading, loading,
/// Indicates an error.
failure, failure,
/// Indicates the process has been canceled.
canceled, canceled,
/// Indicates a success state.
success, success,
} }

Loading…
Cancel
Save