Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
second_display
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
second_display
Commits
cfeb0e2f
Commit
cfeb0e2f
authored
Mar 15, 2022
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
second display
parent
3cc51675
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
131 additions
and
68 deletions
+131
-68
api.dart
lib/api/api.dart
+33
-14
order_detail.dart
lib/bloc/order_detail.dart
+18
-0
orders_bloc.dart
lib/bloc/orders_bloc.dart
+2
-1
config.dart
lib/helper/config.dart
+2
-0
main.dart
lib/main.dart
+6
-2
order_detail.dart
lib/models/order_detail.dart
+10
-11
orders.dart
lib/models/orders.dart
+3
-1
carousel.dart
lib/ui/carousel.dart
+7
-10
main_page.dart
lib/ui/main_page.dart
+4
-1
orders.dart
lib/ui/orders.dart
+46
-28
No files found.
lib/api/api.dart
View file @
cfeb0e2f
import
'dart:convert'
;
import
'dart:convert'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/models/order_detail.dart'
;
import
'package:second_display/models/orders.dart'
;
import
'package:second_display/models/orders.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:http/http.dart'
as
http
;
...
@@ -12,42 +13,33 @@ class Api {
...
@@ -12,42 +13,33 @@ class Api {
total:
"0.0"
,
total:
"0.0"
,
discount_amount:
"0.0"
,
discount_amount:
"0.0"
,
orderCount:
0
,
orderCount:
0
,
subtotal:
"0.0"
);
subtotal:
"0.0"
,
tax:
"0"
);
try
{
try
{
Map
data
=
{
Map
data
=
{
"session_key"
:
"d289c7d6dfc04690b4149b93c91aef8a"
,
"session_key"
:
"d289c7d6dfc04690b4149b93c91aef8a"
,
"user_id"
:
"d31d7ad3ba864ea39300cb99c9e2ac3f"
,
"user_id"
:
"d31d7ad3ba864ea39300cb99c9e2ac3f"
,
"ignore_lock"
:
""
,
"ignore_lock"
:
""
,
"order_id"
:
"
8181320f33704081bf88333e57c5031c
"
"order_id"
:
"
a13004c9ba18459586212b7155d7348e
"
};
};
var
bodi
=
jsonEncode
(
data
);
var
bodi
=
jsonEncode
(
data
);
var
apiresults
=
await
http
.
post
(
Uri
.
parse
(
apiUrl
),
body:
bodi
);
var
apiresults
=
await
http
.
post
(
Uri
.
parse
(
apiUrl
),
body:
bodi
);
var
jsonObject
=
jsonDecode
(
apiresults
.
body
);
var
jsonObject
=
jsonDecode
(
apiresults
.
body
);
List
<
dynamic
>
orderDetailCount
=
(
jsonObject
List
<
dynamic
>
orderDetailCount
=
(
jsonObject
as
Map
<
dynamic
,
dynamic
>)[
'data'
][
'order'
][
'order_detail'
];
as
Map
<
dynamic
,
dynamic
>)[
'data'
][
'order'
][
'order_detail'
];
// List<dynamic> listCustomerOrder =
// (jsonObject as Map<dynamic, dynamic>)['data']['order'];
// for (int i = 0; i < listCustomerOrder.length; i++) {
// customerOrdersList
// .add(CustomerOrders.createCustomerOrder(listCustomerOrder[i]));
// }
var
jsonMap
=
jsonObject
[
'data'
][
'order'
];
var
jsonMap
=
jsonObject
[
'data'
][
'order'
];
String
orderuserName
=
jsonMap
[
'order_user_name'
];
String
orderuserName
=
jsonMap
[
'order_user_name'
];
String
total
=
jsonMap
[
'total'
];
String
total
=
jsonMap
[
'total'
];
String
discountAmount
=
jsonMap
[
'discount_amount'
];
String
discountAmount
=
jsonMap
[
'discount_amount'
];
int
orderCounts
=
orderDetailCount
.
length
;
int
orderCounts
=
orderDetailCount
.
length
;
String
subtotal
=
jsonMap
[
'subtotal'
];
String
subtotal
=
jsonMap
[
'subtotal'
];
String
tax
=
jsonMap
[
'tax_amount'
];
// CustomerOrders(
// order_user_name: orderuserName,
// total: total,
// discount_amount: discountAmount,
// subtotal: subtotal);
customerOrdersList
.
order_user_name
=
orderuserName
;
customerOrdersList
.
order_user_name
=
orderuserName
;
customerOrdersList
.
total
=
total
;
customerOrdersList
.
total
=
total
;
customerOrdersList
.
discount_amount
=
discountAmount
;
customerOrdersList
.
discount_amount
=
discountAmount
;
customerOrdersList
.
orderCount
=
orderCounts
;
customerOrdersList
.
orderCount
=
orderCounts
;
customerOrdersList
.
subtotal
=
subtotal
;
customerOrdersList
.
subtotal
=
subtotal
;
customerOrdersList
.
tax
=
tax
;
return
customerOrdersList
;
return
customerOrdersList
;
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -55,4 +47,31 @@ class Api {
...
@@ -55,4 +47,31 @@ class Api {
return
customerOrdersList
;
return
customerOrdersList
;
}
}
}
}
static
Future
<
List
<
CustomerOrdersDetail
>>
getOrderDetail
()
async
{
String
apiUrl
=
getOrdersUrl
;
try
{
List
<
CustomerOrdersDetail
>
listOrderDetail
=
[];
Map
data
=
{
"session_key"
:
"d289c7d6dfc04690b4149b93c91aef8a"
,
"user_id"
:
"d31d7ad3ba864ea39300cb99c9e2ac3f"
,
"ignore_lock"
:
""
,
"order_id"
:
"a13004c9ba18459586212b7155d7348e"
};
var
bodi
=
jsonEncode
(
data
);
var
apiresults
=
await
http
.
post
(
Uri
.
parse
(
apiUrl
),
body:
bodi
);
var
jsonObject
=
jsonDecode
(
apiresults
.
body
);
List
<
dynamic
>
listDetail
=
(
jsonObject
as
Map
<
dynamic
,
dynamic
>)[
'data'
]
[
'order'
][
'order_detail'
];
for
(
int
i
=
0
;
i
<
listDetail
.
length
;
i
++)
{
listOrderDetail
.
add
(
CustomerOrdersDetail
.
createOrderDetail
(
listDetail
[
i
]));
}
return
listOrderDetail
;
}
catch
(
e
)
{
print
(
e
);
return
[];
}
}
}
}
lib/bloc/order_detail.dart
0 → 100644
View file @
cfeb0e2f
import
'package:second_display/api/api.dart'
;
import
'package:second_display/models/order_detail.dart'
;
import
'package:bloc/bloc.dart'
;
class
OrderDetailBloc
extends
Cubit
<
List
<
CustomerOrdersDetail
>>
{
OrderDetailBloc
()
:
super
([]);
Future
<
List
<
CustomerOrdersDetail
>>
getData
()
async
{
var
orderDetail
=
await
Api
.
getOrderDetail
();
return
orderDetail
;
}
void
getOrderDetailList
()
{
getData
().
then
((
value
)
{
emit
(
value
);
});
}
}
lib/bloc/orders_bloc.dart
View file @
cfeb0e2f
...
@@ -9,7 +9,8 @@ class OrdersBloc extends Cubit<CustomerOrders> {
...
@@ -9,7 +9,8 @@ class OrdersBloc extends Cubit<CustomerOrders> {
total:
""
,
total:
""
,
discount_amount:
""
,
discount_amount:
""
,
orderCount:
0
,
orderCount:
0
,
subtotal:
""
));
subtotal:
""
,
tax:
"0"
));
Future
<
CustomerOrders
>
getData
()
async
{
Future
<
CustomerOrders
>
getData
()
async
{
return
await
Api
.
getOrders
();
return
await
Api
.
getOrders
();
...
...
lib/helper/config.dart
View file @
cfeb0e2f
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
final
Color
textColor
=
Colors
.
white
;
final
Color
textColor
=
Colors
.
white
;
final
Color
colorBackgroundOrder
=
Colors
.
black
.
withOpacity
(
0.8
);
final
Color
colorBackgroundCarousel
=
Colors
.
black
;
final
String
getOrdersUrl
=
"http://192.168.2.142:8001/midware/order/get_by_id"
;
final
String
getOrdersUrl
=
"http://192.168.2.142:8001/midware/order/get_by_id"
;
final
List
<
String
>
imgList
=
[
final
List
<
String
>
imgList
=
[
...
...
lib/main.dart
View file @
cfeb0e2f
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:second_display/bloc/order_detail.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/ui/main_page.dart'
;
import
'package:second_display/ui/main_page.dart'
;
import
'package:url_strategy/url_strategy.dart'
;
import
'package:url_strategy/url_strategy.dart'
;
...
@@ -16,8 +17,11 @@ class MyApp extends StatelessWidget {
...
@@ -16,8 +17,11 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
// This widget is the root of your application.
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
BlocProvider
(
return
MultiBlocProvider
(
create:
(
_
)
=>
OrdersBloc
(),
providers:
[
BlocProvider
(
create:
(
_
)
=>
OrdersBloc
()),
BlocProvider
(
create:
(
_
)
=>
OrderDetailBloc
()),
],
child:
MaterialApp
(
child:
MaterialApp
(
debugShowCheckedModeBanner:
false
,
debugShowCheckedModeBanner:
false
,
initialRoute:
'/'
,
initialRoute:
'/'
,
...
...
lib/models/order_detail.dart
View file @
cfeb0e2f
class
CustomerOrders
{
class
CustomerOrders
Detail
{
late
String
order_user_
name
;
late
String
name
;
late
String
total
;
late
String
total
;
late
String
discount_amount
;
// final List<dynamic> list_order_detail;
late
String
subtotal
;
CustomerOrders
(
CustomerOrdersDetail
({
required
this
.
name
,
required
this
.
total
});
{
required
this
.
order_user_name
,
required
this
.
total
,
factory
CustomerOrdersDetail
.
createOrderDetail
(
Map
<
String
,
dynamic
>
json
)
{
required
this
.
discount_amount
,
return
CustomerOrdersDetail
(
// required this.list_order_detail,
name:
json
[
'name'
].
toString
(),
required
this
.
subtotal
});
total:
json
[
'subtotal'
].
toString
(),
);
}
}
}
lib/models/orders.dart
View file @
cfeb0e2f
...
@@ -4,11 +4,13 @@ class CustomerOrders {
...
@@ -4,11 +4,13 @@ class CustomerOrders {
late
String
discount_amount
;
late
String
discount_amount
;
late
int
orderCount
;
late
int
orderCount
;
late
String
subtotal
;
late
String
subtotal
;
late
String
tax
;
CustomerOrders
(
CustomerOrders
(
{
required
this
.
order_user_name
,
{
required
this
.
order_user_name
,
required
this
.
total
,
required
this
.
total
,
required
this
.
discount_amount
,
required
this
.
discount_amount
,
required
this
.
orderCount
,
required
this
.
orderCount
,
required
this
.
subtotal
});
required
this
.
subtotal
,
required
this
.
tax
});
}
}
lib/ui/carousel.dart
View file @
cfeb0e2f
...
@@ -58,7 +58,7 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
...
@@ -58,7 +58,7 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
body:
Container
(
body:
Container
(
color:
Colors
.
black
,
color:
colorBackgroundCarousel
,
child:
Column
(
children:
[
child:
Column
(
children:
[
Expanded
(
Expanded
(
child:
CarouselSlider
(
child:
CarouselSlider
(
...
@@ -68,7 +68,6 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
...
@@ -68,7 +68,6 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
autoPlay:
true
,
autoPlay:
true
,
autoPlayInterval:
const
Duration
(
seconds:
5
),
autoPlayInterval:
const
Duration
(
seconds:
5
),
enlargeCenterPage:
true
,
enlargeCenterPage:
true
,
aspectRatio:
2.0
,
onPageChanged:
(
index
,
reason
)
{
onPageChanged:
(
index
,
reason
)
{
setState
(()
{
setState
(()
{
_current
=
index
;
_current
=
index
;
...
@@ -82,16 +81,14 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
...
@@ -82,16 +81,14 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
return
GestureDetector
(
return
GestureDetector
(
onTap:
()
=>
_controller
.
animateToPage
(
entry
.
key
),
onTap:
()
=>
_controller
.
animateToPage
(
entry
.
key
),
child:
Container
(
child:
Container
(
width:
12.0
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.012
,
height:
12.0
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.012
,
margin:
margin:
EdgeInsets
.
symmetric
(
EdgeInsets
.
symmetric
(
vertical:
8.0
,
horizontal:
4.0
),
vertical:
MediaQuery
.
of
(
context
).
size
.
height
*
0.008
,
horizontal:
MediaQuery
.
of
(
context
).
size
.
width
*
0.0004
,
),
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
shape:
BoxShape
.
circle
,
shape:
BoxShape
.
circle
,
// color: (Theme.of(context).brightness == Brightness.dark
// ? Colors.white
// : Colors.black)
// .withOpacity(_current == entry.key ? 0.9 : 0.4)),
color:
Colors
.
white
color:
Colors
.
white
.
withOpacity
(
_current
==
entry
.
key
?
0.8
:
0.4
))),
.
withOpacity
(
_current
==
entry
.
key
?
0.8
:
0.4
))),
);
);
...
...
lib/ui/main_page.dart
View file @
cfeb0e2f
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:second_display/bloc/order_detail.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/ui/carousel.dart'
;
import
'package:second_display/ui/carousel.dart'
;
import
'package:second_display/ui/orders.dart'
;
import
'package:second_display/ui/orders.dart'
;
...
@@ -10,6 +12,7 @@ class MainPage extends StatelessWidget {
...
@@ -10,6 +12,7 @@ class MainPage extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
context
.
read
<
OrdersBloc
>().
getOrderList
();
context
.
read
<
OrdersBloc
>().
getOrderList
();
context
.
read
<
OrderDetailBloc
>().
getOrderDetailList
();
return
MaterialApp
(
return
MaterialApp
(
debugShowCheckedModeBanner:
false
,
debugShowCheckedModeBanner:
false
,
home:
Scaffold
(
home:
Scaffold
(
...
@@ -24,7 +27,7 @@ class MainPage extends StatelessWidget {
...
@@ -24,7 +27,7 @@ class MainPage extends StatelessWidget {
Container
(
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
,
height:
MediaQuery
.
of
(
context
).
size
.
height
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.4
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.4
,
color:
Colors
.
black
.
withOpacity
(
0.8
)
,
color:
colorBackgroundOrder
,
child:
OrderPage
(),
child:
OrderPage
(),
)
)
],
],
...
...
lib/ui/orders.dart
View file @
cfeb0e2f
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:second_display/
api/api
.dart'
;
import
'package:second_display/
bloc/order_detail
.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/models/order_detail.dart'
;
import
'package:second_display/models/orders.dart'
;
import
'package:second_display/models/orders.dart'
;
import
'package:intl/intl.dart'
;
import
'package:intl/intl.dart'
;
...
@@ -16,9 +17,11 @@ class OrderPage extends StatelessWidget {
...
@@ -16,9 +17,11 @@ class OrderPage extends StatelessWidget {
var
totalAmount
=
double
.
tryParse
(
list
.
total
)
??
0
;
var
totalAmount
=
double
.
tryParse
(
list
.
total
)
??
0
;
var
discountAmount
=
double
.
tryParse
(
list
.
discount_amount
)
??
0
;
var
discountAmount
=
double
.
tryParse
(
list
.
discount_amount
)
??
0
;
var
subTotalAmount
=
double
.
tryParse
(
list
.
subtotal
)
??
0
;
var
subTotalAmount
=
double
.
tryParse
(
list
.
subtotal
)
??
0
;
var
taxAmount
=
double
.
tryParse
(
list
.
tax
)
??
0
;
var
totalAmountText
=
formatCurrency
().
format
(
totalAmount
);
var
totalAmountText
=
formatCurrency
().
format
(
totalAmount
);
var
discountAmountText
=
formatCurrency
().
format
(
discountAmount
);
var
discountAmountText
=
formatCurrency
().
format
(
discountAmount
);
var
subTotalAmountText
=
formatCurrency
().
format
(
subTotalAmount
);
var
subTotalAmountText
=
formatCurrency
().
format
(
subTotalAmount
);
var
taxAmountText
=
formatCurrency
().
format
(
taxAmount
);
return
Container
(
return
Container
(
// color: Colors.black.withOpacity(0.8),
// color: Colors.black.withOpacity(0.8),
margin:
EdgeInsets
.
fromLTRB
(
margin:
EdgeInsets
.
fromLTRB
(
...
@@ -46,9 +49,15 @@ class OrderPage extends StatelessWidget {
...
@@ -46,9 +49,15 @@ class OrderPage extends StatelessWidget {
Container
(
Container
(
// color: Colors.blue,
// color: Colors.blue,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.5
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.5
,
child:
ListView
.
builder
(
child:
BlocBuilder
<
OrderDetailBloc
,
List
<
CustomerOrdersDetail
>>(
itemCount:
list
.
orderCount
,
builder:
(
context
,
detailOrder
)
{
return
ListView
.
builder
(
itemCount:
detailOrder
.
length
,
itemBuilder:
(
context
,
i
)
{
itemBuilder:
(
context
,
i
)
{
var
amountEachOrder
=
double
.
tryParse
(
detailOrder
[
i
].
total
)
??
0
;
var
amountEachOrderText
=
formatCurrency
().
format
(
amountEachOrder
);
return
Row
(
return
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
...
@@ -58,14 +67,17 @@ class OrderPage extends StatelessWidget {
...
@@ -58,14 +67,17 @@ class OrderPage extends StatelessWidget {
margin:
EdgeInsets
.
only
(
margin:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.005
,
0.005
,
bottom:
MediaQuery
.
of
(
context
).
size
.
height
*
bottom:
MediaQuery
.
of
(
context
).
size
.
height
*
0.005
),
0.005
),
child:
Row
(
child:
Row
(
children:
[
children:
[
listOforder
(
context
,
Alignment
.
centerLeft
,
listOforder
(
context
,
Alignment
.
centerLeft
,
"1 Kopi Pandan"
),
"1 "
+
detailOrder
[
i
].
name
),
listOforder
(
context
,
Alignment
.
centerRight
,
listOforder
(
"Rp 30.000"
)
context
,
Alignment
.
centerRight
,
amountEachOrderText
)
],
],
),
),
)
)
...
@@ -74,6 +86,8 @@ class OrderPage extends StatelessWidget {
...
@@ -74,6 +86,8 @@ class OrderPage extends StatelessWidget {
],
],
);
);
},
},
);
},
),
),
),
),
Expanded
(
Expanded
(
...
@@ -96,14 +110,18 @@ class OrderPage extends StatelessWidget {
...
@@ -96,14 +110,18 @@ class OrderPage extends StatelessWidget {
style:
TextStyle
(
style:
TextStyle
(
color:
textColor
,
color:
textColor
,
fontSize:
fontSize:
MediaQuery
.
of
(
context
).
size
.
height
*
0.0
5
),
MediaQuery
.
of
(
context
).
size
.
height
*
0.0
46
),
),
),
SizedBox
(
SizedBox
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.01
),
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.005
),
listTotalRincian
(
context
,
list
.
orderCount
.
toString
()
+
" Item"
,
subTotalAmountText
+
",-"
),
listTotalRincian
(
listTotalRincian
(
context
,
"
5 Items"
,
subTotal
AmountText
+
",-"
),
context
,
"
Diskon"
,
discount
AmountText
+
",-"
),
listTotalRincian
(
listTotalRincian
(
context
,
"
Discount"
,
discount
AmountText
+
",-"
),
context
,
"
Pajak"
,
tax
AmountText
+
",-"
),
SizedBox
(
SizedBox
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.02
),
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.02
),
listTotalRincian
(
listTotalRincian
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment