repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/flutter-ui/ui_3/lib
|
mirrored_repositories/flutter-ui/ui_3/lib/screens/indexPage.dart
|
import 'package:flutter/material.dart';
class IndexPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
height: 150.0,
width: MediaQuery.of(context).size.width,
color: Colors.blueAccent,
),
Positioned(
child: Center(
child: Column(
children: <Widget>[
Text(
"Your location here",
style: TextStyle(fontSize: 14.0, color: Colors.white54),
),
Row(
children: <Widget>[
Icon(
Icons.my_location,
color: Colors.white54,
),
Text(
"Bali Indonesia",
style:
TextStyle(fontSize: 14.0, color: Colors.white54),
),
],
)
],
),
))
],
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter-ui/ui_3
|
mirrored_repositories/flutter-ui/ui_3/test/widget_test.dart
|
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ui_3/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/flutter-ui/ui_4_login
|
mirrored_repositories/flutter-ui/ui_4_login/lib/socialMediaIcons.dart
|
import 'package:flutter/material.dart';
class SocialMediaIcons extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Social Media Icons"),
),
body: IconCollection(),
);
}
}
class IconCollection extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Padding(
padding: const EdgeInsets.only(left: 20.0, bottom: 35.0),
child: Column(
// crossAxisAlignment: CrossAxisAlignment.baseline,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
" Connect with us:",
style: TextStyle(
fontFamily: "OpenSans",
),
),
SizedBox(
height: 10.0,
),
Center(
child: Row(
children: [
RawMaterialButton(
onPressed: () {},
elevation: 8.0,
splashColor: Colors.blue,
fillColor: Color(0xFF1877f2),
child: Image(
image: AssetImage(
'assets/images/facebook_new.png',
),
height: 24.0,
),
padding: EdgeInsets.all(15.0),
shape: CircleBorder(),
),
RawMaterialButton(
onPressed: () {},
elevation: 8.0,
splashColor: Colors.deepOrangeAccent,
fillColor: Colors.white70,
child: Image(
image: AssetImage(
'assets/images/instagram.png',
),
height: 24.0,
),
padding: EdgeInsets.all(15.0),
shape: CircleBorder(),
),
RawMaterialButton(
onPressed: () {},
elevation: 8.0,
splashColor: Colors.red,
fillColor: Colors.white70,
child: Image(
image: AssetImage(
'assets/images/youtube.png',
),
height: 24.0,
),
padding: EdgeInsets.all(15.0),
shape: CircleBorder(),
),
],
),
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/flutter-ui/ui_4_login
|
mirrored_repositories/flutter-ui/ui_4_login/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flare_flutter/flare_actor.dart';
// import 'package:flutter_signin_button/flutter_signin_button.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: LoginUI(),
);
}
}
class LoginUI extends StatefulWidget {
@override
_LoginUIState createState() => _LoginUIState();
}
class _LoginUIState extends State<LoginUI> {
@override
Widget build(BuildContext context) {
double h = MediaQuery.of(context).size.height;
double w = MediaQuery.of(context).size.width;
return Scaffold(
resizeToAvoidBottomPadding: true,
body: Stack(
children: <Widget>[
Container(
// margin: EdgeInsets.only(top:h/15),
height: h / 1.2,
width: w,
child: RotatedBox(
quarterTurns: 0,
child: FlareActor(
'assets/images/changingColor.flr',
animation: 'Flow',
alignment: Alignment.bottomCenter,
fit: BoxFit.fill,
// isPaused: x,
),
),
),
Container(
margin: EdgeInsets.only(top: w / 4, left: w / 7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
Text(
"Dami",
style: TextStyle(
color: Color(0xE3FFFFFF),
fontSize: 40,
fontFamily: 'AGaramondPro',
fontWeight: FontWeight.w600),
),
Text(
" Hami",
style: TextStyle(
color: Colors.black54,
fontSize: 40,
fontFamily: 'AGaramondPro',
fontWeight: FontWeight.w600),
),
],
),
Text(
"A new Platform for you.",
style: TextStyle(
color: Colors.white,
// fontSize: 1,
// fontWeight: FontWeight.bold,
fontFamily: 'OpenSans',
// fontWeight: FontWeight.w600,
),
),
SizedBox(height: 190),
//Google logo
Container(
height: 50.0,
width: w / 1.5,
child: RaisedButton(
onPressed: () {},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(70)),
color: Color(0xFFFFFFFF),
elevation: 18.0,
child: Container(
// height: 40.0,
// padding: EdgeInsets.only(left: 1.0),
child: Row(
children: [
ClipRRect(
child: Image(
image: AssetImage(
'assets/images/google_light.png',
),
height: 35.0,
),
),
Text(
"Sign in with Google",
style: TextStyle(color: Colors.black54),
),
],
),
),
),
),
SizedBox(
height: 20.0,
),
//Facebook logo
Container(
height: 50.0,
width: w / 1.5,
child: RaisedButton(
onPressed: () {},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(70)),
color: Color(0xFF1877f2),
elevation: 18.0,
child: Container(
// height: 40.0,
padding: EdgeInsets.only(left: 3.0),
child: Row(
children: [
ClipRRect(
child: Image(
image: AssetImage(
'assets/images/facebook_new.png',
),
height: 24.0,
),
),
Text(
" Sign in with Facebook",
style: TextStyle(color: Colors.white),
),
],
),
),
),
)
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter-ui/ui_4_login
|
mirrored_repositories/flutter-ui/ui_4_login/test/widget_test.dart
|
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ui_4_login/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/lib/initial_list.dart
|
import 'task.dart';
import 'package:flutter/material.dart';
List<Task> tasks = [
new Task(
name: "Catch up with Brian",
category: "Mobile Project",
time: "5pm",
color: Colors.orange,
completed: false),
new Task(
name: "Make new icons",
category: "Web App",
time: "3pm",
color: Colors.cyan,
completed: true),
new Task(
name: "Design explorations",
category: "Company Website",
time: "2pm",
color: Colors.pink,
completed: false),
new Task(
name: "Lunch with Mary",
category: "Grill House",
time: "12pm",
color: Colors.cyan,
completed: true),
new Task(
name: "Teem Meeting",
category: "Hangouts",
time: "10am",
color: Colors.cyan,
completed: true),
new Task(
name: "Catch up with Brian",
category: "Mobile Project",
time: "5pm",
color: Colors.orange,
completed: false),
new Task(
name: "Make new icons",
category: "Web App",
time: "3pm",
color: Colors.cyan,
completed: true),
new Task(
name: "Design explorations",
category: "Company Website",
time: "2pm",
color: Colors.pink,
completed: false),
new Task(
name: "Lunch with Mary",
category: "Grill House",
time: "12pm",
color: Colors.cyan,
completed: true),
new Task(
name: "Teem Meeting",
category: "Hangouts",
time: "10am",
color: Colors.cyan,
completed: true),
];
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/lib/task.dart
|
import 'package:flutter/material.dart';
class Task {
final String name;
final String category;
final String time;
final Color color;
final bool completed;
Task({this.name, this.category, this.time, this.color, this.completed});
}
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/lib/task_row.dart
|
import 'package:flutter/material.dart';
import 'task.dart';
//task.dart finished task_row.dart started
class TaskRow extends StatelessWidget {
final Task task;
final double dotSize = 12.0;
final Animation<double> animation;
const TaskRow({Key key, this.task, this.animation}) : super(key: key);
@override
Widget build(BuildContext context) {
return new FadeTransition(
opacity: animation,
child: new SizeTransition(
sizeFactor: animation,
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: new Row(
children: <Widget>[
new Padding(
padding:
new EdgeInsets.symmetric(horizontal: 32.0 - dotSize / 2),
child: new Container(
height: dotSize,
width: dotSize,
decoration: new BoxDecoration(
shape: BoxShape.circle, color: task.color),
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
task.name,
style: new TextStyle(fontSize: 18.0),
),
new Text(
task.category,
style: new TextStyle(fontSize: 12.0, color: Colors.grey),
)
],
),
),
new Padding(
padding: const EdgeInsets.only(right: 16.0),
child: new Text(
task.time,
style: new TextStyle(fontSize: 12.0, color: Colors.grey),
),
),
],
),
),
),
);
}
}
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/lib/animated_fab.dart
|
import 'dart:math' as math;
import 'package:flutter/material.dart';
class AnimatedFab extends StatefulWidget {
final VoidCallback onClick;
const AnimatedFab({Key key, this.onClick}) : super(key: key);
@override
_AnimatedFabState createState() => new _AnimatedFabState();
}
class _AnimatedFabState extends State<AnimatedFab>
with SingleTickerProviderStateMixin {
AnimationController _animationController;
Animation<Color> _colorAnimation;
final double expandedSize = 180.0;
final double hiddenSize = 20.0;
@override
void initState() {
super.initState();
_animationController = new AnimationController(
vsync: this, duration: Duration(milliseconds: 200));
_colorAnimation = new ColorTween(begin: Colors.pink, end: Colors.pink[800])
.animate(_animationController);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new SizedBox(
width: expandedSize,
height: expandedSize,
child: new AnimatedBuilder(
animation: _animationController,
builder: (BuildContext context, Widget child) {
return new Stack(
alignment: Alignment.center,
children: <Widget>[
_buildExpandedBackground(),
_buildOption(Icons.check_circle, 0.0),
_buildOption(Icons.flash_on, -math.pi / 3),
_buildOption(Icons.access_time, -2 * math.pi / 3),
_buildOption(Icons.error_outline, math.pi),
_buildFabCore(),
],
);
},
),
);
}
Widget _buildOption(IconData icon, double angle) {
if (_animationController.isDismissed) {
return Container();
}
double iconSize = 0.0;
if (_animationController.value > 0.8) {
iconSize = 26.0 * (_animationController.value - 0.8) * 5;
}
return new Transform.rotate(
angle: angle,
child: new Align(
alignment: Alignment.topCenter,
child: new Padding(
padding: new EdgeInsets.only(top: 8.0),
child: new IconButton(
onPressed: _onIconClick,
icon: new Transform.rotate(
angle: -angle,
child: new Icon(
icon,
color: Colors.white,
),
),
iconSize: iconSize,
alignment: Alignment.center,
padding: new EdgeInsets.all(0.0),
),
),
),
);
}
Widget _buildExpandedBackground() {
double size =
hiddenSize + (expandedSize - hiddenSize) * _animationController.value;
return new Container(
height: size,
width: size,
decoration: new BoxDecoration(shape: BoxShape.circle, color: Colors.pink),
);
}
Widget _buildFabCore() {
double scaleFactor = 2 * (_animationController.value - 0.5).abs();
return new FloatingActionButton(
onPressed: _onFabTap,
child: new Transform(
alignment: Alignment.center,
transform: new Matrix4.identity()..scale(1.0, scaleFactor),
child: new Icon(
_animationController.value > 0.5 ? Icons.close : Icons.filter_list,
color: Colors.white,
size: 26.0,
),
),
backgroundColor: _colorAnimation.value,
);
}
open() {
if (_animationController.isDismissed) {
_animationController.forward();
}
}
close() {
if (_animationController.isCompleted) {
_animationController.reverse();
}
}
_onFabTap() {
if (_animationController.isDismissed) {
open();
} else {
close();
}
}
_onIconClick() {
widget.onClick();
close();
}
}
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:todo_app/initial_list.dart';
import 'custom_clipper.dart';
import 'task_row.dart';
import 'list_model.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MainPage(),
);
}
}
class MainPage extends StatefulWidget {
MainPage({Key key}) : super(key: key);
@override
_MainPageState createState() => new _MainPageState();
}
class _MainPageState extends State<MainPage> {
final GlobalKey<AnimatedListState> _listKey =
new GlobalKey<AnimatedListState>();
double _imageHeight = 256.0;
ListModel listModel;
bool showOnlyCompleted = false;
@override
void initState() {
super.initState();
listModel = new ListModel(_listKey, tasks);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
_buildImage(),
_buildTopHeader(),
_buildProfileRow(),
_buildBottomPart(),
_buildTimeline(),
_buildFab(),
],
),
);
}
Widget _buildImage() {
return Positioned.fill(
bottom: null,
child: ClipPath(
clipper: new DiagonalClipper(),
child: new Image.asset(
'images/birds.jpg',
fit: BoxFit.cover,
height: _imageHeight,
colorBlendMode: BlendMode.srcOver,
color: new Color.fromARGB(120, 20, 10, 40),
),
),
);
}
Widget _buildTopHeader() {
return new Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 32.0),
child: new Row(
children: <Widget>[
new Icon(Icons.menu, size: 32.0, color: Colors.white),
new Expanded(
child: new Padding(
padding: const EdgeInsets.only(left: 16.0),
child: new Text(
"Timeline",
style: new TextStyle(
fontSize: 20.0,
color: Colors.white,
fontWeight: FontWeight.w300),
),
),
),
new Icon(Icons.linear_scale, color: Colors.white),
],
),
);
}
Widget _buildProfileRow() {
return Padding(
padding: EdgeInsets.only(left: 16.0, top: _imageHeight / 2.5),
child: Row(
children: <Widget>[
CircleAvatar(
backgroundImage: AssetImage('images/avatar.jpg'),
minRadius: 28.0,
maxRadius: 28.0,
),
Padding(
padding: EdgeInsets.only(left: 16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'John Doe',
style: TextStyle(
fontSize: 26.0,
color: Colors.white,
fontWeight: FontWeight.w400),
),
Text(
'Product Manager',
style: TextStyle(
fontSize: 14.0,
color: Colors.white,
fontWeight: FontWeight.w300),
),
],
),
)
],
),
);
}
Widget _buildBottomPart() {
return Padding(
padding: EdgeInsets.only(top: _imageHeight),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildTaskHeader(),
_buildTasksList(),
],
),
);
}
Widget _buildTaskHeader() {
return Padding(
padding: EdgeInsets.only(left: 64.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'My Tasks',
style: TextStyle(fontSize: 34.0),
),
Text(
'Date: Aug 8',
style: TextStyle(color: Colors.grey, fontSize: 12.0),
),
],
),
);
}
Widget _buildTasksList() {
return new Expanded(
child: new AnimatedList(
initialItemCount: tasks.length,
key: _listKey,
itemBuilder: (context, index, animation) {
return new TaskRow(
task: listModel[index],
animation: animation,
);
},
),
);
}
Widget _buildTimeline() {
return new Positioned(
top: _imageHeight - 55,
bottom: 0.0,
left: 32.0,
child: new Container(
width: 1.0,
color: Colors.grey[300],
),
);
}
Widget _buildFab() {
return new Positioned(
top: _imageHeight - 36.0,
right: 16.0,
child: new FloatingActionButton(
onPressed: _changeFilterState,
backgroundColor: Colors.pink,
child: new Icon(Icons.filter_list),
),
);
}
void _changeFilterState() {
showOnlyCompleted = !showOnlyCompleted;
tasks.where((task) => !task.completed).forEach((task) {
if (showOnlyCompleted) {
listModel.removeAt(listModel.indexOf(task));
} else {
listModel.insert(tasks.indexOf(task), task);
}
});
}
}
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/lib/custom_clipper.dart
|
import 'package:flutter/material.dart';
class DiagonalClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = new Path();
path.lineTo(0.0, size.height - 60.0);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/lib/list_model.dart
|
import 'task_row.dart';
import 'task.dart';
import 'package:flutter/material.dart';
class ListModel {
ListModel(this.listKey, items) : this.items = new List.of(items);
final GlobalKey<AnimatedListState> listKey;
final List<Task> items;
AnimatedListState get _animatedList => listKey.currentState;
void insert(int index, Task item) {
items.insert(index, item);
_animatedList.insertItem(index, duration: new Duration(milliseconds: 150));
}
Task removeAt(int index) {
final Task removedItem = items.removeAt(index);
if (removedItem != null) {
_animatedList.removeItem(
index,
(context, animation) => new TaskRow(
task: removedItem,
animation: animation,
),
duration: new Duration(
milliseconds: (150 + 200 * (index / length)).toInt()));
}
return removedItem;
}
int get length => items.length;
Task operator [](int index) => items[index];
int indexOf(Task item) => items.indexOf(item);
}
| 0
|
mirrored_repositories/flutter-ui/todo_app
|
mirrored_repositories/flutter-ui/todo_app/test/widget_test.dart
|
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:todo_app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/flutter-ui/day1_ui
|
mirrored_repositories/flutter-ui/day1_ui/lib/main.dart
|
import 'package:flutter/material.dart';
import 'home_UI/index_page.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
title: "Blog Profile",
home: Scaffold(
body: IndexPage(),
floatingActionButton: FloatingActionButton(
onPressed: () {
null;
},
child: Icon(Icons.message),
tooltip: "Message Box",
),
),
));
void showSnackBar(BuildContext context) {
var snackBar = SnackBar(content: Text(" Message Button was Tapped");
Scaffold.of(context).showSnackBar(snackBar);
}
}
| 0
|
mirrored_repositories/flutter-ui/day1_ui/lib
|
mirrored_repositories/flutter-ui/day1_ui/lib/home_UI/index_page.dart
|
import 'package:flutter/material.dart';
class IndexPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Header(),
SizedBox(
height: 150.0,
),
_subheading(),
ArticleCard(),
],
);
}
}
class Header extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
height: 200,
width: double.infinity,
color: Colors.redAccent,
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: IconButton(icon: Icon(Icons.menu), onPressed: null),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: Text(
"Articles",
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.bold,
color: Colors.black45),
),
)
],
),
),
Positioned(
top: 125.0,
left: 15.0,
right: 15.0,
child: Material(
elevation: 3.0,
borderRadius: BorderRadius.circular(7.0),
child: Container(
height: 200.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.0),
color: Colors.white),
),
),
),
Positioned(
top: 75,
left: (MediaQuery.of(context).size.width / 2 - 50.0),
child: CircleAvatar(
radius: 55,
backgroundColor: Color(0xffFDCF09),
child: CircleAvatar(
radius: 50,
backgroundImage: AssetImage("images/Avatar.jpg"),
),
)),
Positioned(
top: 190.0,
left: (MediaQuery.of(context).size.width / 2 - 105.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Iron Man",
style: TextStyle(fontSize: 17.0, fontWeight: FontWeight.bold),
),
SizedBox(
height: 7.0,
),
Text(
"Stark International",
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.normal,
color: Colors.grey),
),
SizedBox(
height: 10.0,
),
Row(
children: <Widget>[
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(7.0)),
onPressed: () {
debugPrint("Message was tapped !!!");
},
color: Color(0xFFFA624F),
child: Text(
"Message",
style: TextStyle(fontSize: 15.0, color: Colors.white),
),
),
SizedBox(width: 10.0),
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(7.0)),
onPressed: () {
debugPrint("Message was tapped !!!");
},
color: Color(0xFFFA624F),
child: Text(
"Following",
style: TextStyle(fontSize: 15.0, color: Colors.white),
),
),
],
),
],
))
],
);
}
}
Widget _subheading() {
return Padding(
padding: const EdgeInsets.only(left: 15.0, right: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Most Popular",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),
),
Text(
"See All",
style: TextStyle(
fontSize: 15.0, color: Colors.grey, fontWeight: FontWeight.bold),
)
],
),
);
}
class ArticleCard extends StatelessWidget {
// final listItem =
// List<String>.generate(20, (index) => "Article Number: %index");
@override
Widget build(BuildContext context) {
return ListView(
shrinkWrap: true,
// scrollDirection: Axis.vertical,
children: <Widget>[
Container(
height: 125.0,
padding: EdgeInsets.only(left: 12.0, right: 12.0),
width: MediaQuery.of(context).size.width,
child: Card(
color: Colors.white,
elevation: 4.0,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(8.0),
child: Image.asset("images/Joker.jpg"),
),
Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Text(
"Heading Here",
style: TextStyle(
fontSize: 18.0, fontWeight: FontWeight.bold),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Consider applying a flex factor.",
style:
TextStyle(fontSize: 10.0, color: Colors.grey),
),
],
),
],
),
],
)),
),
Container(
height: 125.0,
padding: EdgeInsets.only(left: 12.0, right: 12.0),
width: MediaQuery.of(context).size.width,
child: Card(
color: Colors.white,
elevation: 4.0,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(8.0),
child: Image.asset("images/Joker.jpg"),
),
Column(
children: <Widget>[
SizedBox(
height: 15.0,
),
Text(
"Heading Here",
style: TextStyle(
fontSize: 18.0, fontWeight: FontWeight.bold),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Consider applying a flex factor.",
style:
TextStyle(fontSize: 10.0, color: Colors.grey),
),
],
),
],
),
],
)),
),
],
);
}
}
| 0
|
mirrored_repositories/flutter-ui/day1_ui
|
mirrored_repositories/flutter-ui/day1_ui/test/widget_test.dart
|
// // This is a basic Flutter widget test.
// //
// // To perform an interaction with a widget in your test, use the WidgetTester
// // utility that Flutter provides. For example, you can send tap and scroll
// // gestures. You can also use WidgetTester to find child widgets in the widget
// // tree, read text, and verify that the values of widget properties are correct.
// import 'package:flutter/material.dart';
// import 'package:flutter_test/flutter_test.dart';
// import 'package:day1_ui/main.dart';
// void main() {
// testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// // Build our app and trigger a frame.
// await tester.pumpWidget(MyApp());
// // Verify that our counter starts at 0.
// expect(find.text('0'), findsOneWidget);
// expect(find.text('1'), findsNothing);
// // Tap the '+' icon and trigger a frame.
// await tester.tap(find.byIcon(Icons.add));
// await tester.pump();
// // Verify that our counter has incremented.
// expect(find.text('0'), findsNothing);
// expect(find.text('1'), findsOneWidget);
// });
// }
| 0
|
mirrored_repositories/flutter-ui/day2_ui
|
mirrored_repositories/flutter-ui/day2_ui/lib/main.dart
|
import 'package:flutter/material.dart';
import 'screens/indexPage.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Travel and Explore App',
home: IndexPage(),
);
}
}
| 0
|
mirrored_repositories/flutter-ui/day2_ui/lib
|
mirrored_repositories/flutter-ui/day2_ui/lib/screens/IndexPage.dart
|
import 'package:flutter/material.dart';
import './dashboard.dart';
class IndexPage extends StatefulWidget {
@override
_IndexPageState createState() => _IndexPageState();
}
class _IndexPageState extends State<IndexPage> {
var selectedItem = 0;
List children = [Dashboard(), Dashboard(), Dashboard(), Dashboard()];
@override
Widget build(BuildContext context) {
return Scaffold(
body: children[selectedItem],
backgroundColor: Color(0xFF202020),
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Color(0xFF1B1B1B),
selectedItemColor: Color(0xFFD4F99),
iconSize: 27.0,
currentIndex: selectedItem,
unselectedLabelStyle: TextStyle(color: Color(0xFF1B1B1B)),
unselectedItemColor: Color(0xFF888888),
onTap: (currentIndex) {
setState(() {
selectedItem = currentIndex;
});
},
items: [
BottomNavigationBarItem(
backgroundColor: Color(0xFF1B1B1B),
icon: Icon(
Icons.home,
color: Colors.white54,
),
title: Container(
height: 5.0,
width: 5.0,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Color(0xFFFD4F99)),
)),
BottomNavigationBarItem(
backgroundColor: Color(0xFF1B1B1B),
icon: Icon(
Icons.search,
color: Colors.white54,
),
title: Container(
height: 5.0,
width: 5.0,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Color(0xFFFD4F99)),
)),
BottomNavigationBarItem(
backgroundColor: Color(0xFF1B1B1B),
icon: Icon(
Icons.camera,
color: Colors.white54,
),
title: Container(
height: 5.0,
width: 5.0,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Color(0xFFFD4F99)),
)),
BottomNavigationBarItem(
backgroundColor: Color(0xFF1B1B1B),
icon: Icon(
Icons.person,
color: Colors.white54,
),
title: Container(
height: 5.0,
width: 5.0,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Color(0xFFFD4F99)),
)),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter-ui/day2_ui/lib
|
mirrored_repositories/flutter-ui/day2_ui/lib/screens/detailsPage.dart
|
import 'dart:ui';
import 'package:flutter/material.dart';
class DetailsPage extends StatefulWidget {
final imgPath, title;
DetailsPage({this.imgPath, this.title});
@override
_DetailsPageState createState() => _DetailsPageState();
}
class _DetailsPageState extends State<DetailsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(widget.imgPath), fit: BoxFit.cover)),
),
BackdropFilter(
filter: new ImageFilter.blur(sigmaX: 4, sigmaY: 4),
child: Container(
decoration: BoxDecoration(color: Colors.black.withOpacity(0.5)),
),
),
Padding(
padding: EdgeInsets.fromLTRB(15.0, 35.0, 15.0, 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.0),
color: Color(0xFFFD4F99)),
child: Center(
child: Icon(Icons.filter_list, color: Colors.white))),
Text(widget.title.toString().toUpperCase(),
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w400,
color: Colors.white)),
Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.0),
color: Color(0xFF353535)),
child: Center(
child: Icon(Icons.bookmark_border, color: Colors.white),
),
),
],
)),
Positioned(
top: 100.0,
child: Padding(
padding: EdgeInsets.all(15.0),
child: Column(
children: <Widget>[
//For Trending Attractions and more_vert icon
Container(
width: MediaQuery.of(context).size.width - 15.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Trending Attractions',
style: TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
IconButton(
icon:
Icon(Icons.more_vert, color: Colors.white),
onPressed: () {},
)
],
)),
SizedBox(height: 10.0),
//for image and description card
Stack(
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: 10.0),
child: Container(
height: 200.0,
width: 325.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: AssetImage('images/kyoto.jpg'),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.6),
BlendMode.darken))),
)),
//for discription kyoto tour and .....
Positioned(
top: 125.0,
left: 10.0,
child: Container(
width:
MediaQuery.of(context).size.width - 60.0,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text('Kyoto tour',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: Colors.white)),
Text(
'Three day tour around Kyoto',
style: TextStyle(
fontSize: 14.0,
color: Colors.white),
)
],
),
Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(7.0),
color: Colors.white),
child: Center(
child: Icon(Icons.arrow_forward_ios,
color: Color(0xFFFD4F99),
size: 14.0),
),
)
],
)))
],
),
SizedBox(height: 20.0),
Container(
width: MediaQuery.of(context).size.width - 15.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Weekly Highlights',
style: TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
color: Colors.white),
)
],
)),
SizedBox(height: 15.0),
Container(
height: 200.0,
width: MediaQuery.of(context).size.width,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
_buildListItem('images/japan.jpg',
'Takashi castle', '\$200 - \$400'),
_buildListItem('images/kyoto.jpg',
'Heaven\'s gate', '\$50 - \$150'),
_buildListItem('images/canada.jpg', 'Miay gate',
'\$300 - \$350')
],
))
],
)))
],
),
);
}
_buildListItem(String imgPath, String placeName, String price) {
return Padding(
padding: EdgeInsets.all(10.0),
child: Stack(children: [
Container(
height: 175.0,
width: 150.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.0),
image: DecorationImage(
image: AssetImage(imgPath),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.6), BlendMode.darken)))),
Positioned(
top: 15.0,
right: 15.0,
child: Container(
height: 25.0,
width: 25.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: Colors.white),
child: Center(
child: Icon(
Icons.bookmark_border,
color: Color(0xFFFD4F99),
size: 14.0,
)))),
Positioned(
top: 125.0,
left: 15.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(placeName,
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 15.0,
color: Colors.white)),
Text(price,
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 14.0,
color: Colors.white))
],
))
]));
}
}
| 0
|
mirrored_repositories/flutter-ui/day2_ui/lib
|
mirrored_repositories/flutter-ui/day2_ui/lib/screens/dashboard.dart
|
import './detailsPage.dart';
import 'package:flutter/material.dart';
class Dashboard extends StatefulWidget {
@override
_DashboardState createState() => _DashboardState();
}
class _DashboardState extends State<Dashboard> {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
SizedBox(
height: 20.0,
),
_header(),
SizedBox(height: 10.0),
Container(
//modify the size 150 by around 140 or 145 to get the best view
height: MediaQuery.of(context).size.height - 150,
child: ListView(
children: <Widget>[
_buildListItem(
'images/japan.jpg', "Japan", "Home country of One Piece"),
_buildListItem(
'images/canada.jpg', "Canada", "Nicest People on Earth"),
],
),
)
],
);
}
Widget _header() {
return Padding(
padding: EdgeInsets.only(top: 15.0, left: 15.0, right: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.0),
color: Color(0xFFFD4F99)),
child: Center(
child: Icon(Icons.filter_list, color: Colors.white),
),
),
Text(
'HOME',
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w400,
color: Colors.white),
),
// Inreal case scenerio, this shouldnot be container
//should be wrapped with inkwell INKWELL
Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.0),
color: Color(0xFF353535)),
child: Center(
child: Icon(Icons.bookmark_border, color: Colors.white),
),
),
],
),
);
}
_buildListItem(String imgPath, String country, String description) {
return Padding(
padding: EdgeInsets.all(15.0),
child: Stack(
children: <Widget>[
Container(
height: 300.0,
),
Container(
height: 300.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: AssetImage(imgPath),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.7), BlendMode.darken))),
),
Container(
height: 300.0,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
country,
style: TextStyle(
fontSize: 30.0,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Text(
description,
style: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.w400,
color: Colors.white),
),
SizedBox(height: 20.0),
InkWell(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) =>
DetailsPage(imgPath: imgPath, title: country)));
},
child: Container(
height: 50.0,
width: 125.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: Colors.white),
child: Center(
child: Text(
"Explore Now",
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.bold,
color: Color(0xFFFD4F99)),
),
),
),
)
],
),
),
)
],
),
);
}
}
| 0
|
mirrored_repositories/flutter-ui/day2_ui
|
mirrored_repositories/flutter-ui/day2_ui/test/widget_test.dart
|
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:day2_ui/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/parking_lot_game
|
mirrored_repositories/parking_lot_game/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:parking_lot_game/logic/parking.dart';
import 'package:provider/provider.dart';
import 'screens/screens.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => ParkingLot(),
child: MaterialApp(
theme: ThemeData(
textTheme: GoogleFonts.jetBrainsMonoTextTheme(
Theme.of(context).textTheme,
),
),
home: const PageTitle(),
),
);
}
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/components/game_control.dart
|
import 'package:flutter/material.dart';
import 'package:parking_lot_game/components/components.dart';
import 'package:parking_lot_game/logic/logic.dart';
import 'package:parking_lot_game/model/car.dart';
import 'package:provider/provider.dart';
class GameControl extends StatelessWidget {
const GameControl({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Consumer<ParkingLot>(
builder: (_, provider, __) {
return Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Card(
color: Colors.black45,
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
children: [
const Text(
'Parking Lot Software Inc.',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.white,
),
),
Text.rich(
TextSpan(
style: const TextStyle(color: Colors.white),
children: [
const TextSpan(text: 'Available slots: '),
TextSpan(
text: '${provider.getAvailable}',
style: const TextStyle(
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
)
],
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.all(15),
child: ElevatedButton(
onPressed: () =>
!provider.isFull ? _onPressPark(context) : null,
style: ElevatedButton.styleFrom(
fixedSize: Size(MediaQuery.of(context).size.width, 50),
primary: provider.isFull ? Colors.red : Colors.green,
),
child: const Text(
'PARK!',
style: TextStyle(fontSize: 20),
),
),
),
const Icon(
Icons.drive_eta_rounded,
size: 50,
color: Colors.red,
),
const Text(
'Click on a busy parking slot to unpark the car',
textAlign: TextAlign.center,
),
],
),
);
},
);
}
void _onPressPark(BuildContext context) {
final provider = context.read<ParkingLot>();
final brand = CarBrandExtension.generateRandomCarBrand();
final plate = CarPlateExtension.generateRandomCarPlate();
final Car car = Car(brand: brand.getString(), plate: plate);
if (provider.park(car)) {
showSnackBar(context, 'Park successful!');
} else if (provider.isFull) {
showSnackBar(context, 'Parking lot is full');
}
}
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/components/title_main.dart
|
import 'package:flutter/material.dart';
class TitleMain extends StatelessWidget {
const TitleMain({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Flexible(
child: Padding(
padding: EdgeInsets.all(20),
child: Text(
'Welcome to Parking Lot',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 80,
fontWeight: FontWeight.bold,
),
),
),
);
}
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/components/title_button.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:parking_lot_game/components/components.dart';
import 'package:parking_lot_game/logic/parking.dart';
import 'package:provider/provider.dart';
import '../screens/screens.dart';
class TitleButton extends StatefulWidget {
const TitleButton({
Key? key,
required this.textEditingController,
}) : super(key: key);
final TextEditingController textEditingController;
@override
State<TitleButton> createState() => _TitleButtonState();
}
class _TitleButtonState extends State<TitleButton> {
// -------------------------------- PROPERTIES -------------------------------
late FocusNode _focusNode;
// --------------------------------- METHODS ---------------------------------
@override
void initState() {
_focusNode = FocusNode();
super.initState();
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Flexible(
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'How many parking slots you need?',
textAlign: TextAlign.center,
),
Padding(
padding: const EdgeInsets.only(top: 15, bottom: 30),
child: TextField(
focusNode: _focusNode,
controller: widget.textEditingController,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
textAlign: TextAlign.center,
decoration: const InputDecoration(
contentPadding: EdgeInsets.all(0),
fillColor: Colors.white,
filled: true,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
hintText: 'Enter desired number from 1-20',
),
onSubmitted: (_) => _onSubmitSlots(
widget.textEditingController.text,
),
),
),
ElevatedButton(
onPressed: () => _onSubmitSlots(
widget.textEditingController.text,
),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
primary: Colors.green,
),
child: const Text(
'Pressed to Start',
style: TextStyle(fontSize: 20),
),
),
],
),
),
);
}
void _onSubmitSlots(String input) {
if (input.isEmpty) {
showSnackBar(context, 'Please enter a number');
} else if (int.tryParse(input) == null) {
showSnackBar(context, 'Please enter a valid number');
} else if (int.parse(input) > 20) {
showSnackBar(context, 'Please enter a number range from 1-20');
} else {
final provider = context.read<ParkingLot>();
provider.setSlots = int.parse(input);
Navigator.push(
context,
CupertinoPageRoute(
builder: (_) => const PageGame(),
),
);
}
}
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/components/snackbar.dart
|
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void showSnackBar(BuildContext context, String text) {
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(
SnackBar(
content: Text(
text,
style: GoogleFonts.jetBrainsMono(fontSize: 16),
),
),
);
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/components/components.dart
|
export 'game_control.dart';
export 'game_layout.dart';
export 'snackbar.dart';
export 'title_button.dart';
export 'title_main.dart';
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/components/game_layout.dart
|
import 'package:flutter/material.dart';
import 'package:parking_lot_game/components/components.dart';
import 'package:provider/provider.dart';
import '../logic/logic.dart';
import '../model/car.dart';
class GameLayout extends StatelessWidget {
const GameLayout({Key? key, required this.constraints}) : super(key: key);
final BoxConstraints constraints;
@override
Widget build(BuildContext context) {
const tileHeight = 100;
const tileWidth = 100;
return Consumer<ParkingLot>(
builder: (_, provider, __) {
final countPotrait = constraints.maxWidth ~/ tileWidth;
final countHorizontal = constraints.maxHeight ~/ tileWidth;
return Padding(
padding: const EdgeInsets.all(20),
child: GridView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:
constraints.maxWidth > 600 ? countHorizontal : countPotrait,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
childAspectRatio: tileWidth / tileHeight,
),
itemCount: provider.getSize,
itemBuilder: (BuildContext context, int index) {
final car = provider.getSlots[index];
index += 1;
return InkWell(
onTap: () => _onTapPark(context, car),
splashColor: Colors.lightBlue,
child: Card(
color: car != null ? Colors.red : Colors.green,
child: Center(
child: Text(
car == null
? 'Slot $index'
: '${car.brand}\n${car.plate}',
textAlign: TextAlign.center,
),
),
),
);
},
),
);
},
);
}
void _onTapPark(BuildContext context, Car? car) {
final provider = context.read<ParkingLot>();
if (car != null) {
if (provider.remove(car)) {
showSnackBar(context, 'Successfully removed a car');
}
}
}
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/model/car.freezed.dart
|
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
part of 'car.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
mixin _$Car {
String get brand => throw _privateConstructorUsedError;
String get plate => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$CarCopyWith<Car> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CarCopyWith<$Res> {
factory $CarCopyWith(Car value, $Res Function(Car) then) =
_$CarCopyWithImpl<$Res>;
$Res call({String brand, String plate});
}
/// @nodoc
class _$CarCopyWithImpl<$Res> implements $CarCopyWith<$Res> {
_$CarCopyWithImpl(this._value, this._then);
final Car _value;
// ignore: unused_field
final $Res Function(Car) _then;
@override
$Res call({
Object? brand = freezed,
Object? plate = freezed,
}) {
return _then(_value.copyWith(
brand: brand == freezed
? _value.brand
: brand // ignore: cast_nullable_to_non_nullable
as String,
plate: plate == freezed
? _value.plate
: plate // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
abstract class _$$_CarCopyWith<$Res> implements $CarCopyWith<$Res> {
factory _$$_CarCopyWith(_$_Car value, $Res Function(_$_Car) then) =
__$$_CarCopyWithImpl<$Res>;
@override
$Res call({String brand, String plate});
}
/// @nodoc
class __$$_CarCopyWithImpl<$Res> extends _$CarCopyWithImpl<$Res>
implements _$$_CarCopyWith<$Res> {
__$$_CarCopyWithImpl(_$_Car _value, $Res Function(_$_Car) _then)
: super(_value, (v) => _then(v as _$_Car));
@override
_$_Car get _value => super._value as _$_Car;
@override
$Res call({
Object? brand = freezed,
Object? plate = freezed,
}) {
return _then(_$_Car(
brand: brand == freezed
? _value.brand
: brand // ignore: cast_nullable_to_non_nullable
as String,
plate: plate == freezed
? _value.plate
: plate // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$_Car implements _Car {
_$_Car({required this.brand, required this.plate});
@override
final String brand;
@override
final String plate;
@override
String toString() {
return 'Car(brand: $brand, plate: $plate)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Car &&
const DeepCollectionEquality().equals(other.brand, brand) &&
const DeepCollectionEquality().equals(other.plate, plate));
}
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(brand),
const DeepCollectionEquality().hash(plate));
@JsonKey(ignore: true)
@override
_$$_CarCopyWith<_$_Car> get copyWith =>
__$$_CarCopyWithImpl<_$_Car>(this, _$identity);
}
abstract class _Car implements Car {
factory _Car({required final String brand, required final String plate}) =
_$_Car;
@override
String get brand => throw _privateConstructorUsedError;
@override
String get plate => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$$_CarCopyWith<_$_Car> get copyWith => throw _privateConstructorUsedError;
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/model/car.dart
|
import 'package:freezed_annotation/freezed_annotation.dart';
part 'car.freezed.dart';
@freezed
class Car with _$Car {
factory Car({
required String brand,
required String plate,
}) = _Car;
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/logic/parking.dart
|
import 'package:flutter/material.dart';
import '../model/car.dart';
class ParkingLot extends ChangeNotifier {
List<Car?> _slots = [];
set setSlots(int parkingSize) {
_slots.clear();
_slots = List.filled(parkingSize, null, growable: true);
notifyListeners();
}
bool park(Car car) {
if (_slots.every((element) => element != null)) {
return false;
}
for (int i = 0; i <= _slots.length; i++) {
final slot = _slots[i];
if (slot == null) {
_slots[i] = car;
notifyListeners();
return true;
}
}
return false;
}
bool remove(Car car) {
if (_slots.every((element) => element != car)) {
return false;
}
for (int i = 0; i <= _slots.length; i++) {
final slot = _slots[i];
if (slot == car) {
_slots[i] = null;
notifyListeners();
return true;
}
}
return false;
}
List<Car?> get getSlots => _slots;
int get getSize => _slots.length;
int get getAvailable => _slots.where((element) => element == null).length;
bool get isFull => getAvailable == 0;
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/logic/car_generator.dart
|
import 'dart:math';
enum CarBrand {
nissan,
tesla,
toyota,
mitsubushi,
honda,
mercedes,
subaru,
proton,
perodua,
hyundai,
ford,
bmw,
lexus,
chevrolet,
dodge,
volkswagen,
kia,
jeep;
String getString() {
switch (this) {
case nissan:
return 'Nissan';
case tesla:
return 'Tesla';
case toyota:
return 'Toyota';
case mitsubushi:
return 'Mitsubushi';
case honda:
return 'Honda';
case mercedes:
return 'Mercedes';
case subaru:
return 'Subaru';
case proton:
return 'Proton';
case perodua:
return 'Perodua';
case hyundai:
return 'Hyundai';
case ford:
return 'Ford';
case bmw:
return 'BMW';
case lexus:
return 'Lexus';
case chevrolet:
return 'Chevrolet';
case dodge:
return 'Dodge';
case volkswagen:
return 'Volkswagen';
case kia:
return 'Kia';
case jeep:
return 'Jeep';
default:
throw UnimplementedError();
}
}
}
extension CarBrandExtension on CarBrand {
static CarBrand generateRandomCarBrand() {
final random = Random();
return CarBrand.values[random.nextInt(CarBrand.values.length)];
}
}
extension CarPlateExtension on CarBrand {
static String generateRandomCarPlate() {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
final random = Random();
final prefix = String.fromCharCodes(
Iterable.generate(
3,
(_) => chars.codeUnitAt(
random.nextInt(chars.length),
),
),
);
final suffix = random.nextInt(8999) + 1000;
return '$prefix-$suffix';
}
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/logic/logic.dart
|
export 'car_generator.dart';
export 'parking.dart';
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/screens/screens.dart
|
export 'game.dart';
export 'title.dart';
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/screens/title.dart
|
import 'package:flutter/material.dart';
import '../components/components.dart';
class PageTitle extends StatefulWidget {
const PageTitle({Key? key}) : super(key: key);
@override
State<PageTitle> createState() => _PageTitleState();
}
class _PageTitleState extends State<PageTitle> {
late TextEditingController _textEditingController;
@override
void initState() {
_textEditingController = TextEditingController();
super.initState();
}
@override
void dispose() {
_textEditingController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.lightBlue.shade100,
body: LayoutBuilder(
builder: (context, constraints) {
if (constraints.isNormalized) {
if (constraints.maxWidth > 600) {
return Center(
child: Row(
children: [
const TitleMain(),
TitleButton(textEditingController: _textEditingController),
],
),
);
} else {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const TitleMain(),
TitleButton(textEditingController: _textEditingController),
],
);
}
}
return const Text('Constraint not normalized');
},
),
);
}
}
| 0
|
mirrored_repositories/parking_lot_game/lib
|
mirrored_repositories/parking_lot_game/lib/screens/game.dart
|
import 'package:flutter/material.dart';
import '../components/components.dart';
class PageGame extends StatefulWidget {
const PageGame({Key? key}) : super(key: key);
@override
State<PageGame> createState() => _PageGameState();
}
class _PageGameState extends State<PageGame> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
foregroundColor: Colors.black,
),
backgroundColor: Colors.lightBlue.shade100,
body: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.isNormalized) {
if (constraints.maxWidth > 600) {
return Center(
child: Row(
children: [
Expanded(child: GameLayout(constraints: constraints)),
const Flexible(child: GameControl()),
],
),
);
} else {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(child: GameLayout(constraints: constraints)),
const GameControl(),
],
),
);
}
}
return const Text('Constraint not normalized');
},
),
);
}
}
| 0
|
mirrored_repositories/parking_lot_game
|
mirrored_repositories/parking_lot_game/test/widget_test.dart
|
void main() {}
| 0
|
mirrored_repositories/autoScrollable-list/auto_scroll
|
mirrored_repositories/autoScrollable-list/auto_scroll/lib/main.dart
|
import 'package:animate_do/animate_do.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:google_fonts/google_fonts.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
/////////////////////////////////////
//@CodeWithFlexz on Instagram
//
//AmirBayat0 on Github
//Programming with Flexz on Youtube
/////////////////////////////////////
ScrollController scrollController = ScrollController();
@override
void initState() {
Future.delayed(const Duration(seconds: 1), () {
scrollController.animateTo(scrollController.position.maxScrollExtent,
duration: Duration(seconds: asset.length * 10), curve: Curves.linear);
});
super.initState();
}
@override
void dispose() {
scrollController.dispose();
super.dispose();
}
List<String> asset = [
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
'asset/1.png',
'asset/2.png',
'asset/3.png',
'asset/4.png',
'asset/5.png',
'asset/6.jpg',
'asset/7.png',
'asset/8.png',
'asset/9.png',
'asset/10.png',
];
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Scaffold(
body: SizedBox(
width: size.width,
height: size.height,
child: Stack(
children: [
SizedBox(
width: size.width,
height: size.height,
child: StaggeredGridView.countBuilder(
controller: scrollController,
physics: const BouncingScrollPhysics(),
crossAxisCount: 4,
itemCount: asset.length,
itemBuilder: (BuildContext context, int index) {
return Image(
image: AssetImage(asset[index]),
fit: BoxFit.cover,
);
},
staggeredTileBuilder: (int index) =>
StaggeredTile.count(2, index.isEven ? 4 : 2),
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
width: size.width,
height: size.height,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.black.withOpacity(0),
Colors.black.withOpacity(0),
Colors.black.withOpacity(0),
Colors.black.withOpacity(0.9),
Colors.black.withOpacity(1),
],
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding:
EdgeInsets.symmetric(horizontal: size.width * 0.02),
child: FadeInUp(
child: Text(
"The 30 Most Stunning Movie\nPosters of 2019",
textAlign: TextAlign.center,
style: GoogleFonts.actor(
color: Colors.white,
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
),
),
SizedBox(
height: size.height * 0.025,
),
GestureDetector(
onTap: () {
Navigator.pushReplacement(
context,
CupertinoPageRoute(
builder: (ctx) => const HomePage(),
),
);
},
child: FadeInUp(
delay: const Duration(milliseconds: 500),
child: const CircleAvatar(
radius: 40,
backgroundImage: AssetImage("asset/100.jpg"),
),
),
),
FadeInUp(
delay: const Duration(milliseconds: 700),
child: Text(
"Zack Sharf",
style: GoogleFonts.actor(
color: Colors.white, fontSize: 17),
),
),
FadeInUp(
delay: const Duration(milliseconds: 900),
child: Text(
"Dec 12, 2019 11:00 am",
style: GoogleFonts.actor(
color: Colors.grey[300], fontSize: 15),
),
),
FadeInUp(
delay: const Duration(milliseconds: 1000),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.person,
color: Colors.grey,
),
Text(
"@zsharf",
style: GoogleFonts.actor(
color: Colors.grey, fontSize: 15),
),
],
),
),
SizedBox(
height: size.height * 0.03,
),
],
),
),
)
],
),
),
);
}
}
| 0
|
mirrored_repositories/BookHive
|
mirrored_repositories/BookHive/lib/my_bloc_observer.dart
|
import 'package:bloc/bloc.dart';
import 'package:flutter/material.dart';
class MyBlocObserver extends BlocObserver {
@override
void onCreate(BlocBase bloc) {
super.onCreate(bloc);
debugPrint('onCreate -- ${bloc.runtimeType}');
}
@override
void onChange(BlocBase bloc, Change change) {
super.onChange(bloc, change);
debugPrint('onChange -- ${bloc.runtimeType}, $change');
}
@override
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
debugPrint('onError -- ${bloc.runtimeType}, $error');
super.onError(bloc, error, stackTrace);
}
@override
void onClose(BlocBase bloc) {
super.onClose(bloc);
debugPrint('onClose -- ${bloc.runtimeType}');
}
}
| 0
|
mirrored_repositories/BookHive
|
mirrored_repositories/BookHive/lib/constants.dart
|
import 'package:flutter/material.dart';
const Color kPrimaryColor = Color(0xff102e44);
const Color kSeconderyColor = Color(0xff072136);
const Duration kTransitionDuration = Duration(milliseconds: 250);
const String kGTSectraFine = 'GT Sectra Fine';
const double kDefaultPadding = 24.0;
void navigateBack(context) {
Navigator.pop(context);
}
Route createRoute(Widget screen) {
return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => screen,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
final tween = Tween<double>(
begin: 0,
end: 1,
);
final opacityAnimation = tween.animate(
CurvedAnimation(
parent: animation,
curve: Curves.easeInExpo,
),
);
return FadeTransition(
opacity: opacityAnimation,
child: child,
);
},
);
}
void navigateTo({
required BuildContext context,
required Widget screen,
}) {
Navigator.of(context).push(createRoute(screen));
}
void navigateAndFinish({
required BuildContext context,
required Widget screen,
}) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => screen),
(Route<dynamic> route) => false, // remove all previous routes
);
}
| 0
|
mirrored_repositories/BookHive
|
mirrored_repositories/BookHive/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import '/constants.dart';
import '/core/utils/service_locator.dart';
import '/features/home/data/repos/home_repo_implementation.dart';
import '/features/home/presentation/manager/featured_books_cubit/featured_books_cubit.dart';
import '/features/home/presentation/manager/newest_books_cubit/newest_books_cubit.dart';
import '/features/splash/presentation/views/splash_view.dart';
import 'my_bloc_observer.dart';
void main() {
Bloc.observer = MyBlocObserver();
setupServiceLocator();
runApp(const BookHiveApp());
}
class BookHiveApp extends StatelessWidget {
const BookHiveApp({super.key});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => FeaturedBooksCubit(getIt.get<HomeRepoImpl>())
..fetchFeaturedBooks(),
),
BlocProvider(
create: (context) =>
NewestBooksCubit(getIt.get<HomeRepoImpl>())..fetchNewestBooks(),
),
],
child: MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: kPrimaryColor,
textTheme:
GoogleFonts.montserratTextTheme(ThemeData.dark().textTheme),
),
debugShowCheckedModeBanner: false,
home: const SplashView(),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/web_display/presentation
|
mirrored_repositories/BookHive/lib/features/web_display/presentation/views/web_view_screen.dart
|
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import '/constants.dart';
class WebViewScreen extends StatelessWidget {
final String url;
const WebViewScreen({super.key, required this.url});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: kPrimaryColor,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios),
onPressed: () => navigateBack(context),
),
),
body: WebView(
initialUrl: url,
// javascriptMode: JavascriptMode.unrestricted,
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/data
|
mirrored_repositories/BookHive/lib/features/home/data/repos/home_repo_implementation.dart
|
import 'package:dartz/dartz.dart';
import 'package:dio/dio.dart';
import '/core/errors/failure.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/api_service.dart';
import '/features/home/data/repos/home_repo.dart';
class HomeRepoImpl implements HomeRepo {
final ApiService apiService;
const HomeRepoImpl(this.apiService);
@override
Future<Either<Failure, List<BookModel>>> fetchNewestBooks() async {
try {
var data = await apiService.getData(
endPoint:
'volumes?Filtering=free-ebooks&Sorting=newest &q=subject: computer science',
);
List<BookModel> books = [];
for (var item in data['items']) {
books.add(BookModel.fromJson(item));
}
return right(books);
} catch (e) {
if (e is DioError) {
return left(ServerFailure.fromDioError(e));
}
return left(ServerFailure(e.toString()));
}
}
@override
Future<Either<Failure, List<BookModel>>> fetchFeaturedBooks() async {
try {
var data = await apiService.getData(
endPoint:
'volumes?Filtering=free-ebooks&q=subject: Artificial Intelligence',
);
List<BookModel> books = [];
for (var item in data['items']) {
books.add(BookModel.fromJson(item));
}
return right(books);
} catch (e) {
if (e is DioError) {
return left(ServerFailure.fromDioError(e));
}
return left(ServerFailure(e.toString()));
}
}
@override
Future<Either<Failure, List<BookModel>>> fetchSimilarBooks({
required String category,
}) async {
try {
var data = await apiService.getData(
endPoint:
'volumes?Filtering=free-ebooks&Sorting=relevance&q=subject: programming',
);
List<BookModel> books = [];
for (var item in data['items']) {
books.add(BookModel.fromJson(item));
}
return right(books);
} catch (e) {
if (e is DioError) {
return left(ServerFailure.fromDioError(e));
}
return left(ServerFailure(e.toString()));
}
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/data
|
mirrored_repositories/BookHive/lib/features/home/data/repos/home_repo.dart
|
import 'package:dartz/dartz.dart';
import '/core/errors/failure.dart';
import '/core/models/book_model/book_model.dart';
abstract class HomeRepo {
Future<Either<Failure, List<BookModel>>> fetchFeaturedBooks();
Future<Either<Failure, List<BookModel>>> fetchNewestBooks();
Future<Either<Failure, List<BookModel>>> fetchSimilarBooks({
required String category,
});
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/book_details_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/service_locator.dart';
import '/features/home/data/repos/home_repo_implementation.dart';
import '/features/home/presentation/manager/similar_books_cubit/similar_books_cubit.dart';
import '/features/home/presentation/views/widgets/book_details_view_body.dart';
class BookDetailsView extends StatelessWidget {
final BookModel book;
const BookDetailsView({super.key, required this.book});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => SimilarBooksCubit(getIt.get<HomeRepoImpl>()),
child: Scaffold(
body: SafeArea(
child: BookDetailsViewBody(book: book),
),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/home_view.dart
|
import 'package:flutter/material.dart';
import '/features/home/presentation/views/widgets/home_view_body.dart';
class HomeView extends StatelessWidget {
const HomeView({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: HomeViewBody(),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/home_view_body.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
import '/core/utils/styles.dart';
import 'custom_app_bar.dart';
import 'featured_books_list_view.dart';
import 'newest_list_view.dart';
class HomeViewBody extends StatelessWidget {
const HomeViewBody({super.key});
@override
Widget build(BuildContext context) {
return const CustomScrollView(
physics: BouncingScrollPhysics(),
slivers: <Widget>[
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
CustomAppBar(),
Padding(
padding: EdgeInsets.symmetric(horizontal: kDefaultPadding),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Featured",
style: Styles.textStyle22,
),
FeaturedBooksListView(),
SizedBox(height: 20),
Text(
"Newest",
style: Styles.textStyle22,
),
SizedBox(height: 18),
],
),
),
],
),
),
SliverToBoxAdapter(
child: NewestListView(),
),
SliverToBoxAdapter(
child: SizedBox(height: 20),
),
],
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/custom_book_details_app_bar.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
class CustomBookDetailsAppBar extends StatelessWidget {
const CustomBookDetailsAppBar({super.key});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
onPressed: () => navigateBack(context),
icon: const Icon(Icons.close),
),
IconButton(
onPressed: () {},
icon: const Icon(Icons.shopping_cart_outlined),
),
],
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/book_list_view_item.dart
|
import 'package:flutter/material.dart';
import '../book_details_view.dart';
import '/constants.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/styles.dart';
import '/features/home/presentation/views/widgets/custom_book_image.dart';
import 'book_rating.dart';
class BookListViewItem extends StatelessWidget {
final BookModel book;
const BookListViewItem({super.key, required this.book});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => navigateTo(
context: context,
screen: BookDetailsView(book: book),
),
child: SizedBox(
height: 130,
child: Row(
children: <Widget>[
CustomBookImage(
book: book,
imageUrl: book.volumeInfo.imageLinks.thumbnail,
),
const SizedBox(width: 30),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width * 0.5,
child: Text(
book.volumeInfo.title!,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Styles.textStyle20.copyWith(
fontFamily: kGTSectraFine,
),
),
),
const SizedBox(height: 3),
Text(
book.volumeInfo.authors?[0] ?? 'Unknown',
style: Styles.textStyle14,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 3),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Free",
style: Styles.textStyle20.copyWith(
fontWeight: FontWeight.bold,
),
),
BookRating(book: book),
],
),
],
),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/book_details_section.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/styles.dart';
import 'book_actions.dart';
import 'book_rating.dart';
import 'custom_book_image.dart';
import 'description_container.dart';
class BookDetailsSection extends StatelessWidget {
final BookModel book;
const BookDetailsSection({super.key, required this.book});
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(
right: screenWidth * 0.12,
left: screenWidth * 0.12,
bottom: 30,
top: kDefaultPadding / 2,
),
child: Hero(
tag: book.id!,
child: CustomBookImage(
book: book,
imageUrl: book.volumeInfo.imageLinks.thumbnail,
),
),
),
Text(
book.volumeInfo.title!,
style: Styles.textStyle30.copyWith(fontWeight: FontWeight.w600),
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
),
const SizedBox(height: 6),
Opacity(
opacity: 0.7,
child: Text(
book.volumeInfo.authors?[0] ?? 'Unknown',
style: Styles.textStyle18.copyWith(
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 14),
BookRating(
book: book,
mainAxisAlignment: MainAxisAlignment.center,
),
const SizedBox(height: 25),
if (book.volumeInfo.description != null)
DescriptionContainer(book: book),
const SizedBox(height: 25),
BookActions(book: book),
],
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/shimmer_similar_books_list_view.dart
|
import 'package:flutter/material.dart';
import 'shimmer_custom_book_image.dart';
class ShimmerSimilarBooksListView extends StatelessWidget {
const ShimmerSimilarBooksListView({super.key});
@override
Widget build(BuildContext context) {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.11,
child: ListView.separated(
padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: 10,
itemBuilder: (context, index) {
return const ShimmerCustomBookImage();
},
separatorBuilder: (context, index) {
return const SizedBox(width: 10);
},
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/book_actions.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
import '/core/models/book_model/book_model.dart';
import '/core/widgets/custom_button.dart';
import '../../../../web_display/presentation/views/web_view_screen.dart';
class BookActions extends StatelessWidget {
final BookModel book;
const BookActions({super.key, required this.book});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: <Widget>[
Expanded(
child: CustomButton(
onPressed: () {},
backgroundColor: Colors.white,
text: "Free",
textColor: Colors.black,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(16),
bottomLeft: Radius.circular(16),
),
),
),
Expanded(
child: CustomButton(
onPressed: () {
navigateTo(
context: context,
screen: WebViewScreen(
url: book.volumeInfo.previewLink!,
),
);
},
backgroundColor: const Color(0xffEF8262),
text: getText(book),
fontSize: 16,
textColor: Colors.white,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(12),
bottomRight: Radius.circular(12),
),
),
),
],
),
);
}
String getText(BookModel book) {
if (book.volumeInfo.previewLink == null) {
return "Not Available";
}
return "Preview";
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/shimmer_featured_list_view.dart
|
import 'package:flutter/material.dart';
import 'shimmer_custom_book_image.dart';
class ShimmerFeaturedListView extends StatelessWidget {
const ShimmerFeaturedListView({super.key});
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 18),
height: MediaQuery.of(context).size.height * 0.3,
child: ListView.separated(
padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: 10,
itemBuilder: (context, index) {
return const ShimmerCustomBookImage();
},
separatorBuilder: (context, index) {
return const SizedBox(width: 13);
},
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/newest_list_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '/constants.dart';
import '/features/home/presentation/manager/newest_books_cubit/newest_books_cubit.dart';
import '/features/home/presentation/manager/newest_books_cubit/newest_books_states.dart';
import 'book_list_view_item.dart';
import 'shimmer_newest_list_view.dart';
class NewestListView extends StatelessWidget {
const NewestListView({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<NewestBooksCubit, NewestBooksStates>(
builder: (context, state) {
if (state is NewestBooksSuccessState) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
child: ListView.separated(
physics: const NeverScrollableScrollPhysics(),
// Download all items at the same time
shrinkWrap: true,
padding: EdgeInsets.zero,
itemCount: state.books.length,
itemBuilder: (context, index) {
return BookListViewItem(book: state.books[index]);
},
separatorBuilder: (context, index) {
return const SizedBox(height: 10);
},
),
);
} else {
return const ShimmerNewestListView();
}
},
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/shimmer_book_list_view_item.dart
|
import 'package:flutter/material.dart';
import 'shimmer_custom_book_image.dart';
import '../../../../../core/widgets/skelton.dart';
class ShimmerBookListViewItem extends StatelessWidget {
const ShimmerBookListViewItem({super.key});
@override
Widget build(BuildContext context) {
return SizedBox(
height: 130,
child: Row(
children: <Widget>[
const ShimmerCustomBookImage(),
const SizedBox(width: 30),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Skelton(
height: 15,
width: MediaQuery.of(context).size.width * 0.5,
),
const SizedBox(height: 10),
Skelton(
height: 15,
width: MediaQuery.of(context).size.width * 0.35,
),
const SizedBox(height: 10),
Skelton(
height: 6,
width: MediaQuery.of(context).size.width * 0.2,
),
const SizedBox(height: 10),
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Skelton(
height: 10,
width: 50,
),
Skelton(
height: 10,
width: 80,
),
],
),
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/shimmer_newest_list_view.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
import 'shimmer_book_list_view_item.dart';
class ShimmerNewestListView extends StatelessWidget {
const ShimmerNewestListView({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
child: ListView.separated(
physics: const NeverScrollableScrollPhysics(),
// Download all items at the same time
shrinkWrap: true,
padding: EdgeInsets.zero,
itemCount: 10,
itemBuilder: (context, index) {
return const ShimmerBookListViewItem();
},
separatorBuilder: (context, index) {
return const SizedBox(height: 10);
},
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/similar_books_section.dart
|
import 'package:flutter/material.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/styles.dart';
import 'similar_books_list_view.dart';
class SimilarBooksSection extends StatelessWidget {
final BookModel book;
const SimilarBooksSection({super.key, required this.book});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"You can also like",
style: Styles.textStyle16.copyWith(fontWeight: FontWeight.w600),
),
const SizedBox(height: 15),
SimilarBooksListView(book: book),
],
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/book_rating.dart
|
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/styles.dart';
class BookRating extends StatelessWidget {
final MainAxisAlignment mainAxisAlignment;
final BookModel book;
const BookRating({
super.key,
this.mainAxisAlignment = MainAxisAlignment.start,
required this.book,
});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: mainAxisAlignment,
children: <Widget>[
const Icon(
FontAwesomeIcons.solidStar,
color: Color(0xffFFDD4F),
size: 16,
),
const SizedBox(width: 6.3),
Text(
"${book.volumeInfo.averageRating ?? 0}",
style: Styles.textStyle16,
),
const SizedBox(width: 3),
Opacity(
opacity: 0.5,
child: Text(
"(${book.volumeInfo.ratingsCount ?? 0})",
style: Styles.textStyle14.copyWith(
fontWeight: FontWeight.w600,
),
),
),
],
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/book_details_view_body.dart
|
import 'package:book_hive/core/models/book_model/book_model.dart';
import 'package:flutter/material.dart';
import '/constants.dart';
import 'book_details_section.dart';
import 'custom_book_details_app_bar.dart';
import 'similar_books_section.dart';
class BookDetailsViewBody extends StatelessWidget {
final BookModel book;
const BookDetailsViewBody({super.key, required this.book});
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: CustomBookDetailsAppBar(),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
child: Column(
children: <Widget>[
BookDetailsSection(book: book),
const SizedBox(height: 30),
SimilarBooksSection(book: book),
const SizedBox(height: 20),
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/description_container.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/styles.dart';
class DescriptionContainer extends StatelessWidget {
final BookModel book;
const DescriptionContainer({super.key, required this.book});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(
vertical: kDefaultPadding / 2,
horizontal: kDefaultPadding,
),
decoration: BoxDecoration(
color: kSeconderyColor,
borderRadius: BorderRadius.circular(16),
),
child: Text(
book.volumeInfo.description!,
maxLines: 5,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.justify,
style: Styles.textStyle14.copyWith(height: 1.5),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/custom_app_bar.dart
|
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '/constants.dart';
import '/core/utils/assets_data.dart';
import '/features/search/presentation/views/search_view.dart';
class CustomAppBar extends StatelessWidget {
const CustomAppBar({super.key});
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(
top: 50,
bottom: 30,
),
padding: const EdgeInsets.symmetric(horizontal: 6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Image.asset(
AssetsData.logo,
height: 43,
),
IconButton(
onPressed: () => navigateTo(
context: context,
screen: const SearchView(),
),
icon: const Icon(
FontAwesomeIcons.magnifyingGlass,
size: 22,
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/custom_book_image.dart
|
import 'package:book_hive/constants.dart';
import 'package:book_hive/features/home/presentation/views/book_details_view.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '/core/models/book_model/book_model.dart';
class CustomBookImage extends StatelessWidget {
final BookModel book;
final String imageUrl;
const CustomBookImage({
super.key,
required this.imageUrl,
required this.book,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
navigateTo(
context: context,
screen: BookDetailsView(
book: book,
),
);
},
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: AspectRatio(
aspectRatio: 1.5 / 2,
child: CachedNetworkImage(
imageUrl: imageUrl,
fit: BoxFit.fill,
errorWidget: (context, url, error) => const Icon(Icons.error),
),
),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/similar_books_list_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'shimmer_similar_books_list_view.dart';
import '/core/models/book_model/book_model.dart';
import '/features/home/presentation/manager/similar_books_cubit/similar_books_cubit.dart';
import '/features/home/presentation/manager/similar_books_cubit/similar_books_states.dart';
import 'custom_book_image.dart';
class SimilarBooksListView extends StatelessWidget {
final BookModel book;
const SimilarBooksListView({super.key, required this.book});
@override
Widget build(BuildContext context) {
return Builder(
builder: (context) {
BlocProvider.of<SimilarBooksCubit>(context).fetchSimilarBooks(
category: book.volumeInfo.categories![0],
);
return BlocBuilder<SimilarBooksCubit, SimilarBooksStates>(
builder: (context, state) {
if (state is SimilarBooksSuccessState) {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.11,
child: ListView.separated(
padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: state.books.length,
itemBuilder: (context, index) {
return CustomBookImage(
book: state.books[index],
imageUrl:
state.books[index].volumeInfo.imageLinks.thumbnail,
);
},
separatorBuilder: (context, index) {
return const SizedBox(width: 10);
},
),
);
} else {
return const ShimmerSimilarBooksListView();
}
},
);
},
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/featured_books_list_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '/features/home/presentation/manager/featured_books_cubit/featured_books_cubit.dart';
import '/features/home/presentation/manager/featured_books_cubit/featured_books_states.dart';
import 'custom_book_image.dart';
import 'shimmer_featured_list_view.dart';
class FeaturedBooksListView extends StatelessWidget {
const FeaturedBooksListView({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<FeaturedBooksCubit, FeaturedBooksStates>(
builder: (context, state) {
if (state is FeaturedBooksSuccessState) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 18),
height: MediaQuery.of(context).size.height * 0.3,
child: ListView.separated(
padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: state.books.length,
itemBuilder: (context, index) {
return Hero(
tag: state.books[index].id!,
child: CustomBookImage(
book: state.books[index],
imageUrl:
state.books[index].volumeInfo.imageLinks.thumbnail,
),
);
},
separatorBuilder: (context, index) {
return const SizedBox(width: 13);
},
),
);
} else {
return const ShimmerFeaturedListView();
}
},
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/views
|
mirrored_repositories/BookHive/lib/features/home/presentation/views/widgets/shimmer_custom_book_image.dart
|
import 'package:flutter/material.dart';
import '../../../../../core/widgets/skelton.dart';
class ShimmerCustomBookImage extends StatelessWidget {
const ShimmerCustomBookImage({
super.key,
});
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 1.5 / 2,
child: Skelton(
height: MediaQuery.of(context).size.height * 0.3,
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager/similar_books_cubit/similar_books_states.dart
|
import '/core/models/book_model/book_model.dart';
abstract class SimilarBooksStates {
const SimilarBooksStates();
}
class SimilarBooksInitialState extends SimilarBooksStates {}
class SimilarBooksLoadingState extends SimilarBooksStates {}
class SimilarBooksFailureState extends SimilarBooksStates {
final String errorMessage;
const SimilarBooksFailureState(this.errorMessage);
}
class SimilarBooksSuccessState extends SimilarBooksStates {
final List<BookModel> books;
const SimilarBooksSuccessState(this.books);
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager/similar_books_cubit/similar_books_cubit.dart
|
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../data/repos/home_repo.dart';
import '/features/home/presentation/manager/similar_books_cubit/similar_books_states.dart';
class SimilarBooksCubit extends Cubit<SimilarBooksStates> {
SimilarBooksCubit(this.homeRepo) : super(SimilarBooksInitialState());
final HomeRepo homeRepo;
void fetchSimilarBooks({required String category}) {
emit(SimilarBooksLoadingState());
homeRepo.fetchSimilarBooks(category: category).then((result) {
result.fold((failure) {
emit(SimilarBooksFailureState(failure.errorMessage));
}, (books) {
emit(SimilarBooksSuccessState(books));
});
});
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager/newest_books_cubit/newest_books_cubit.dart
|
import 'package:flutter_bloc/flutter_bloc.dart';
import '/features/home/data/repos/home_repo.dart';
import '/features/home/presentation/manager/newest_books_cubit/newest_books_states.dart';
class NewestBooksCubit extends Cubit<NewestBooksStates> {
NewestBooksCubit(this.homeRepo) : super(NewestBooksInitialState());
final HomeRepo homeRepo;
void fetchNewestBooks() {
emit(NewestBooksLoadingState());
homeRepo.fetchNewestBooks().then((result) {
result.fold((failure) {
emit(NewestBooksFailureState(failure.errorMessage));
}, (books) {
emit(NewestBooksSuccessState(books));
});
});
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager/newest_books_cubit/newest_books_states.dart
|
import '/core/models/book_model/book_model.dart';
abstract class NewestBooksStates {
const NewestBooksStates();
}
class NewestBooksInitialState extends NewestBooksStates {}
class NewestBooksLoadingState extends NewestBooksStates {}
class NewestBooksFailureState extends NewestBooksStates {
final String errorMessage;
const NewestBooksFailureState(this.errorMessage);
}
class NewestBooksSuccessState extends NewestBooksStates {
final List<BookModel> books;
const NewestBooksSuccessState(this.books);
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager/featured_books_cubit/featured_books_cubit.dart
|
import 'package:flutter_bloc/flutter_bloc.dart';
import '/features/home/data/repos/home_repo.dart';
import '/features/home/presentation/manager/featured_books_cubit/featured_books_states.dart';
class FeaturedBooksCubit extends Cubit<FeaturedBooksStates> {
FeaturedBooksCubit(this.homeRepo) : super(FeaturedBooksInitialState());
final HomeRepo homeRepo;
void fetchFeaturedBooks() {
emit(FeaturedBooksLoadingState());
homeRepo.fetchFeaturedBooks().then((result) {
result.fold(
(failure) {
emit(FeaturedBooksFailureState(failure.errorMessage));
},
(books) {
emit(FeaturedBooksSuccessState(books));
},
);
});
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager
|
mirrored_repositories/BookHive/lib/features/home/presentation/manager/featured_books_cubit/featured_books_states.dart
|
import '/core/models/book_model/book_model.dart';
abstract class FeaturedBooksStates {
const FeaturedBooksStates();
}
class FeaturedBooksInitialState extends FeaturedBooksStates {}
class FeaturedBooksLoadingState extends FeaturedBooksStates {}
class FeaturedBooksFailureState extends FeaturedBooksStates {
final String errorMessage;
const FeaturedBooksFailureState(this.errorMessage);
}
class FeaturedBooksSuccessState extends FeaturedBooksStates {
final List<BookModel> books;
const FeaturedBooksSuccessState(this.books);
}
| 0
|
mirrored_repositories/BookHive/lib/features/splash/presentation
|
mirrored_repositories/BookHive/lib/features/splash/presentation/views/splash_view.dart
|
import 'package:flutter/material.dart';
import '/features/splash/presentation/views/widgets/splash_view_body.dart';
class SplashView extends StatelessWidget {
const SplashView({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: SplashViewBody(),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/splash/presentation/views
|
mirrored_repositories/BookHive/lib/features/splash/presentation/views/widgets/splash_view_body.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../../home/presentation/views/home_view.dart';
import '/constants.dart';
import '/core/utils/assets_data.dart';
import '/core/utils/styles.dart';
class SplashViewBody extends StatefulWidget {
const SplashViewBody({super.key});
@override
State<SplashViewBody> createState() => _SplashViewBodyState();
}
class _SplashViewBodyState extends State<SplashViewBody>
with SingleTickerProviderStateMixin {
late AnimationController animationController;
late Animation<Offset> slideAnimation;
@override
void initState() {
super.initState();
setSystemUIOverlayStyle();
initFadingAnimation();
navigateToHome();
}
@override
void dispose() {
animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
AssetsData.logo,
),
AnimatedBuilder(
animation: slideAnimation,
builder: (context, _) => SlideTransition(
position: slideAnimation,
child: Container(
margin: EdgeInsets.only(
left: MediaQuery.of(context).size.width * 0.1,
),
child: Text(
"Find Free Books",
style: Styles.textStyle16.copyWith(
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.center,
),
),
),
),
],
);
}
void setSystemUIOverlayStyle() {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
systemNavigationBarColor: kPrimaryColor,
statusBarColor: kPrimaryColor,
statusBarBrightness: Brightness.light,
),
);
}
void initFadingAnimation() {
animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 2500),
);
slideAnimation = Tween<Offset>(
begin: const Offset(0, 10),
end: Offset.zero,
).animate(
CurvedAnimation(
parent: animationController,
curve: Curves.fastOutSlowIn,
),
);
animationController.forward();
}
void navigateToHome() {
Future.delayed(
const Duration(milliseconds: 3500),
() => navigateAndFinish(context: context, screen: const HomeView()),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/data
|
mirrored_repositories/BookHive/lib/features/search/data/repo/search_repo_impl.dart
|
import 'package:dartz/dartz.dart';
import 'package:dio/dio.dart';
import '/core/errors/failure.dart';
import '/core/models/book_model/book_model.dart';
import '/core/utils/api_service.dart';
import '/features/search/data/repo/search_repo.dart';
class SearchRepoImpl implements SearchRepo {
final ApiService apiService;
const SearchRepoImpl(this.apiService);
@override
Future<Either<Failure, List<BookModel>>> getSearchResult(String value) async {
try {
var data = await apiService.getData(
endPoint: 'volumes?Filtering=free-ebooks&q= $value',
);
List<BookModel> search = [];
for (var item in data['items']) {
search.add(BookModel.fromJson(item));
}
return right(search);
} catch (e) {
if (e is DioError) {
return left(ServerFailure.fromDioError(e));
}
return left(ServerFailure(e.toString()));
}
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/data
|
mirrored_repositories/BookHive/lib/features/search/data/repo/search_repo.dart
|
import 'package:dartz/dartz.dart';
import '/core/errors/failure.dart';
import '/core/models/book_model/book_model.dart';
abstract class SearchRepo {
Future<Either<Failure, List<BookModel>>> getSearchResult(String value);
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/presentation
|
mirrored_repositories/BookHive/lib/features/search/presentation/views/search_view.dart
|
import 'package:flutter/material.dart';
import 'widgets/search_view_body.dart';
class SearchView extends StatelessWidget {
const SearchView({super.key});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: const Scaffold(
body: SafeArea(
child: SearchViewBody(),
),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/presentation/views
|
mirrored_repositories/BookHive/lib/features/search/presentation/views/widgets/search_result_list_view.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../home/presentation/views/widgets/book_list_view_item.dart';
import '/core/widgets/custom_loading_indicator.dart';
import '/features/search/presentation/manager/search_cubit.dart';
import '/features/search/presentation/manager/search_states.dart';
class SearchResultListView extends StatelessWidget {
const SearchResultListView({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<SearchCubit, SearchStates>(
builder: (context, state) {
if (state is SearchSuccessState) {
return ListView.separated(
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
// Download all items at the same time
shrinkWrap: true,
itemCount: state.search.length,
itemBuilder: (context, index) {
return BookListViewItem(
book: state.search[index],
);
},
separatorBuilder: (context, index) {
return const SizedBox(height: 10);
},
);
} else if (state is SearchLoadingState) {
return const CustomLoadingIndicator();
} else {
return Container();
}
},
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/presentation/views
|
mirrored_repositories/BookHive/lib/features/search/presentation/views/widgets/search_view_body.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '/constants.dart';
import '/core/utils/service_locator.dart';
import '/core/utils/styles.dart';
import '/features/search/data/repo/search_repo_impl.dart';
import '/features/search/presentation/manager/search_cubit.dart';
import 'custom_text_field.dart';
import 'search_result_list_view.dart';
class SearchViewBody extends StatelessWidget {
const SearchViewBody({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => SearchCubit(getIt.get<SearchRepoImpl>()),
child: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: <Widget>[
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: kDefaultPadding,
vertical: kDefaultPadding / 2,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const CustomSearchTextField(),
const SizedBox(height: 16),
Text(
"Search Result",
style: Styles.textStyle20.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 16),
const SearchResultListView(),
],
),
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/presentation/views
|
mirrored_repositories/BookHive/lib/features/search/presentation/views/widgets/custom_text_field.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '/core/utils/styles.dart';
import '/features/search/presentation/manager/search_cubit.dart';
class CustomSearchTextField extends StatelessWidget {
const CustomSearchTextField({super.key});
@override
Widget build(BuildContext context) {
return TextField(
onChanged: (value) {
BlocProvider.of<SearchCubit>(context).getSearchResult(value);
},
style: Styles.textStyle18,
decoration: InputDecoration(
enabledBorder: buildOutlineInputBorder(),
focusedBorder: buildOutlineInputBorder(),
hintText: 'Search',
hintStyle: Styles.textStyle18.copyWith(
fontWeight: FontWeight.w500,
),
suffixIcon: IconButton(
onPressed: () {},
icon: const Opacity(
opacity: 0.7,
child: Icon(
FontAwesomeIcons.magnifyingGlass,
size: 22,
color: Colors.white,
),
),
),
),
);
}
OutlineInputBorder buildOutlineInputBorder() {
return OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: const BorderSide(
color: Colors.white,
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/presentation
|
mirrored_repositories/BookHive/lib/features/search/presentation/manager/search_cubit.dart
|
import 'package:flutter_bloc/flutter_bloc.dart';
import '/features/search/data/repo/search_repo.dart';
import '/features/search/presentation/manager/search_states.dart';
class SearchCubit extends Cubit<SearchStates> {
SearchCubit(this.searchRepo) : super(SearchInitialState());
final SearchRepo searchRepo;
void getSearchResult(String value) {
emit(SearchLoadingState());
searchRepo.getSearchResult(value).then(
(result) {
result.fold(
(failure) {
emit(SearchFailureState(failure.errorMessage));
},
(search) {
emit(SearchSuccessState(search));
},
);
},
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/features/search/presentation
|
mirrored_repositories/BookHive/lib/features/search/presentation/manager/search_states.dart
|
import '/core/models/book_model/book_model.dart';
abstract class SearchStates {
const SearchStates();
}
class SearchInitialState extends SearchStates {}
class SearchLoadingState extends SearchStates {}
class SearchFailureState extends SearchStates {
final String errorMessage;
const SearchFailureState(this.errorMessage);
}
class SearchSuccessState extends SearchStates {
final List<BookModel> search;
const SearchSuccessState(this.search);
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/widgets/custom_button.dart
|
import 'package:flutter/material.dart';
import '../utils/styles.dart';
class CustomButton extends StatelessWidget {
final Color backgroundColor;
final String text;
final Color textColor;
final double? fontSize;
final BorderRadius? borderRadius;
final void Function() onPressed;
const CustomButton({
super.key,
required this.onPressed,
required this.backgroundColor,
required this.text,
required this.textColor,
this.borderRadius,
this.fontSize,
});
@override
Widget build(BuildContext context) {
return SizedBox(
height: 48,
child: TextButton(
onPressed: onPressed,
style: TextButton.styleFrom(
backgroundColor: backgroundColor,
shape: RoundedRectangleBorder(
borderRadius: borderRadius ?? BorderRadius.circular(12),
),
),
child: Text(
text,
style: Styles.textStyle18.copyWith(
fontWeight: FontWeight.w900,
color: textColor,
fontSize: fontSize,
),
),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/widgets/custom_loading_indicator.dart
|
import 'package:flutter/material.dart';
class CustomLoadingIndicator extends StatelessWidget {
const CustomLoadingIndicator({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: CircularProgressIndicator(
color: Colors.white.withOpacity(0.8),
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/widgets/custom_error_widget.dart
|
import 'package:flutter/material.dart';
import '/core/utils/styles.dart';
class CustomErrorWidget extends StatelessWidget {
final String errorMessage;
const CustomErrorWidget({super.key, required this.errorMessage});
@override
Widget build(BuildContext context) {
return Center(
child: Text(
errorMessage,
style: Styles.textStyle18,
textAlign: TextAlign.center,
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/widgets/skelton.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
class Skelton extends StatefulWidget {
final double? height, width;
const Skelton({super.key, this.height, this.width});
@override
State<Skelton> createState() => _SkeltonState();
}
class _SkeltonState extends State<Skelton> with SingleTickerProviderStateMixin {
late AnimationController _animationController;
late Animation<Alignment> _beginAnimation;
@override
void initState() {
super.initState();
initAnimation();
_animationController.repeat();
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _animationController,
builder: (context, child) {
return Container(
height: widget.height,
width: widget.width,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
kSeconderyColor,
const Color.fromARGB(255, 255, 255, 255),
kSeconderyColor.withOpacity(0.6),
kSeconderyColor.withOpacity(0.4),
kSeconderyColor.withOpacity(0.2),
],
stops: const [
0.1,
0.3,
0.1,
0.1,
0.4,
],
begin: _beginAnimation.value,
end: Alignment.bottomRight,
tileMode: TileMode.clamp,
),
borderRadius: BorderRadius.circular(16),
),
);
},
);
}
void initAnimation() {
_animationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 3), // equal 31.7 years
);
_beginAnimation = TweenSequence<Alignment>(
[
TweenSequenceItem<Alignment>(
tween: Tween<Alignment>(
begin: Alignment.topLeft, end: Alignment.bottomRight),
weight: 1,
),
TweenSequenceItem<Alignment>(
tween: Tween<Alignment>(
begin: Alignment.bottomRight, end: Alignment.topLeft),
weight: 1,
),
],
).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.ease,
),
);
}
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/industry_identifier.dart
|
import 'package:equatable/equatable.dart';
class IndustryIdentifier extends Equatable {
final String? type;
final String? identifier;
const IndustryIdentifier({this.type, this.identifier});
factory IndustryIdentifier.fromJson(Map<String, dynamic> json) {
return IndustryIdentifier(
type: json['type'] as String?,
identifier: json['identifier'] as String?,
);
}
Map<String, dynamic> toJson() => {
'type': type,
'identifier': identifier,
};
@override
List<Object?> get props => [type, identifier];
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/pdf.dart
|
import 'package:equatable/equatable.dart';
class Pdf extends Equatable {
final bool? isAvailable;
final String? acsTokenLink;
const Pdf({this.isAvailable, this.acsTokenLink});
factory Pdf.fromJson(Map<String, dynamic> json) => Pdf(
isAvailable: json['isAvailable'] as bool?,
acsTokenLink: json['acsTokenLink'] as String?,
);
Map<String, dynamic> toJson() => {
'isAvailable': isAvailable,
'acsTokenLink': acsTokenLink,
};
@override
List<Object?> get props => [isAvailable, acsTokenLink];
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/epub.dart
|
import 'package:equatable/equatable.dart';
class Epub extends Equatable {
final bool? isAvailable;
const Epub({this.isAvailable});
factory Epub.fromJson(Map<String, dynamic> json) => Epub(
isAvailable: json['isAvailable'] as bool?,
);
Map<String, dynamic> toJson() => {
'isAvailable': isAvailable,
};
@override
List<Object?> get props => [isAvailable];
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/image_links.dart
|
import 'package:equatable/equatable.dart';
class ImageLinks extends Equatable {
final String smallThumbnail;
final String thumbnail;
const ImageLinks({required this.smallThumbnail, required this.thumbnail});
factory ImageLinks.fromJson(Map<String, dynamic> json) => ImageLinks(
smallThumbnail: json['smallThumbnail'] as String,
thumbnail: json['thumbnail'] as String,
);
Map<String, dynamic> toJson() => {
'smallThumbnail': smallThumbnail,
'thumbnail': thumbnail,
};
@override
List<Object?> get props => [smallThumbnail, thumbnail];
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/volume_info.dart
|
import 'package:equatable/equatable.dart';
import 'image_links.dart';
import 'industry_identifier.dart';
import 'panelization_summary.dart';
import 'reading_modes.dart';
class VolumeInfo extends Equatable {
final String? title;
final String? subtitle;
final List<String>? authors;
final String? publisher;
final String? publishedDate;
final String? description;
final List<IndustryIdentifier>? industryIdentifiers;
final ReadingModes? readingModes;
final int? pageCount;
final String? printType;
final double? averageRating;
final int? ratingsCount;
final List<String>? categories;
final String? maturityRating;
final bool? allowAnonLogging;
final String? contentVersion;
final PanelizationSummary? panelizationSummary;
final ImageLinks imageLinks;
final String? language;
final String? previewLink;
final String? infoLink;
final String? canonicalVolumeLink;
const VolumeInfo({
required this.imageLinks,
this.title,
this.ratingsCount,
this.averageRating,
this.subtitle,
this.authors,
this.publisher,
this.publishedDate,
this.description,
this.industryIdentifiers,
this.readingModes,
this.pageCount,
this.printType,
this.categories,
this.maturityRating,
this.allowAnonLogging,
this.contentVersion,
this.panelizationSummary,
this.language,
this.previewLink,
this.infoLink,
this.canonicalVolumeLink,
});
factory VolumeInfo.fromJson(Map<String, dynamic> json) => VolumeInfo(
title: json['title'] as String?,
subtitle: json['subtitle'] as String?,
authors: (json['authors'] as List<dynamic>?)?.cast<String>(),
publisher: json['publisher'] as String?,
publishedDate: json['publishedDate'] as String?,
description: json['description'] as String?,
industryIdentifiers: (json['industryIdentifiers'] as List<dynamic>?)
?.map((e) => IndustryIdentifier.fromJson(e as Map<String, dynamic>))
.toList(),
readingModes: json['readingModes'] == null
? null
: ReadingModes.fromJson(
json['readingModes'] as Map<String, dynamic>),
pageCount: json['pageCount'] as int?,
averageRating: json['averageRating'] is double
? json['averageRating']
: (json['averageRating'] as int?)?.toDouble(),
ratingsCount: json['ratingsCount'] as int?,
printType: json['printType'] as String?,
categories: (json['categories'] as List<dynamic>?)?.cast<String>(),
maturityRating: json['maturityRating'] as String?,
allowAnonLogging: json['allowAnonLogging'] as bool?,
contentVersion: json['contentVersion'] as String?,
panelizationSummary: json['panelizationSummary'] == null
? null
: PanelizationSummary.fromJson(
json['panelizationSummary'] as Map<String, dynamic>),
imageLinks:
ImageLinks.fromJson(json['imageLinks'] as Map<String, dynamic>),
language: json['language'] as String?,
previewLink: json['previewLink'] as String?,
infoLink: json['infoLink'] as String?,
canonicalVolumeLink: json['canonicalVolumeLink'] as String?,
);
Map<String, dynamic> toJson() => {
'title': title,
'subtitle': subtitle,
'authors': authors,
'publisher': publisher,
'publishedDate': publishedDate,
'description': description,
'industryIdentifiers':
industryIdentifiers?.map((e) => e.toJson()).toList(),
'readingModes': readingModes?.toJson(),
'pageCount': pageCount,
'printType': printType,
'categories': categories,
'ratingsCount': ratingsCount,
'averageRating': averageRating,
'maturityRating': maturityRating,
'allowAnonLogging': allowAnonLogging,
'contentVersion': contentVersion,
'panelizationSummary': panelizationSummary?.toJson(),
'imageLinks': imageLinks.toJson(),
'language': language,
'previewLink': previewLink,
'infoLink': infoLink,
'canonicalVolumeLink': canonicalVolumeLink,
};
@override
List<Object?> get props {
return [
title,
subtitle,
authors,
publisher,
publishedDate,
description,
industryIdentifiers,
readingModes,
pageCount,
printType,
categories,
maturityRating,
allowAnonLogging,
contentVersion,
panelizationSummary,
averageRating,
ratingsCount,
imageLinks,
language,
previewLink,
infoLink,
canonicalVolumeLink,
];
}
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/book_model.dart
|
import 'package:equatable/equatable.dart';
import 'access_info.dart';
import 'sale_info.dart';
import 'search_info.dart';
import 'volume_info.dart';
class BookModel extends Equatable {
final String? kind;
final String? id;
final String? etag;
final String? selfLink;
final VolumeInfo volumeInfo;
final SaleInfo? saleInfo;
final AccessInfo? accessInfo;
final SearchInfo? searchInfo;
const BookModel({
required this.volumeInfo,
this.kind,
this.id,
this.etag,
this.selfLink,
this.saleInfo,
this.accessInfo,
this.searchInfo,
});
factory BookModel.fromJson(Map<String, dynamic> json) => BookModel(
kind: json['kind'] as String?,
id: json['id'] as String?,
etag: json['etag'] as String?,
selfLink: json['selfLink'] as String?,
volumeInfo:
VolumeInfo.fromJson(json['volumeInfo'] as Map<String, dynamic>),
saleInfo: json['saleInfo'] == null
? null
: SaleInfo.fromJson(json['saleInfo'] as Map<String, dynamic>),
accessInfo: json['accessInfo'] == null
? null
: AccessInfo.fromJson(json['accessInfo'] as Map<String, dynamic>),
searchInfo: json['searchInfo'] == null
? null
: SearchInfo.fromJson(json['searchInfo'] as Map<String, dynamic>),
);
Map<String, dynamic> toJson() => {
'kind': kind,
'id': id,
'etag': etag,
'selfLink': selfLink,
'volumeInfo': volumeInfo.toJson(),
'saleInfo': saleInfo?.toJson(),
'accessInfo': accessInfo?.toJson(),
'searchInfo': searchInfo?.toJson(),
};
@override
List<Object?> get props {
return [
kind,
id,
etag,
selfLink,
volumeInfo,
saleInfo,
accessInfo,
searchInfo,
];
}
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/reading_modes.dart
|
import 'package:equatable/equatable.dart';
class ReadingModes extends Equatable {
final bool? text;
final bool? image;
const ReadingModes({this.text, this.image});
factory ReadingModes.fromJson(Map<String, dynamic> json) => ReadingModes(
text: json['text'] as bool?,
image: json['image'] as bool?,
);
Map<String, dynamic> toJson() => {
'text': text,
'image': image,
};
@override
List<Object?> get props => [text, image];
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/panelization_summary.dart
|
import 'package:equatable/equatable.dart';
class PanelizationSummary extends Equatable {
final bool? containsEpubBubbles;
final bool? containsImageBubbles;
const PanelizationSummary({
this.containsEpubBubbles,
this.containsImageBubbles,
});
factory PanelizationSummary.fromJson(Map<String, dynamic> json) {
return PanelizationSummary(
containsEpubBubbles: json['containsEpubBubbles'] as bool?,
containsImageBubbles: json['containsImageBubbles'] as bool?,
);
}
Map<String, dynamic> toJson() => {
'containsEpubBubbles': containsEpubBubbles,
'containsImageBubbles': containsImageBubbles,
};
@override
List<Object?> get props => [containsEpubBubbles, containsImageBubbles];
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/sale_info.dart
|
import 'package:equatable/equatable.dart';
class SaleInfo extends Equatable {
final String? country;
final String? saleability;
final bool? isEbook;
const SaleInfo({this.country, this.saleability, this.isEbook});
factory SaleInfo.fromJson(Map<String, dynamic> json) => SaleInfo(
country: json['country'] as String?,
saleability: json['saleability'] as String?,
isEbook: json['isEbook'] as bool?,
);
Map<String, dynamic> toJson() => {
'country': country,
'saleability': saleability,
'isEbook': isEbook,
};
@override
List<Object?> get props => [country, saleability, isEbook];
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/access_info.dart
|
import 'package:equatable/equatable.dart';
import 'epub.dart';
import 'pdf.dart';
class AccessInfo extends Equatable {
final String? country;
final String? viewability;
final bool? embeddable;
final bool? publicDomain;
final String? textToSpeechPermission;
final Epub? epub;
final Pdf? pdf;
final String? webReaderLink;
final String? accessViewStatus;
final bool? quoteSharingAllowed;
const AccessInfo({
this.country,
this.viewability,
this.embeddable,
this.publicDomain,
this.textToSpeechPermission,
this.epub,
this.pdf,
this.webReaderLink,
this.accessViewStatus,
this.quoteSharingAllowed,
});
factory AccessInfo.fromJson(Map<String, dynamic> json) => AccessInfo(
country: json['country'] as String?,
viewability: json['viewability'] as String?,
embeddable: json['embeddable'] as bool?,
publicDomain: json['publicDomain'] as bool?,
textToSpeechPermission: json['textToSpeechPermission'] as String?,
epub: json['epub'] == null
? null
: Epub.fromJson(json['epub'] as Map<String, dynamic>),
pdf: json['pdf'] == null
? null
: Pdf.fromJson(json['pdf'] as Map<String, dynamic>),
webReaderLink: json['webReaderLink'] as String?,
accessViewStatus: json['accessViewStatus'] as String?,
quoteSharingAllowed: json['quoteSharingAllowed'] as bool?,
);
Map<String, dynamic> toJson() => {
'country': country,
'viewability': viewability,
'embeddable': embeddable,
'publicDomain': publicDomain,
'textToSpeechPermission': textToSpeechPermission,
'epub': epub?.toJson(),
'pdf': pdf?.toJson(),
'webReaderLink': webReaderLink,
'accessViewStatus': accessViewStatus,
'quoteSharingAllowed': quoteSharingAllowed,
};
@override
List<Object?> get props {
return [
country,
viewability,
embeddable,
publicDomain,
textToSpeechPermission,
epub,
pdf,
webReaderLink,
accessViewStatus,
quoteSharingAllowed,
];
}
}
| 0
|
mirrored_repositories/BookHive/lib/core/models
|
mirrored_repositories/BookHive/lib/core/models/book_model/search_info.dart
|
import 'package:equatable/equatable.dart';
class SearchInfo extends Equatable {
final String? textSnippet;
const SearchInfo({this.textSnippet});
factory SearchInfo.fromJson(Map<String, dynamic> json) => SearchInfo(
textSnippet: json['textSnippet'] as String?,
);
Map<String, dynamic> toJson() => {
'textSnippet': textSnippet,
};
@override
List<Object?> get props => [textSnippet];
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/errors/failure.dart
|
import 'package:dio/dio.dart';
abstract class Failure {
final String errorMessage;
const Failure(this.errorMessage);
}
class ServerFailure extends Failure {
ServerFailure(super.errorMessage);
factory ServerFailure.fromDioError(DioError dioError) {
switch (dioError.type) {
case DioErrorType.connectionTimeout:
return ServerFailure('Connection Timeout With ApiServer');
case DioErrorType.sendTimeout:
return ServerFailure('Send Timeout With ApiServer');
case DioErrorType.receiveTimeout:
return ServerFailure('Receive Timeout With ApiServer');
case DioErrorType.badCertificate:
return ServerFailure('Your request not found, please try again later!');
case DioErrorType.badResponse:
return ServerFailure.fromResponse(
dioError.response!.statusCode!,
dioError.response!.data,
);
case DioErrorType.cancel:
return ServerFailure('Request to ApiServer was canceled');
case DioErrorType.connectionError:
return ServerFailure('No Internet Connection');
case DioErrorType.unknown:
return ServerFailure(
"Unexpected Error, please try again!",
);
default:
return ServerFailure(
"Opps something went wrong, please try again later!",
);
}
}
factory ServerFailure.fromResponse(int statusCode, dynamic response) {
if (statusCode == 400 || statusCode == 401 || statusCode == 403) {
return ServerFailure(response['error']['message']);
}
return ServerFailure("Opps something went wrong, please try again later!");
}
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/utils/assets_data.dart
|
class AssetsData {
static const String logo = 'assets/images/logo.png';
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/utils/styles.dart
|
import 'package:flutter/material.dart';
import '/constants.dart';
abstract class Styles {
static const textStyle22 = TextStyle(
fontSize: 22,
fontWeight: FontWeight.w600,
letterSpacing: 0.5,
);
static const textStyle18 = TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
letterSpacing: 0.5,
);
static const textStyle20 = TextStyle(
fontSize: 20,
fontWeight: FontWeight.normal,
letterSpacing: 0.5,
);
static const textStyle30 = TextStyle(
fontSize: 30,
fontWeight: FontWeight.normal,
letterSpacing: 0.5,
fontFamily: kGTSectraFine,
);
static const textStyle14 = TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
letterSpacing: 0.5,
);
static const textStyle16 = TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
letterSpacing: 0.5,
);
}
| 0
|
mirrored_repositories/BookHive/lib/core
|
mirrored_repositories/BookHive/lib/core/utils/api_service.dart
|
import 'package:dio/dio.dart';
class ApiService {
final String _baseUrl = 'https://www.googleapis.com/books/v1/';
final Dio _dio;
const ApiService(this._dio);
Future<Map<String, dynamic>> getData(
{required String endPoint, Map<String, dynamic>? queries}) async {
var response = await _dio.get(
"$_baseUrl$endPoint",
queryParameters: queries,
);
return response.data;
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.