Skip to content

Commit

Permalink
Merge pull request #43 from Rajkumarbhakta/master
Browse files Browse the repository at this point in the history
Fix issue #38
  • Loading branch information
sapatevaibhav authored May 12, 2024
2 parents 45c62ba + 89edc72 commit 08cdbac
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 76 deletions.
187 changes: 111 additions & 76 deletions lib/pages/parts.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_card_swiper/flutter_card_swiper.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_tts/flutter_tts.dart';
import 'package:learn/utils/constants.dart';
import 'package:learn/utils/functions.dart';
import 'package:learn/utils/responsive_screen_provider.dart';

void main() {
runApp(
Expand Down Expand Up @@ -66,85 +69,115 @@ class _PartsPagePageState extends State<PartsPage> {
body: SafeArea(
child: Column(
children: [
Flexible(
child: CardSwiper(
controller: controller,
cardsCount: cards.length,
onSwipe: (prevIndex, currentIndex, direction) {
setState(() {
previousIndices.add(topCardIndex);
topCardIndex = currentIndex ?? 0;
});
return true;
},
onUndo: _onUndo,
numberOfCardsDisplayed: 3,
backCardOffset: const Offset(40, 40),
padding: const EdgeInsets.all(24.0),
cardBuilder: (
context,
index,
horizontalThresholdPercentage,
verticalThresholdPercentage,
) =>
cards[index],
Expanded(
child: ResponsiveScreenProvider.isMobileScreen(context)?CardSwiper(
controller: controller,
cardsCount: cards.length,
onSwipe: (prevIndex, currentIndex, direction) {
setState(() {
previousIndices.add(topCardIndex);
topCardIndex = currentIndex ?? 0;
});
return true;
},
onUndo: _onUndo,
numberOfCardsDisplayed: 3,
backCardOffset: const Offset(40, 40),
padding: const EdgeInsets.all(24.0),
cardBuilder: (
context,
index,
horizontalThresholdPercentage,
verticalThresholdPercentage,
) =>
cards[index],
) :
Center(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.4,
width: MediaQuery.of(context).size.height * 0.6,
child: CardSwiper(
controller: controller,
cardsCount: cards.length,
onSwipe: (prevIndex, currentIndex, direction) {
setState(() {
previousIndices.add(topCardIndex);
topCardIndex = currentIndex ?? 0;
});
return true;
},
onUndo: _onUndo,
numberOfCardsDisplayed: 3,
backCardOffset: const Offset(40, 40),
padding: const EdgeInsets.all(24.0),
cardBuilder: (
context,
index,
horizontalThresholdPercentage,
verticalThresholdPercentage,
) =>
cards[index],
),
),
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
cards[topCardIndex].name,
style: const TextStyle(
fontSize: 50, fontWeight: FontWeight.bold),
),
const SizedBox(
width: 150,
),
Row(
children: [
IconButton(
icon: const Icon(
Icons.volume_up,
// color: Colors.black,
size: 40,
Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
cards[topCardIndex].name,
style: const TextStyle(
fontSize: 50, fontWeight: FontWeight.bold),
),
const SizedBox(
width: 150,
),
Row(
children: [
IconButton(
icon: const Icon(
Icons.volume_up,
// color: Colors.black,
size: 40,
),
onPressed: () {
_speakText(cards[topCardIndex].name);
},
),
onPressed: () {
_speakText(cards[topCardIndex].name);
},
),
const SizedBox(
width: 25,
),
IconButton(
onPressed: controller.undo,
icon: const Icon(
Icons.rotate_left,
// color: Colors.black,
size: 40,
const SizedBox(
width: 25,
),
),
],
),
const SizedBox(height: 10),
const SizedBox(height: 5),
SizedBox(
height: 200,
child: SingleChildScrollView(
clipBehavior: Clip.hardEdge,
child: Text(
AppFunctions()
.getDescription(cards[topCardIndex].name),
style: const TextStyle(
fontSize: 25,
IconButton(
onPressed: controller.undo,
icon: const Icon(
Icons.rotate_left,
// color: Colors.black,
size: 40,
),
),
],
),
const SizedBox(height: 10),
const SizedBox(height: 5),
SizedBox(
height: 200,
child: SingleChildScrollView(
clipBehavior: Clip.hardEdge,
child: Text(
AppFunctions()
.getDescription(cards[topCardIndex].name),
style: const TextStyle(
fontSize: 25,
),
),
),
),
),
],
],
),
),
),
),
Expand Down Expand Up @@ -202,10 +235,12 @@ class PartsPageCard extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
"assets/body/$name.svg",
width: 250,
height: 250,
Expanded(
child: SvgPicture.asset(
"assets/body/$name.svg",
width: 250,
height: 250,
),
),
const SizedBox(height: 10),
],
Expand Down
16 changes: 16 additions & 0 deletions lib/utils/responsive_screen_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';

class ResponsiveScreenProvider {
static bool isMobileScreen(BuildContext context) {
return MediaQuery.of(context).size.width < 480;
}

static bool isTabScreen(BuildContext context) {
return MediaQuery.of(context).size.width > 480 &&
MediaQuery.of(context).size.width < 800;
}

static bool isDesktopScreen(BuildContext context) {
return MediaQuery.of(context).size.width >= 800;
}
}

0 comments on commit 08cdbac

Please sign in to comment.