Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for Haptic Feedback (small vibration) when value changes #59

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
7 changes: 0 additions & 7 deletions example/lib/common/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ class Languages extends GithubLanguage with ISuspensionBean {
@override
Map<String, dynamic> toJson() {
final Map<String, dynamic> map = super.toJson();
void addIfNonNull(String fieldName, dynamic value) {
if (value != null) {
map[fieldName] = value;
}
}

// addIfNonNull('tagIndex', tagIndex);
return map;
}

Expand Down
2 changes: 0 additions & 2 deletions example/lib/ui/car_models_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:developer';

import 'package:azlistview/azlistview.dart';
import 'package:azlistview_example/common/index.dart';
import 'package:flutter/material.dart';
Expand Down
1 change: 0 additions & 1 deletion example/lib/ui/github_language_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class _GitHubLanguagePageState extends State<GitHubLanguagePage> {
},
indexBarOptions: IndexBarOptions(
needRebuild: true,
hapticFeedback: true,
selectTextStyle: TextStyle(
fontSize: 12,
color: Colors.white,
Expand Down
75 changes: 41 additions & 34 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ packages:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
azlistview:
Expand All @@ -14,82 +14,82 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0"
version: "2.1.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
common_utils:
dependency: "direct main"
description:
name: common_utils
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.2"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
decimal:
dependency: transitive
description:
name: decimal
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "2.1.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
flutter:
Expand All @@ -115,14 +115,21 @@ packages:
dependency: "direct main"
description:
name: lpinyin
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.3"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
Expand All @@ -136,28 +143,28 @@ packages:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
rational:
dependency: transitive
description:
name: rational
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "2.0.0"
scrollable_positioned_list:
dependency: transitive
description:
name: scrollable_positioned_list
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
sky_engine:
Expand All @@ -169,58 +176,58 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.15.0 <3.0.0"
flutter: ">=1.17.0"
9 changes: 9 additions & 0 deletions lib/src/az_listview.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'package:flutter/services.dart';

import 'az_common.dart';
import 'index_bar.dart';
Expand All @@ -23,6 +24,7 @@ class AzListView extends StatefulWidget {
this.indexBarData = kIndexBarData,
this.indexBarWidth = kIndexBarWidth,
this.indexBarHeight,
this.contentIndexBarAlignment = Alignment.topCenter,
this.indexBarItemHeight = kIndexBarItemHeight,
this.hapticFeedback = false,
this.indexBarAlignment = Alignment.centerRight,
Expand Down Expand Up @@ -87,6 +89,9 @@ class AzListView extends StatefulWidget {
/// IndexBar alignment.
final AlignmentGeometry indexBarAlignment;

/// contentIndexBar alignment.
final AlignmentGeometry contentIndexBarAlignment;

/// IndexBar margin.
final EdgeInsetsGeometry? indexBarMargin;

Expand Down Expand Up @@ -156,6 +161,9 @@ class _AzListViewState extends State<AzListView> {
details.action == IndexBarDragDetails.actionUpdate) {
selectTag = tag;
_scrollTopIndex(tag);
if (widget.hapticFeedback) {
HapticFeedback.lightImpact();
}
}
}

Expand Down Expand Up @@ -203,6 +211,7 @@ class _AzListViewState extends State<AzListView> {
itemHeight: widget.indexBarItemHeight,
margin: widget.indexBarMargin,
indexHintBuilder: widget.indexHintBuilder,
contentIndexBarAlignment: widget.contentIndexBarAlignment,
indexBarDragListener: dragListener,
options: widget.indexBarOptions,
controller: indexBarController,
Expand Down
Loading