Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit a03b05d

Browse files
authored
Merge pull request #3 from Iconica-Development/v0.0.2
V0.0.2
2 parents a0eef54 + 11045e3 commit a03b05d

File tree

12 files changed

+891
-16
lines changed

12 files changed

+891
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## 0.0.1
1+
## [0.0.2] - 16 September 2022
22

3-
* TODO: Describe initial release.
3+
* Initial release.

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
[![pub package](https://img.shields.io/pub/v/[PACKAGE NAME ON PUB].svg)](https://github.com/Iconica-Development) [![Build status](URL TO REPO)](URL TO GITHUB ACTIONS) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
22

3-
Short description of what your package is, why you created it. What issues it fixes and how it works. Also mention the available platforms
3+
# Introduction Widget
4+
Flutter Introduction Widget for showing a list of introduction pages on a single scrollable page or horizontal pageview.
45

5-
## Setup
6+
If nothing is provided a few default pages are shown with a simple description of the package.
67

7-
What setup steps are neccesarry and why>
88

9-
<details>
10-
<summary>PLATFORM</summary>
11-
12-
specific platform steps
9+
Supports all Flutter platforms.
1310

14-
</details>
11+
## Usage
12+
13+
To use this package, add `flutter_introduction_widget` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels).
1514

1615
## How to use
1716

18-
How can we use the package descibe the most common ways with examples in
17+
Simple way to use the introduction widget:
1918
```dart
20-
codeblocks
19+
Introduction(
20+
introductionSettings: const IntroductionSettings(
21+
buttonMode: IntroductionScreenButtonMode.Text,
22+
showSkipButton: true,
23+
showFinishButton: true,
24+
),
25+
onComplete: () {
26+
debugPrint('done!');
27+
},
28+
pages: [
29+
IntroductionPage(title: 'Page1', text: 'hello'),
30+
IntroductionPage(title: 'Page2', text: 'world'),
31+
IntroductionPage(title: 'Page3', text: 'text'),
32+
],
33+
),
2134
```
35+
### Example
36+
37+
See [Example Code](example/lib/main.dart) for more info.
2238

2339
## Issues
2440

example/lib/main.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_introduction_widget/flutter_introduction_widget.dart';
23

34
void main() {
45
runApp(const MaterialApp(home: FlutterIntroductionDemo()));
@@ -9,6 +10,25 @@ class FlutterIntroductionDemo extends StatelessWidget {
910

1011
@override
1112
Widget build(BuildContext context) {
12-
return const Scaffold(body: Text('FlutterIntroductionDemo'));
13+
return Scaffold(
14+
body: Theme(
15+
data: Theme.of(context).copyWith(backgroundColor: Colors.amber),
16+
child: Introduction(
17+
introductionSettings: const IntroductionSettings(
18+
buttonMode: IntroductionScreenButtonMode.Text,
19+
showSkipButton: true,
20+
showFinishButton: true,
21+
),
22+
onComplete: () {
23+
debugPrint('done!');
24+
},
25+
pages: [
26+
IntroductionPage(title: 'Page1', text: 'hello'),
27+
IntroductionPage(title: 'Page2', text: 'world'),
28+
IntroductionPage(title: 'Page3', text: 'text'),
29+
],
30+
),
31+
),
32+
);
1333
}
1434
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
library flutter_introduction_widget;
2+
3+
export 'package:flutter_introduction_widget/src/introduction.dart';
4+
export 'package:flutter_introduction_widget/src/models/introduction_page.dart';

lib/src/extensions.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// ignore_for_file: prefer_mixin
2+
3+
import 'package:flutter/material.dart';
4+
5+
class NavigateWidgetMixin {
6+
void navigateFadeTo(
7+
BuildContext context,
8+
WidgetBuilder buildChild, {
9+
String? routeName,
10+
bool? opaque,
11+
Color? barrierColor,
12+
}) {
13+
Navigator.of(context).push(
14+
PageRouteBuilder(
15+
opaque: opaque ?? true,
16+
barrierColor: barrierColor,
17+
settings: RouteSettings(name: routeName),
18+
transitionDuration: const Duration(milliseconds: 500),
19+
transitionsBuilder: (context, animation, secondamination, child) =>
20+
FadeTransition(opacity: animation, child: child),
21+
pageBuilder: (BuildContext ctx, animation, __) => buildChild(ctx),
22+
),
23+
);
24+
}
25+
26+
void navigateFadeToReplace(
27+
BuildContext context,
28+
WidgetBuilder buildChild, {
29+
bool popRemaining = false,
30+
}) {
31+
if (popRemaining) {
32+
Navigator.of(context).popUntil((route) => route.isFirst);
33+
}
34+
Navigator.of(context).pushReplacement(
35+
PageRouteBuilder(
36+
transitionDuration: const Duration(milliseconds: 500),
37+
transitionsBuilder: (context, animation, secondamination, child) =>
38+
FadeTransition(opacity: animation, child: child),
39+
pageBuilder: (BuildContext ctx, animation, __) => buildChild(ctx),
40+
),
41+
);
42+
}
43+
}
44+
45+
abstract class NavigateWidget extends StatelessWidget with NavigateWidgetMixin {
46+
const NavigateWidget({super.key});
47+
}
48+
49+
abstract class StatefulNavigateWidget extends StatefulWidget
50+
with NavigateWidgetMixin {
51+
const StatefulNavigateWidget({super.key});
52+
}
53+
54+
extension AlignmentFromTextAlign on TextAlign {
55+
CrossAxisAlignment toCrossAxisAlignment() {
56+
switch (this) {
57+
case TextAlign.left:
58+
return CrossAxisAlignment.start;
59+
case TextAlign.right:
60+
return CrossAxisAlignment.end;
61+
case TextAlign.center:
62+
return CrossAxisAlignment.center;
63+
// ignore: no_default_cases
64+
default:
65+
return CrossAxisAlignment.end;
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)