Skip to content

Commit

Permalink
Merge pull request #2 from presswink/#1
Browse files Browse the repository at this point in the history
#1: update text and button colors feature added
  • Loading branch information
Adityapanther authored Oct 27, 2023
2 parents c8d6946 + e25e557 commit 5e81aec
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 123 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 0.0.1

* initial Release

## 0.0.2
* we can update colors & style of button and text
3 changes: 0 additions & 3 deletions example/integration_test/plugin_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
// For more information about Flutter integration tests, please see
// https://docs.flutter.dev/cookbook/testing/integration/introduction


import 'package:integration_test/integration_test.dart';


void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

}
7 changes: 3 additions & 4 deletions example/lib/image_resource.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class ImageResouce {
static const android2= "assets/images/android_2.png";
static const android3= "assets/images/android_3.png";
static const android4= "assets/images/android_4.png";
static const android2 = "assets/images/android_2.png";
static const android3 = "assets/images/android_3.png";
static const android4 = "assets/images/android_4.png";
}

65 changes: 62 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:app_walk_through_example/second_screen.dart';
import 'package:app_walk_through_example/walk_through_screen.dart';
import 'package:app_walk_through/app_walk_through.dart';
import 'package:flutter/material.dart';

import 'image_resource.dart';

void main() {
runApp(const MyApp());
}
Expand All @@ -14,9 +16,66 @@ class MyApp extends StatelessWidget {
initialRoute: WalkThroughScreen.routeName,
routes: {
WalkThroughScreen.routeName: (context) => const WalkThroughScreen(),
SecondScreen.routeName:(context) => const SecondScreen()
SecondScreen.routeName: (context) => const SecondScreen()
},
);
}
}

// WalkThrough screen initialization

class WalkThroughScreen extends StatelessWidget {
const WalkThroughScreen({super.key});
static const routeName = "/walk_through";

void openSecondScreen(BuildContext context) {
Navigator.of(context).pushNamed(SecondScreen.routeName);
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
alignment: Alignment.center,
child: AppWalkThrough(
models: [
AppWalkThroughDataModel(
title: "Sit and Relax",
description: "have a sit and relax for your future Goals.",
image: ImageResouce.android2),
AppWalkThroughDataModel(
title: "LeaderBoard",
description:
"Leaderboard is the way to know your client behaviour.",
image: ImageResouce.android3),
AppWalkThroughDataModel(
title: "Build your own blocks",
description: "Build you own block or path to success.",
image: ImageResouce.android4)
],
onNextButtonPressed: () {
openSecondScreen(context);
},
onSkipButtonPressed: () {
openSecondScreen(context);
}),
),
);
}
}

// second screen initialization
class SecondScreen extends StatelessWidget {
const SecondScreen({super.key});
static const routeName = "/secondScreen";

@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
alignment: Alignment.center,
child: const Text("second Screen"),
),
);
}
}
18 changes: 0 additions & 18 deletions example/lib/second_screen.dart

This file was deleted.

44 changes: 0 additions & 44 deletions example/lib/walk_through_screen.dart

This file was deleted.

2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "0.0.2"
async:
dependency: transitive
description:
Expand Down
2 changes: 0 additions & 2 deletions example/test/my_widget_tester.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:flutter/material.dart';

class MyWidgetTester extends StatelessWidget {
Expand All @@ -12,4 +11,3 @@ class MyWidgetTester extends StatelessWidget {
);
}
}

5 changes: 2 additions & 3 deletions example/test/second_screen_test.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:app_walk_through_example/second_screen.dart';
import 'package:app_walk_through_example/main.dart';
import 'package:flutter_test/flutter_test.dart';

import 'my_widget_tester.dart';

void main(){
void main() {
testWidgets("should have AppWalkThrough widget", (widgetTester) async {
await widgetTester.pumpWidget(const MyWidgetTester(screen: SecondScreen()));
final textFinder = find.text("second Screen");
expect(textFinder, findsOneWidget);
});
}

9 changes: 5 additions & 4 deletions example/test/walk_through_screen_test.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'package:app_walk_through/app_walk_through.dart';
import 'package:app_walk_through_example/walk_through_screen.dart';
import 'package:app_walk_through_example/main.dart';
import 'package:flutter_test/flutter_test.dart';

import 'my_widget_tester.dart';

void main(){
void main() {
testWidgets("should have AppWalkThrough widget", (widgetTester) async {
await widgetTester.pumpWidget(const MyWidgetTester(screen: WalkThroughScreen()));
await widgetTester
.pumpWidget(const MyWidgetTester(screen: WalkThroughScreen()));
final appWalkThroughFinder = find.byType(AppWalkThrough);
expect(appWalkThroughFinder, findsOneWidget);
});
}
}
58 changes: 38 additions & 20 deletions lib/app_walk_through.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@


import 'package:app_walk_through/src/app_walk_through_data_model.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

export './src/app_walk_through_data_model.dart';

/// this is app walk through widget. using this you can define your app short description and user will be able to get your app idea and feature.
/// [models] is a set of list in which you will have your app features & short description with text and images.
/// with the [onNextButtonPressed] you will be able to move on next activity or screen after the slide finish.
/// [onSkipButtonPressed] you will be able to move on next activity or screen without app walk through slide.
/// [titleStyle] is a text style for title which is visible on the app walk through slide.
/// [descriptionStyle] is a text style for title which is visible on the app walk through slide.
/// with the [nextButtonColor] you will be able to change next button icon colors.
/// you can also change or define skip button text style with [skipButtonStyle]
///
class AppWalkThrough extends StatefulWidget {
final List<AppWalkThroughDataModel> models;
final void Function() onNextButtonPressed;
final void Function() onSkipButtonPressed;
final TextStyle? titleStyle;
final TextStyle? descriptionStyle;
final Color? nextButtonColor;
final TextStyle? skipButtonStyle;

const AppWalkThrough({
super.key,
required this.models,
required this.onNextButtonPressed,
required this.onSkipButtonPressed,
this.titleStyle,
this.descriptionStyle,
this.nextButtonColor,
this.skipButtonStyle,
});

@override
Expand Down Expand Up @@ -50,6 +62,7 @@ class _AppWalkThroughState extends State<AppWalkThrough> {
super.initState();
}

/// will build the list of dot indicators
void _buildList() {
_indicatorList.clear();
widget.models.asMap().forEach((int index, _) {
Expand All @@ -59,6 +72,7 @@ class _AppWalkThroughState extends State<AppWalkThrough> {
});
}

/// [index] of the slides
void _pageHandler(int index) {
_currentPage = index;
_buildList();
Expand Down Expand Up @@ -92,11 +106,12 @@ class _AppWalkThroughState extends State<AppWalkThrough> {
alignment: Alignment.center,
child: Text(
widget.models[index].title!,
style: widget.titleStyle ?? GoogleFonts.notoSans(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
letterSpacing: 0.5),
style: widget.titleStyle ??
GoogleFonts.notoSans(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
letterSpacing: 0.5),
))),
Expanded(flex: 10, child: Container()),
Expanded(
Expand All @@ -108,14 +123,16 @@ class _AppWalkThroughState extends State<AppWalkThrough> {
Expanded(
child: Container(
margin: const EdgeInsets.only(bottom: 20),
padding: const EdgeInsets.only(left: 20, right: 20),
padding: const EdgeInsets.only(
left: 20, right: 20),
child: Text(
widget.models[index].description!,
style: widget.descriptionStyle ?? GoogleFonts.notoSans(
fontSize: 18,
fontWeight: FontWeight.w500,
color: Colors.grey,
),
style: widget.descriptionStyle ??
GoogleFonts.notoSans(
fontSize: 18,
fontWeight: FontWeight.w500,
color: Colors.grey,
),
textAlign: TextAlign.center,
)),
),
Expand All @@ -141,10 +158,11 @@ class _AppWalkThroughState extends State<AppWalkThrough> {
onPressed: widget.onSkipButtonPressed,
child: Text(
"Skip",
style: GoogleFonts.notoSans(
fontSize: 18,
fontWeight: FontWeight.w500,
color: Colors.white),
style: widget.skipButtonStyle ??
GoogleFonts.notoSans(
fontSize: 18,
fontWeight: FontWeight.w500,
color: Colors.white),
))),
Expanded(
flex: 4,
Expand All @@ -157,7 +175,7 @@ class _AppWalkThroughState extends State<AppWalkThrough> {
child: IconButton(
iconSize: 36.0,
onPressed: () {
if (_currentPage < widget.models.length -1) {
if (_currentPage < widget.models.length - 1) {
int nextIndex = _currentPage + 1;
_pageController.animateToPage(nextIndex,
duration: const Duration(milliseconds: 300),
Expand All @@ -167,9 +185,9 @@ class _AppWalkThroughState extends State<AppWalkThrough> {
widget.onNextButtonPressed();
}
},
icon: const Icon(
icon: Icon(
Icons.arrow_forward,
color: Colors.white,
color: widget.nextButtonColor ?? Colors.white,
)),
)
],
Expand Down
6 changes: 5 additions & 1 deletion lib/src/app_walk_through_data_model.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/// this is appWalkThrough data model which will be helpful to define app short descriptions.
/// assign appWalkThrough item [title] text,
/// assign appWalkThrough item [description] text &
/// assign assets [image] string of appWalkThrough item
class AppWalkThroughDataModel {
String? title;
String? description;
String? image;
AppWalkThroughDataModel({this.title, this.description, this.image});
}

4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: app_walk_through
description: A app walk through modules.
version: 0.0.1
description: A app walk through library to define or showcase app features to the users.
version: 0.0.2
homepage: https://github.com/presswink/app_walk_through

environment:
Expand Down
Loading

0 comments on commit 5e81aec

Please sign in to comment.