Skip to content

Commit 47b54ab

Browse files
Merge pull request #5 from Cleveroad/fix/page_indicator_oversizing
Fix/page indicator oversizing
2 parents 42eead4 + bcce000 commit 47b54ab

File tree

11 files changed

+59
-378
lines changed

11 files changed

+59
-378
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66

77
Version | Changes
88
--- | ---
9+
v.1.1.0 | <ul><li>Fixed sliding indicator oversize when using icons</li></ul>
10+
v.1.0.0-nullsafety | <ul><li>Null safety support</li></ul>
11+
v.0.1.0 | <ul><li>Removed unnecessary dependency</li></ul>
912
v.0.0.1 | <ul><li>First public release</li></ul>
10-
v.0.1.0 | <ul><li>Removed unnecessary dependency</li></ul>

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Cleveroad
3+
Copyright (c) 2021 Cleveroad
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## SlidingTutorial [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/Solido/awesome-flutter)
1+
## SlidingTutorial [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/Solido/awesome-flutter) <a href="https://www.cleveroad.com/?utm_source=github&utm_medium=label&utm_campaign=contacts"><img src="https://www.cleveroad.com/public/comercial/label-cleveroad.svg" height="20"></a>
22
![Header image](https://github.com/Cleveroad/flutter_sliding_tutorial/raw/master/images/header.jpg)
3+
34
## Cleveroad introduces Sliding Tutorial Library for Flutter
45

56
Hey guys, hope you haven’t started developing a tutorial for your Flutter app yet, as we have already completed a part of your job. Don’t worry, we act from good motives only. Our aim is to help you create a sliding tutorial in a fast and simple manner. So we’ve done some work and voila!. A simple Flutter Sliding Tutorial library is at your service.
@@ -16,7 +17,7 @@ All you need to do is:
1617
<br>2. Create icons for each screen of your tutorial
1718
<br>3. Follow the instructions below
1819

19-
[![Awesome](https://github.com/Cleveroad/flutter_sliding_tutorial/raw/master/images/logo-footer.png)](https://www.cleveroad.com/?utm_source=github&utm_medium=label&utm_campaign=contacts)
20+
[![Awesome](https://avatars.githubusercontent.com/u/14131420?s=200&v=4)](https://www.cleveroad.com/?utm_source=github&utm_medium=label&utm_campaign=contacts)
2021

2122

2223
## Full Documentation
@@ -26,7 +27,7 @@ In the `pubspec.yaml` of your flutter project, add the following dependency:
2627
```yaml
2728
dependencies:
2829
...
29-
flutter_sliding_tutorial: "^0.1.0"
30+
flutter_sliding_tutorial: "^1.1.0"
3031
```
3132
3233
In your library add the following import:
@@ -54,7 +55,7 @@ If you have any questions regarding the use of this tutorial, please contact us
5455

5556
The MIT License (MIT)
5657

57-
Copyright (c) 2015-2016 Cleveroad
58+
Copyright (c) 2021 Cleveroad
5859

5960
Permission is hereby granted, free of charge, to any person obtaining a copy
6061
of this software and associated documentation files (the "Software"), to deal
@@ -83,4 +84,4 @@ If you have any questions regarding the use of this tutorial, please contact us
8384

8485
For help getting started with Flutter, view our
8586
[online documentation](https://flutter.dev/docs), which offers tutorials,
86-
samples, guidance on mobile development, and a full API reference.
87+
samples, guidance on mobile development, and a full API reference.

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ class _ExamplePageState extends State<ExamplePage> {
5757
notifier: notifier,
5858
activeIndicator: Icon(
5959
Icons.check_circle,
60-
size: 10,
6160
color: Color(0xFF29B6F6),
6261
),
6362
inActiveIndicator: SvgPicture.asset(
6463
"assets/hollow_circle.svg",
6564
),
6665
margin: 8,
67-
sizeIndicator: 10,
66+
inactiveIndicatorSize: 14,
67+
activeIndicatorSize: 14,
6868
),
6969
)
7070
],

example/pubspec.lock

Lines changed: 0 additions & 196 deletions
This file was deleted.

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
sdk: flutter
1111

1212
cupertino_icons: ^1.0.2
13-
flutter_svg: ^0.21.0-nullsafety.0
13+
flutter_svg: ^0.22.0
1414
flutter_sliding_tutorial:
1515
path: ../
1616

images/gif1.gif

-3.72 MB
Binary file not shown.

images/header.png

-68.6 KB
Binary file not shown.

lib/src/sliding_indicator.dart

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:math' as math;
22

3+
import 'package:flutter/material.dart';
34
import 'package:flutter/widgets.dart';
45
import 'package:flutter_sliding_tutorial/flutter_sliding_tutorial.dart';
56

@@ -21,16 +22,18 @@ class SlidingIndicator extends StatelessWidget {
2122
final ValueNotifier<double> notifier;
2223
final Widget activeIndicator;
2324
final Widget inActiveIndicator;
25+
final double activeIndicatorSize;
26+
final double inactiveIndicatorSize;
2427
final int indicatorCount;
25-
final double sizeIndicator;
2628
final double margin;
2729

2830
const SlidingIndicator({
2931
required this.notifier,
3032
required this.activeIndicator,
3133
required this.inActiveIndicator,
3234
required this.indicatorCount,
33-
this.sizeIndicator = 10,
35+
this.activeIndicatorSize = 10,
36+
this.inactiveIndicatorSize = 10,
3437
this.margin = 8,
3538
Key? key,
3639
}) : super(key: key);
@@ -39,36 +42,54 @@ class SlidingIndicator extends StatelessWidget {
3942
Widget build(BuildContext context) {
4043
return Row(
4144
mainAxisAlignment: MainAxisAlignment.center,
42-
children: <Widget>[
45+
children: [
4346
Stack(
44-
children: <Widget>[
47+
alignment: Alignment.centerLeft,
48+
children: [
4549
Row(
4650
mainAxisAlignment: MainAxisAlignment.center,
47-
children: List<Widget>.generate(indicatorCount, (i) {
48-
return Container(
51+
children: List<Widget>.generate(
52+
indicatorCount,
53+
(i) {
54+
return Container(
4955
margin: EdgeInsets.only(
50-
left: i == 0 ? 0 : margin, right: margin),
56+
left: i == 0 ? 0 : margin,
57+
right: margin,
58+
),
5159
child: Container(
52-
width: sizeIndicator,
53-
height: sizeIndicator,
54-
child: inActiveIndicator));
55-
}),
60+
width: inactiveIndicatorSize,
61+
height: inactiveIndicatorSize,
62+
child: FittedBox(child: inActiveIndicator),
63+
),
64+
);
65+
},
66+
),
5667
),
57-
AnimatedBuilder(
58-
animation: notifier,
59-
builder: (context, anim) {
60-
var correctScroll = notifier.value;
61-
return Transform.translate(
62-
offset:
63-
Offset((margin * 2 + sizeIndicator) * correctScroll, 0),
68+
Transform.translate(
69+
offset: Offset(
70+
inactiveIndicatorSize / 2 - activeIndicatorSize / 2,
71+
0,
72+
),
73+
child: AnimatedBuilder(
74+
animation: notifier,
75+
builder: (context, anim) {
76+
var correctScroll = notifier.value;
77+
return Transform.translate(
78+
offset: Offset(
79+
(margin * 2 + inactiveIndicatorSize) * correctScroll,
80+
0,
81+
),
6482
child: Transform.rotate(
6583
angle: 2 * math.pi * correctScroll,
6684
child: Container(
67-
width: sizeIndicator,
68-
height: sizeIndicator,
69-
child: activeIndicator),
70-
));
71-
},
85+
width: activeIndicatorSize,
86+
height: activeIndicatorSize,
87+
child: FittedBox(child: activeIndicator),
88+
),
89+
),
90+
);
91+
},
92+
),
7293
),
7394
],
7495
)

0 commit comments

Comments
 (0)