Skip to content

Commit 3960653

Browse files
authored
Merge pull request #141 from deepikahr/shimmer
issues fixed
2 parents 4e37a1c + 60c7eca commit 3960653

File tree

8 files changed

+718
-319
lines changed

8 files changed

+718
-319
lines changed

example/lib/main_temp.dart

Lines changed: 641 additions & 280 deletions
Large diffs are not rendered by default.

lib/components/card/gf_card.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class GFCard extends StatelessWidget {
106106
/// defines the gradient background
107107
final LinearGradient gradient;
108108

109+
109110
static const double _defaultElevation = 1;
110111
static const Clip _defaultClipBehavior = Clip.none;
111112

@@ -121,7 +122,7 @@ class GFCard extends StatelessWidget {
121122
? title ?? Container()
122123
: image != null
123124
? ClipRRect(
124-
borderRadius:
125+
borderRadius: borderRadius ??
125126
const BorderRadius.vertical(top: Radius.circular(4)),
126127
child: image,
127128
)
@@ -155,7 +156,7 @@ class GFCard extends StatelessWidget {
155156
decoration: gradient != null
156157
? BoxDecoration(
157158
gradient: gradient,
158-
borderRadius: const BorderRadius.all(Radius.circular(4)),
159+
borderRadius: borderRadius ?? const BorderRadius.all(Radius.circular(4)),
159160
)
160161
: null,
161162
child: gradient == null

lib/components/carousel/gf_carousel.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class GFCarousel extends StatefulWidget {
2323
this.pauseAutoPlayOnTouch,
2424
this.enlargeMainPage = false,
2525
this.onPageChanged,
26+
this.onPageIndex,
2627
this.scrollPhysics,
2728
this.scrollDirection = Axis.horizontal,
2829
}) : realPage = enableInfiniteScroll ? realPage + initialPage : initialPage,
@@ -94,6 +95,8 @@ class GFCarousel extends StatefulWidget {
9495
/// Called whenever the page in the center of the viewport changes.
9596
final Function(int index) onPageChanged;
9697

98+
int onPageIndex;
99+
97100
/// How the carousel should respond to user input.
98101
///
99102
/// For example, determines how the items continues to animate after the
@@ -216,6 +219,12 @@ class _GFCarouselState extends State<GFCarousel> with TickerProviderStateMixin {
216219
timer?.cancel();
217220
}
218221

222+
onPageChanged(index) {
223+
setState(() {
224+
index;
225+
});
226+
}
227+
219228
@override
220229
Widget build(BuildContext context) => Stack(
221230
children: <Widget>[
@@ -229,8 +238,8 @@ class _GFCarouselState extends State<GFCarousel> with TickerProviderStateMixin {
229238
int currentPage;
230239
currentPage = _getRealIndex(index + widget.initialPage,
231240
widget.realPage, widget.items.length);
232-
if (widget.onPageChanged != null) {
233-
widget.onPageChanged(currentPage);
241+
if (widget.pagination == true) {
242+
onPageChanged(currentPage);
234243
_current = currentPage;
235244
}
236245
_current = currentPage;

lib/components/checkboxListTile/gf_checkbox_list_tile.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ class _GFCheckboxListTileState extends State<GFCheckboxListTile> {
163163
padding: widget.padding,
164164
margin: widget.margin,
165165
title: widget.title,
166-
167166
icon: GFCheckbox(
168167
size: widget.size,
169168
activebgColor: widget.activebgColor,

lib/components/list_tile/gf_list_tile.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class GFListTile extends StatelessWidget {
5050

5151
@override
5252
Widget build(BuildContext context) => Container(
53-
constraints: const BoxConstraints(minHeight: 50),
53+
// constraints: const BoxConstraints(minHeight: 50),
5454
padding: padding,
5555
margin: margin,
5656
decoration: BoxDecoration(

lib/components/tabs/gf_segment_tabs.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class GFSegmentTabs extends StatefulWidget {
1111
/// [GFSegmentTabs] are best used as an alternative for [GFTabBar].
1212
const GFSegmentTabs(
1313
{Key key,
14-
this.initialIndex = 0,
14+
// this.initialIndex = 0,
1515
@required this.length,
1616
this.height,
1717
this.width,
@@ -31,13 +31,13 @@ class GFSegmentTabs extends StatefulWidget {
3131
this.tabs,
3232
this.tabController})
3333
: assert(length != null && length >= 0),
34-
assert(initialIndex != null &&
35-
initialIndex >= 0 &&
36-
(length == 0 || initialIndex < length)),
34+
// assert(initialIndex != null &&
35+
// initialIndex >= 0 &&
36+
// (length == 0 || initialIndex < length)),
3737
super(key: key);
3838

39-
/// The initial index of the selected tab. Defaults to zero.
40-
final int initialIndex;
39+
// /// The initial index of the selected tab. Defaults to zero.
40+
// final int initialIndex;
4141

4242
/// The total number of tabs. Typically greater than one. Must match [TabBar.tabs]'s and
4343
/// [TabBarView.children]'s length.
@@ -178,7 +178,7 @@ class _GFSegmentTabsState extends State<GFSegmentTabs> {
178178
borderRadius: widget.borderRadius ?? BorderRadius.circular(2),
179179
),
180180
child: DefaultTabController(
181-
initialIndex: widget.initialIndex,
181+
// initialIndex: widget.initialIndex,
182182
length: widget.length,
183183
child: Material(
184184
borderRadius: widget.borderRadius ?? BorderRadius.circular(2),

lib/components/tabs/gf_tabbar.dart

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/gestures.dart';
12
import 'package:flutter/rendering.dart';
23
import 'package:flutter/material.dart';
34
import 'package:flutter/widgets.dart';
@@ -16,8 +17,9 @@ class GFTabBar extends StatefulWidget {
1617
/// [TabController.length].
1718
const GFTabBar({
1819
Key key,
19-
this.initialIndex = 0,
20+
// this.initialIndex = 0,
2021
@required this.length,
22+
this.isScrollable = false,
2123
this.tabBarHeight,
2224
this.tabBarColor,
2325
this.indicatorColor,
@@ -34,13 +36,14 @@ class GFTabBar extends StatefulWidget {
3436
this.controller,
3537
this.shape,
3638
}) : assert(length != null && length >= 0),
37-
assert(initialIndex != null &&
38-
initialIndex >= 0 &&
39-
(length == 0 || initialIndex < length)),
39+
assert(isScrollable != null),
40+
// assert(initialIndex != null &&
41+
// initialIndex >= 0 &&
42+
// (length == 0 || initialIndex < length)),
4043
super(key: key);
4144

42-
/// The initial index of the selected tab. Defaults to zero.
43-
final int initialIndex;
45+
// /// The initial index of the selected tab. Defaults to zero.
46+
// final int initialIndex;
4447

4548
/// The total number of tabs. Typically greater than one. Must match [TabBar.tabs]'s and
4649
/// [TabBarView.children]'s length.
@@ -151,6 +154,13 @@ class GFTabBar extends StatefulWidget {
151154
/// and the length of the [TabBarView.children] list.
152155
final List<Widget> tabs;
153156

157+
/// Whether this tab bar can be scrolled horizontally.
158+
///
159+
/// If [isScrollable] is true, then each tab is as wide as needed for its label
160+
/// and the entire [TabBar] is scrollable. Otherwise each tab gets an equal
161+
/// share of the available space.
162+
final bool isScrollable;
163+
154164
/// This widget's selection and animation state.
155165
///
156166
/// If [TabController] is not provided, then the value of [DefaultTabController.of]
@@ -165,26 +175,36 @@ class GFTabBar extends StatefulWidget {
165175
}
166176

167177
class _GFTabBarState extends State<GFTabBar> {
178+
ScrollController _scrollController;
179+
DragStartBehavior dragStartBehavior = DragStartBehavior.start;
180+
168181
@override
169-
Widget build(BuildContext context) => Container(
170-
height: widget.tabBarHeight ?? MediaQuery.of(context).size.height * 0.1,
171-
child: Material(
172-
shape: widget.shape,
173-
type: MaterialType.button,
174-
color: widget.tabBarColor ?? GFColors.PRIMARY,
175-
child: TabBar(
176-
controller: widget.controller,
177-
labelColor: widget.labelColor,
178-
unselectedLabelColor: widget.unselectedLabelColor,
179-
labelStyle: widget.labelStyle,
180-
unselectedLabelStyle: widget.unselectedLabelStyle,
181-
indicatorColor: widget.indicatorColor,
182-
indicatorSize: widget.indicatorSize,
183-
indicator: widget.indicator,
184-
indicatorPadding: widget.indicatorPadding,
185-
indicatorWeight: widget.indicatorWeight,
186-
tabs: widget.tabs,
182+
Widget build(BuildContext context) => SingleChildScrollView(
183+
dragStartBehavior: dragStartBehavior,
184+
scrollDirection: Axis.horizontal,
185+
controller: _scrollController,
186+
child: Container(
187+
width: MediaQuery.of(context).size.width,
188+
height: widget.tabBarHeight ?? MediaQuery.of(context).size.height * 0.1,
189+
child: Material(
190+
shape: widget.shape,
191+
type: MaterialType.button,
192+
color: widget.tabBarColor ?? GFColors.PRIMARY,
193+
child: TabBar(
194+
isScrollable: widget.isScrollable,
195+
controller: widget.controller,
196+
labelColor: widget.labelColor,
197+
unselectedLabelColor: widget.unselectedLabelColor,
198+
labelStyle: widget.labelStyle,
199+
unselectedLabelStyle: widget.unselectedLabelStyle,
200+
indicatorColor: widget.indicatorColor,
201+
indicatorSize: widget.indicatorSize,
202+
indicator: widget.indicator,
203+
indicatorPadding: widget.indicatorPadding,
204+
indicatorWeight: widget.indicatorWeight,
205+
tabs: widget.tabs,
206+
),
187207
),
188208
),
189-
);
209+
);
190210
}

lib/components/tabs/gf_tabs.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class GFTabs extends StatefulWidget {
1515
Key key,
1616
this.initialIndex = 0,
1717
@required this.length,
18+
this.isScrollable = false,
1819
this.height,
1920
this.tabBarColor,
2021
this.indicatorColor,
@@ -167,6 +168,13 @@ class GFTabs extends StatefulWidget {
167168
/// defines the shape of tabBar
168169
final ShapeBorder shape;
169170

171+
/// Whether this tab bar can be scrolled horizontally.
172+
///
173+
/// If [isScrollable] is true, then each tab is as wide as needed for its label
174+
/// and the entire [TabBar] is scrollable. Otherwise each tab gets an equal
175+
/// share of the available space.
176+
final bool isScrollable;
177+
170178
@override
171179
_GFTabsState createState() => _GFTabsState();
172180
}
@@ -182,9 +190,10 @@ class _GFTabsState extends State<GFTabs> {
182190
child: Column(
183191
children: <Widget>[
184192
GFTabBar(
193+
isScrollable: widget.isScrollable,
185194
shape: widget.shape,
186195
length: widget.length,
187-
initialIndex: widget.initialIndex,
196+
// initialIndex: widget.initialIndex,
188197
tabBarHeight: widget.tabBarHeight,
189198
tabBarColor: widget.tabBarColor ?? GFColors.PRIMARY,
190199
controller: widget.controller,

0 commit comments

Comments
 (0)