Commit 3b58ecc8 authored by valdi's avatar valdi

rebuild ok, problem di multi select

parent 3ea85076
import 'package:bloc/bloc.dart';
import 'package:flutter/widgets.dart';
import 'package:manager_queue/models/queue.dart';
class SelectedQueueBloc extends Cubit<List<OrderQueue>> {
SelectedQueueBloc() : super([]);
onPressed(OrderQueue thisQueue) {
if (state.contains(thisQueue)) {
state.remove(thisQueue);
} else {
state.add(thisQueue);
}
print("from bloc");
print(state);
emit(state);
}
}
...@@ -4,6 +4,8 @@ import 'package:manager_queue/bloc/queue_bloc.dart'; ...@@ -4,6 +4,8 @@ import 'package:manager_queue/bloc/queue_bloc.dart';
import 'package:manager_queue/bloc/ready_bloc.dart'; import 'package:manager_queue/bloc/ready_bloc.dart';
import 'package:manager_queue/main_page.dart'; import 'package:manager_queue/main_page.dart';
import 'bloc/selected_queue_bloc.dart';
void main() { void main() {
runApp(MyApp()); runApp(MyApp());
} }
...@@ -17,6 +19,7 @@ class MyApp extends StatelessWidget { ...@@ -17,6 +19,7 @@ class MyApp extends StatelessWidget {
'/': (context) => MultiBlocProvider(providers: [ '/': (context) => MultiBlocProvider(providers: [
BlocProvider(create: (_) => QueueBloc()), BlocProvider(create: (_) => QueueBloc()),
BlocProvider(create: (_) => ReadyBloc()), BlocProvider(create: (_) => ReadyBloc()),
BlocProvider(create: (_) => SelectedQueueBloc()),
], child: MainPage()), ], child: MainPage()),
}, },
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
......
...@@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; ...@@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:manager_queue/api.dart'; import 'package:manager_queue/api.dart';
import 'package:manager_queue/bloc/queue_bloc.dart'; import 'package:manager_queue/bloc/queue_bloc.dart';
import 'package:manager_queue/bloc/ready_bloc.dart'; import 'package:manager_queue/bloc/ready_bloc.dart';
import 'package:manager_queue/bloc/selected_queue_bloc.dart';
import 'package:manager_queue/models/queue.dart'; import 'package:manager_queue/models/queue.dart';
class MainPage extends StatefulWidget { class MainPage extends StatefulWidget {
...@@ -22,14 +23,14 @@ class _MainPageState extends State<MainPage> { ...@@ -22,14 +23,14 @@ class _MainPageState extends State<MainPage> {
List<OrderQueue> pickUp = []; List<OrderQueue> pickUp = [];
// List<dynamic> orderQueueList = []; // List<dynamic> orderQueueList = [];
@override // @override
void initState() { // void initState() {
// orderQueueList = orderQueue.where((i) => (i.status == 'In Queue')).toList(); // // orderQueueList = orderQueue.where((i) => (i.status == 'In Queue')).toList();
// orderReady = orderQueue.where((i) => (i.status == 'Ready')).toList(); // // orderReady = orderQueue.where((i) => (i.status == 'Ready')).toList();
// TODO: implement initState // // TODO: implement initState
super.initState(); // super.initState();
} // }
void setToReady(List<OrderQueue> queueSelected) { void setToReady(List<OrderQueue> queueSelected) {
for (var i in queueSelected) { for (var i in queueSelected) {
...@@ -66,6 +67,7 @@ class _MainPageState extends State<MainPage> { ...@@ -66,6 +67,7 @@ class _MainPageState extends State<MainPage> {
print("Rebuild"); print("Rebuild");
return MaterialApp( return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold( home: Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Row( body: Row(
...@@ -114,33 +116,40 @@ class _MainPageState extends State<MainPage> { ...@@ -114,33 +116,40 @@ class _MainPageState extends State<MainPage> {
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
setState(() { context
if (queueSelected.contains(thisQueue)) { .read<SelectedQueueBloc>()
queueSelected.remove(thisQueue); .onPressed(thisQueue);
} else { // print(context
queueSelected.add(thisQueue); // .read<SelectedQueueBloc>()
} // .state
// .contains(thisQueue)
print(queueSelected.toString()); // ? 'ADA LOH'
}); // : 'GAK ADA LOH');
}, },
child: Card( child: Card(
color: Colors.black38, color: Colors.black38,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
child: GestureDetector(
onTap: () {},
child: Center( child: Center(
child: Text( child: BlocBuilder<SelectedQueueBloc,
queueSelected.contains(thisQueue) List<OrderQueue>>(
builder: (context, list) {
print("--");
print(list);
return Text(
context
.read<SelectedQueueBloc>()
.state
.contains(thisQueue)
? "Pesanan " + ? "Pesanan " +
thisQueue.queue_number + thisQueue.queue_number +
" ✅" " ✅ "
: "Pesanan " + : "Pesanan " +
thisQueue.queue_number, thisQueue.queue_number,
style: TextStyle(fontSize: 20), style: TextStyle(fontSize: 20),
), );
},
), ),
), ),
), ),
...@@ -270,18 +279,19 @@ class _MainPageState extends State<MainPage> { ...@@ -270,18 +279,19 @@ class _MainPageState extends State<MainPage> {
mainAxisSpacing: 5, mainAxisSpacing: 5,
childAspectRatio: 2), childAspectRatio: 2),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
var thisReady = orderReady[index];
return Material( return Material(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
setState(() { setState(() {
// if (readySelected.contains(readyItem)) { if (readySelected.contains(thisReady)) {
// readySelected.remove(readyItem); readySelected.remove(thisReady);
// } else { } else {
// readySelected.add(readyItem); readySelected.add(thisReady);
// } }
// print(readySelected.toString()); print(readySelected.toString());
}); });
}, },
child: Card( child: Card(
...@@ -291,12 +301,12 @@ class _MainPageState extends State<MainPage> { ...@@ -291,12 +301,12 @@ class _MainPageState extends State<MainPage> {
), ),
child: Center( child: Center(
child: Text( child: Text(
readySelected.contains(orderReady) readySelected.contains(thisReady)
? "Pesanan " + ? "Pesanan " +
orderReady[index].queue_number + thisReady.queue_number +
" ✅" " ✅"
: "Pesanan " + : "Pesanan " +
orderReady[index].queue_number, thisReady.queue_number,
style: TextStyle(fontSize: 20), style: TextStyle(fontSize: 20),
), ),
), ),
......
...@@ -150,7 +150,7 @@ packages: ...@@ -150,7 +150,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.1"
provider: provider:
dependency: transitive dependency: transitive
description: description:
...@@ -204,7 +204,7 @@ packages: ...@@ -204,7 +204,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.8" version: "0.4.9"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST}) foreach(plugin ${FLUTTER_PLUGIN_LIST})
...@@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) ...@@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin) endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment