Skip to content

Commit

Permalink
Finally done fixing #390
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiminrana05 committed Sep 20, 2023
1 parent ea5cdd1 commit c6c9b07
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 187 deletions.
307 changes: 137 additions & 170 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,71 +13,42 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
final scrollController = ScrollController();
return Center(
child: Container(
color: Colors.red,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 40),
child: MaterialApp(
title: 'Flutter ShowCase',
theme: ThemeData(
primaryColor: const Color(0xffEE5366),
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: ShowCaseWidget(
enableAutoScroll: true,
onStart: (index, key) {
print('index -> $index');
if(index == 2) {
WidgetsBinding.instance.addPostFrameCallback((_) {
// If showcase widget is at offset 1000 in the listview.
// If you don't know the exact position of the showcase widget,
// You can provide nearest possible location.
//
// In this case providing 990 instead of 1000 will work as well.
scrollController.jumpTo(990);
});
}
log('onStart: $index, $key');
},
onComplete: (index, key) {
log('onComplete: $index, $key');
if (index == 4) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.light.copyWith(
statusBarIconBrightness: Brightness.dark,
statusBarColor: Colors.white,
),
);
}
},
blurValue: 1,
builder: Builder(
builder: (context) => MailPage(
scrollController: scrollController,
)),
autoPlayDelay: const Duration(seconds: 3),
),
),
),
return MaterialApp(
title: 'Flutter ShowCase',
theme: ThemeData(
primaryColor: const Color(0xffEE5366),
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: ShowCaseWidget(
onStart: (index, key) {
log('onStart: $index, $key');
},
onComplete: (index, key) {
log('onComplete: $index, $key');
if (index == 4) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.light.copyWith(
statusBarIconBrightness: Brightness.dark,
statusBarColor: Colors.white,
),
);
}
},
blurValue: 1,
builder: Builder(builder: (context) => const MailPage()),
autoPlayDelay: const Duration(seconds: 3),
),
),
);
}
}

class MailPage extends StatefulWidget {
const MailPage({
Key? key,
required this.scrollController,
}) : super(key: key);
const MailPage({Key? key}) : super(key: key);

@override
_MailPageState createState() => _MailPageState();

final ScrollController scrollController;
}

class _MailPageState extends State<MailPage> {
Expand All @@ -88,6 +59,8 @@ class _MailPageState extends State<MailPage> {
final GlobalKey _five = GlobalKey();
List<Mail> mails = [];

final scrollController = ScrollController();

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -167,7 +140,7 @@ class _MailPageState extends State<MailPage> {

@override
void dispose() {
widget.scrollController.dispose();
scrollController.dispose();
super.dispose();
}

Expand Down Expand Up @@ -288,12 +261,11 @@ class _MailPageState extends State<MailPage> {
const Padding(padding: EdgeInsets.only(top: 8)),
Expanded(
child: ListView.builder(
scrollDirection: Axis.horizontal,
controller: widget.scrollController,
controller: scrollController,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, index) {
if (index == 3) {
return showcaseMailTile(_three, true, context, mails[index]);
if (index == 0) {
return showcaseMailTile(_three, true, context, mails.first);
}
return MailTile(
mail: mails[index % mails.length],
Expand All @@ -316,7 +288,7 @@ class _MailPageState extends State<MailPage> {
/* reset ListView to ensure that the showcased widgets are
* currently rendered so the showcased keys are available in the
* render tree. */
widget.scrollController.jumpTo(0);
scrollController.jumpTo(0);
ShowCaseWidget.of(context)
.startShowCase([_one, _two, _three, _four, _five]);
});
Expand Down Expand Up @@ -432,127 +404,122 @@ class MailTile extends StatelessWidget {
return Container(
padding: const EdgeInsets.only(left: 6, right: 16, top: 8, bottom: 8),
color: mail.isUnread ? const Color(0xffFFF6F7) : Colors.white,
child: SizedBox(
width: 400,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (showCaseDetail)
Showcase.withWidget(
key: showCaseKey!,
height: 50,
width: 140,
targetShapeBorder: const CircleBorder(),
targetBorderRadius: const BorderRadius.all(
Radius.circular(150),
),
container: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 45,
height: 45,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Color(0xffFCD8DC),
),
child: Center(
child: Text(
'S',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
const SizedBox(
height: 10,
),
const Text(
"Your sender's profile ",
style: TextStyle(color: Colors.white),
)
],
),
child: const SAvatarExampleChild(),
)
else
const SAvatarExampleChild(),
const Padding(padding: EdgeInsets.only(left: 8)),
Expanded(
child: Column(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (showCaseDetail)
Showcase.withWidget(
key: showCaseKey!,
height: 50,
width: 140,
targetShapeBorder: const CircleBorder(),
targetBorderRadius: const BorderRadius.all(
Radius.circular(150),
),
container: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mail.sender,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: mail.isUnread
? FontWeight.bold
: FontWeight.normal,
fontSize: 17,
Container(
width: 45,
height: 45,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Color(0xffFCD8DC),
),
),
Text(
mail.sub,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 16,
child: Center(
child: Text(
'S',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
Text(
mail.msg,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.normal,
color: mail.isUnread
? Theme.of(context).primaryColor
: Colors.black,
fontSize: 15,
),
const SizedBox(
height: 10,
),
const Text(
"Your sender's profile ",
style: TextStyle(color: Colors.white),
)
],
),
child: const SAvatarExampleChild(),
)
],
),
),
SizedBox(
width: 50,
child: Column(
children: <Widget>[
const SizedBox(
height: 5,
),
Text(
mail.date,
style: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 12,
color: Colors.grey,
),
),
const SizedBox(
height: 10,
else
const SAvatarExampleChild(),
const Padding(padding: EdgeInsets.only(left: 8)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
mail.sender,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: mail.isUnread
? FontWeight.bold
: FontWeight.normal,
fontSize: 17,
),
),
Text(
mail.sub,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 16,
),
),
Text(
mail.msg,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.normal,
color: mail.isUnread
? Theme.of(context).primaryColor
: Colors.black,
fontSize: 15,
),
),
],
),
Icon(
mail.isUnread ? Icons.star : Icons.star_border,
color:
mail.isUnread ? const Color(0xffFBC800) : Colors.grey,
)
],
),
),
SizedBox(
width: 50,
child: Column(
children: <Widget>[
const SizedBox(
height: 5,
),
Text(
mail.date,
style: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 12,
color: Colors.grey,
),
],
),
),
const SizedBox(
height: 10,
),
Icon(
mail.isUnread ? Icons.star : Icons.star_border,
color: mail.isUnread ? const Color(0xffFBC800) : Colors.grey,
),
],
),
],
),
),
],
),
);
}
Expand Down
Loading

0 comments on commit c6c9b07

Please sign in to comment.