Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nuc134r committed May 14, 2022
1 parent 6eb21c4 commit 1d053d2
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 23 deletions.
37 changes: 17 additions & 20 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:example/main.dart';
//import 'package:example/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
//testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// // Build our app and trigger a frame.
// await tester.pumpWidget(const MyApp());
//
// // Verify that our counter starts at 0.
// expect(find.text('0'), findsOneWidget);
// expect(find.text('1'), findsNothing);
//
// // Tap the '+' icon and trigger a frame.
// await tester.tap(find.byIcon(Icons.add));
// await tester.pump();
//
// // Verify that our counter has incremented.
// expect(find.text('0'), findsNothing);
// expect(find.text('1'), findsOneWidget);
//});
}
5 changes: 3 additions & 2 deletions lib/preview_capturer_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:tab_switcher/tab_switcher_controller.dart';

typedef TabWidgetBuilder = Widget Function(BuildContext context, TabSwitcherTab tab, int index);
typedef ImageCaptureCallback = void Function(ui.Image image);

/// Generates image from child widget right before detaching from the widget tree
/// and calls callback with the captured image
/// TODO Customizable image quality (pixelRatio)
class PreviewCapturerWidget extends StatefulWidget {
PreviewCapturerWidget({required this.child, required this.callback, required this.tag});

Expand Down
2 changes: 2 additions & 0 deletions lib/tab_count_icon.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:tab_switcher/tab_switcher_controller.dart';

/// Reusable button which shows supplied [TabSwitcherController]'s tab count
/// and triggers tab switching if tapped. For use in AppBar.
class TabCountIcon extends StatelessWidget {
const TabCountIcon({required this.controller, Key? key}) : super(key: key);

Expand Down
1 change: 1 addition & 0 deletions lib/tab_switcher_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:tab_switcher/tab_switcher_controller.dart';
import 'package:tab_switcher/tab_switcher_impl.dart';
import 'package:tab_switcher/utils/responsive_page_view_scroll_physics.dart';

/// Wraps supplied app bar builder to add gesture support, animations and transitions
class TabSwitcherAppBar extends StatelessWidget implements PreferredSizeWidget {
TabSwitcherAppBar(
this.builder,
Expand Down
3 changes: 3 additions & 0 deletions lib/tab_switcher_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

/// Main controller of the tab switcher.
/// Opens new tabs, closes tabs, switches tabs programmatically.
/// Provides streams for common events.
class TabSwitcherController {
int get tabCount => _tabs.length;
UnmodifiableListView<TabSwitcherTab> get tabs => UnmodifiableListView(_tabs);
Expand Down
1 change: 1 addition & 0 deletions lib/tab_switcher_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:tab_switcher/tab_switcher_tab_grid.dart';

typedef TabWidgetBuilder = Widget Function(BuildContext context, TabSwitcherTab? tab);

/// Root widget for building apps with full screen tabs
class TabSwitcherWidget extends StatefulWidget {
TabSwitcherWidget({
required this.controller,
Expand Down
3 changes: 3 additions & 0 deletions lib/tab_switcher_minimized_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
import 'package:tab_switcher/tab_switcher_controller.dart';
import 'package:tab_switcher/ui_image_widget.dart';

/// A widget representing single minimized tab.
/// Consists of title, subtitle, preview image and a close button.
/// Implements swipe to dismiss on it's own.
class TabSwitcherMinimizedTab extends StatelessWidget {
TabSwitcherMinimizedTab(this._tab, this.onTap, this.onClose, this._isCurrent);

Expand Down
3 changes: 2 additions & 1 deletion lib/tab_switcher_tab_grid.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:scroll_shadow_container/scroll_shadow_container.dart';
import 'package:tab_switcher/animated_grid.dart';
import 'package:tab_switcher/tab_switcher_controller.dart';
import 'package:tab_switcher/tab_switcher_minimized_tab.dart';
import 'package:scroll_shadow_container/scroll_shadow_container.dart';

/// Displays grid of minimized tabs
class TabSwitcherTabGrid extends StatefulWidget {
TabSwitcherTabGrid(this.controller);

Expand Down
1 change: 1 addition & 0 deletions lib/tab_switcher_tab_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:scroll_shadow_container/scroll_shadow_container.dart';
import 'package:tab_switcher/tab_switcher_controller.dart';
import 'package:tab_switcher/tab_switcher_minimized_tab.dart';

/// Displays list of minimized tabs
class TabSwitcherTabList extends StatefulWidget {
TabSwitcherTabList(this.controller);

Expand Down
1 change: 1 addition & 0 deletions lib/ui_image_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:ui' as ui;

import 'package:flutter/material.dart';

/// Renders [ui.Image] data faster than encoding and displaying in [Image.memory].
class UiImageWidget extends StatelessWidget {
final ui.Image image;
final BoxFit fit;
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/responsive_page_view_scroll_physics.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/physics.dart';

/// Fast and steady scrolling physics based on [ScrollPhysics].
class ResponsiveClampedScrollPhysics extends ScrollPhysics {
const ResponsiveClampedScrollPhysics({ScrollPhysics? parent}) : super(parent: parent);

Expand All @@ -17,6 +18,7 @@ class ResponsiveClampedScrollPhysics extends ScrollPhysics {
);
}

/// Fast and steady scrolling physics based on [BouncingScrollPhysics].
class ResponsiveBouncingScrollPhysics extends BouncingScrollPhysics {
const ResponsiveBouncingScrollPhysics({ScrollPhysics? parent}) : super(parent: parent);

Expand Down

0 comments on commit 1d053d2

Please sign in to comment.