Skip to content

Commit

Permalink
Release v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Cong Nguyen authored and congthanhng committed Jan 20, 2023
1 parent 822651e commit f5f4e2e
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 162 deletions.
8 changes: 6 additions & 2 deletions lib/app/lucky_envelope_app.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lucky_envolope/app/presentation/blocs/draw/draw_bloc.dart';
import 'package:lucky_envolope/app/presentation/blocs/envelope_set/envelope_set_bloc.dart';
Expand All @@ -21,7 +22,10 @@ class LuckyEnvelopeApp extends StatefulWidget {
class _LuckyEnvelopeAppState extends State<LuckyEnvelopeApp> {
@override
void initState() {
// context.read<EnvelopeSetBloc>().add(EnvelopeSetFetched());
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
super.initState();
}

Expand Down Expand Up @@ -149,7 +153,7 @@ class _LuckyEnvelopeAppState extends State<LuckyEnvelopeApp> {
borderRadius: BorderRadius.circular(6),
onTap: () {
CustomDraws.addNewEnvelope(
context: context, body: [const AddEnvelopeBSBody()]);
context: context, body: const AddEnvelopeBSBody());
},
child: const Padding(
padding:
Expand Down
24 changes: 4 additions & 20 deletions lib/app/presentation/components/overlays/draws/default_draw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ class CustomDraws {
),
],
),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
...body
],
),
),
),
...body,
const SizedBox(
height: 24,
),
Expand Down Expand Up @@ -129,7 +121,7 @@ class CustomDraws {
}

static addNewEnvelope(
{required BuildContext context, required List<Widget> body}) {
{required BuildContext context, required Widget body}) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
Expand Down Expand Up @@ -172,7 +164,7 @@ class CustomDraws {
),
],
),
...body,
body,
const SizedBox(
height: 24,
),
Expand Down Expand Up @@ -233,15 +225,7 @@ class CustomDraws {
),
],
),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
...body
],
),
),
),
...body,
const SizedBox(
height: 24,
),
Expand Down
279 changes: 139 additions & 140 deletions lib/app/presentation/widgets/add_envelope_bs_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,158 +35,157 @@ class _AddEnvelopeBSBodyState extends State<AddEnvelopeBSBody> {
@override
Widget build(BuildContext context) {
var isTablet = DeviceInfo.isTablet;
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(
height: 16,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'Chọn mệnh giá:',
style: TextStyle(
color: Colors.white,
),
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(
height: 16,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'Chọn mệnh giá:',
style: TextStyle(
color: Colors.white,
),
),
const SizedBox(
height: 8,
),
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: 2,
crossAxisCount: isTablet ? 5 : 3,
mainAxisSpacing: 16,
crossAxisSpacing: 16),
padding: const EdgeInsets.symmetric(horizontal: 16),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
if (selectedIndex != index) {
setState(() {
selectedIndex = index;
});
}
},
child: Container(
decoration: selectedIndex == index
? BoxDecoration(
border: Border.all(color: Colors.yellow, width: 3))
: null,
child: cells[index],
),
);
},
itemCount: cells.length,
),
const SizedBox(
height: 16,
),
Stack(
alignment: Alignment.centerLeft,
children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'Số lượng:',
style: TextStyle(
color: Colors.white,
),
),
const SizedBox(
height: 8,
),
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: 2,
crossAxisCount: isTablet ? 5 : 3,
mainAxisSpacing: 16,
crossAxisSpacing: 16),
padding: const EdgeInsets.symmetric(horizontal: 16),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
if (selectedIndex != index) {
setState(() {
selectedIndex = index;
});
}
},
child: Container(
decoration: selectedIndex == index
? BoxDecoration(
border: Border.all(color: Colors.yellow, width: 3))
: null,
child: cells[index],
),
);
},
itemCount: cells.length,
),
const SizedBox(
height: 16,
),
Stack(
alignment: Alignment.centerLeft,
children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'Số lượng:',
style: TextStyle(
color: Colors.white,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
if (quantity < 1) {
setState(() {
quantity = 1;
});
} else if (quantity > 1) {
setState(() {
quantity--;
});
}
},
child: const Padding(
padding: EdgeInsets.all(6.0),
child: Icon(Icons.remove, color: Colors.white),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
'$quantity',
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.w600),
),
),
InkWell(
onTap: () {
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
if (quantity < 1) {
setState(() {
quantity = 1;
});
} else if (quantity > 1) {
setState(() {
quantity++;
quantity--;
});
},
child: const Padding(
padding: EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color: Colors.white,
),
}
},
child: const Padding(
padding: EdgeInsets.all(6.0),
child: Icon(Icons.remove, color: Colors.white),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
'$quantity',
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.w600),
),
),
InkWell(
onTap: () {
setState(() {
quantity++;
});
},
child: const Padding(
padding: EdgeInsets.all(6.0),
child: Icon(
Icons.add,
color: Colors.white,
),
),
],
),
],
),
const SizedBox(
height: 16,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'Lưu ý: Sau khi nhấn thêm, toàn bộ lì xì chưa rút còn lại sẽ bị xáo trộn vị trí để đảm bảo tính ngẫu nhiên và công bằng.',
style: TextStyle(
color: Colors.white,
),
),
],
),
],
),
const SizedBox(
height: 16,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
'Lưu ý: Sau khi nhấn thêm, toàn bộ lì xì chưa rút còn lại sẽ bị xáo trộn vị trí để đảm bảo tính ngẫu nhiên và công bằng.',
style: TextStyle(
color: Colors.white,
),
),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
onPressed: () {
var denomination =
DenominationVN.getDefault.values.toList()[selectedIndex];
context.read<EnvelopeSetBloc>().add(EnvelopeSetItemAdded(
EnvelopeModel(
name: denomination.name,
quantity: quantity,
denominations: denomination.value,
isWithdraw: false)));
_settingBloc
.add(SettingQuantityIncreased(denomination.name, quantity));
Navigator.pop(context);
},
style: ButtonStyle(elevation: MaterialStateProperty.all(0)),
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0),
child: Text(
'Thêm',
style: TextStyle(color: Colors.white),
),
),
const SizedBox(
height: 8,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ElevatedButton(
onPressed: () {
var denomination =
DenominationVN.getDefault.values.toList()[selectedIndex];
context.read<EnvelopeSetBloc>().add(EnvelopeSetItemAdded(
EnvelopeModel(
name: denomination.name,
quantity: quantity,
denominations: denomination.value,
isWithdraw: false)));
_settingBloc
.add(SettingQuantityIncreased(denomination.name, quantity));
Navigator.pop(context);
},
style: ButtonStyle(elevation: MaterialStateProperty.all(0)),
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0),
child: Text(
'Thêm',
style: TextStyle(color: Colors.white),
),
),
)
],
),
),
)
],
);
}
}

0 comments on commit f5f4e2e

Please sign in to comment.