promocode
This commit is contained in:
parent
39b91a5fb3
commit
819bdd1134
3 changed files with 187 additions and 192 deletions
|
|
@ -163,165 +163,153 @@ class AddPromocodeCampaign {
|
|||
}).toList(),
|
||||
),
|
||||
StatefulBuilder(builder: (context, setState) {
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
TextParam(
|
||||
'Name',
|
||||
campaignDto.name,
|
||||
(v) {
|
||||
campaignDto =
|
||||
campaignDto.copyWith(
|
||||
name: v,
|
||||
TextParam(
|
||||
'Name',
|
||||
campaignDto.name,
|
||||
(v) {
|
||||
campaignDto = campaignDto.copyWith(
|
||||
name: v,
|
||||
);
|
||||
},
|
||||
),
|
||||
TextParam(
|
||||
'Template',
|
||||
campaignDto.template,
|
||||
(v) {
|
||||
campaignDto = campaignDto.copyWith(
|
||||
template: v,
|
||||
);
|
||||
},
|
||||
description:
|
||||
r'$d - digit $l - letter $s - any',
|
||||
),
|
||||
IntParam(
|
||||
'Generation size',
|
||||
campaignDto.generationSize,
|
||||
(v) {
|
||||
campaignDto = campaignDto.copyWith(
|
||||
generationSize: v);
|
||||
},
|
||||
),
|
||||
IntParam(
|
||||
'Activations per code',
|
||||
campaignDto.activationsPerCode,
|
||||
(v) {
|
||||
campaignDto = campaignDto.copyWith(
|
||||
activationsPerCode: v,
|
||||
);
|
||||
},
|
||||
),
|
||||
DateParam(
|
||||
'Start',
|
||||
campaignDto.start,
|
||||
(v) {
|
||||
setState(() {
|
||||
campaignDto = campaignDto
|
||||
.copyWith(start: v);
|
||||
});
|
||||
},
|
||||
),
|
||||
DateParam(
|
||||
'Finish',
|
||||
campaignDto.finish,
|
||||
(v) {
|
||||
setState(() {
|
||||
campaignDto = campaignDto
|
||||
.copyWith(finish: v);
|
||||
});
|
||||
},
|
||||
),
|
||||
DateParam(
|
||||
'Finish',
|
||||
campaignDto.finish,
|
||||
(v) {
|
||||
setState(() {
|
||||
campaignDto = campaignDto
|
||||
.copyWith(finish: v);
|
||||
});
|
||||
},
|
||||
),
|
||||
EnumParam(
|
||||
'Status',
|
||||
PromoCodeCampaignStatus.values,
|
||||
campaignDto.status, (v) {
|
||||
setState(() {
|
||||
campaignDto =
|
||||
campaignDto.copyWith(status: v);
|
||||
});
|
||||
}),
|
||||
Text(
|
||||
'Created to generate promocodes\n'
|
||||
'Disabled to disable\n'
|
||||
'Dont use other statuses!',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
Text('Products:'),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount:
|
||||
campaignDto.products.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index ==
|
||||
campaignDto.products.length) {
|
||||
return ListTile(
|
||||
title: Text('Add'),
|
||||
onTap: () async {
|
||||
final p =
|
||||
await _showProductDialog(
|
||||
context, null);
|
||||
if (p != null) {
|
||||
setState(() {
|
||||
campaignDto.products
|
||||
.add(p);
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
final item =
|
||||
campaignDto.products[index];
|
||||
return ListTile(
|
||||
title: Text(
|
||||
'${item.type.name} ${item.id ?? ''}'),
|
||||
onTap: () async {
|
||||
final p =
|
||||
await _showProductDialog(
|
||||
context,
|
||||
item,
|
||||
);
|
||||
},
|
||||
),
|
||||
TextParam(
|
||||
'Template',
|
||||
campaignDto.template,
|
||||
(v) {
|
||||
campaignDto =
|
||||
campaignDto.copyWith(
|
||||
template: v,
|
||||
);
|
||||
},
|
||||
description:
|
||||
r'$d - digit $l - letter $s - any',
|
||||
),
|
||||
IntParam(
|
||||
'Generation size',
|
||||
campaignDto.generationSize,
|
||||
(v) {
|
||||
campaignDto =
|
||||
campaignDto.copyWith(
|
||||
generationSize: v);
|
||||
},
|
||||
),
|
||||
IntParam(
|
||||
'Activations per code',
|
||||
campaignDto.activationsPerCode,
|
||||
(v) {
|
||||
campaignDto =
|
||||
campaignDto.copyWith(
|
||||
activationsPerCode: v,
|
||||
);
|
||||
},
|
||||
),
|
||||
DateParam(
|
||||
'Start',
|
||||
campaignDto.start,
|
||||
(v) {
|
||||
setState(() {
|
||||
campaignDto = campaignDto
|
||||
.copyWith(start: v);
|
||||
});
|
||||
},
|
||||
),
|
||||
DateParam(
|
||||
'Finish',
|
||||
campaignDto.finish,
|
||||
(v) {
|
||||
setState(() {
|
||||
campaignDto = campaignDto
|
||||
.copyWith(finish: v);
|
||||
});
|
||||
},
|
||||
),
|
||||
DateParam(
|
||||
'Finish',
|
||||
campaignDto.finish,
|
||||
(v) {
|
||||
setState(() {
|
||||
campaignDto = campaignDto
|
||||
.copyWith(finish: v);
|
||||
});
|
||||
},
|
||||
),
|
||||
EnumParam(
|
||||
'Status',
|
||||
PromoCodeCampaignStatus.values,
|
||||
campaignDto.status, (v) {
|
||||
setState(() {
|
||||
campaignDto = campaignDto
|
||||
.copyWith(status: v);
|
||||
});
|
||||
}),
|
||||
Text(
|
||||
'Created to generate promocodes\n'
|
||||
'Disabled to disable\n'
|
||||
'Dont use other statuses!',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
Text('Products:'),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount:
|
||||
campaignDto.products.length +
|
||||
1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index ==
|
||||
campaignDto
|
||||
.products.length) {
|
||||
return ListTile(
|
||||
title: Text('Add'),
|
||||
onTap: () async {
|
||||
final p =
|
||||
await _showProductDialog(
|
||||
context, null);
|
||||
if (p != null) {
|
||||
setState(() {
|
||||
campaignDto.products
|
||||
.add(p);
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
if (p != null) {
|
||||
setState(() {
|
||||
campaignDto.products.add(p);
|
||||
});
|
||||
}
|
||||
final item =
|
||||
campaignDto.products[index];
|
||||
return ListTile(
|
||||
title: Text(
|
||||
'${item.type.name} ${item.id ?? ''}'),
|
||||
onTap: () async {
|
||||
final p =
|
||||
await _showProductDialog(
|
||||
context,
|
||||
item,
|
||||
);
|
||||
if (p != null) {
|
||||
setState(() {
|
||||
campaignDto.products
|
||||
.add(p);
|
||||
});
|
||||
}
|
||||
},
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
campaignDto.products
|
||||
.remove(item);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
campaignDto.products
|
||||
.remove(item);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -12,54 +12,61 @@ class DateParam extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(title),
|
||||
SizedBox(
|
||||
width: 2,
|
||||
width: 8,
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () async {
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialEntryMode: DatePickerEntryMode.calendar,
|
||||
initialDate: initial ?? DateTime.now(),
|
||||
firstDate: DateTime.utc(2000),
|
||||
lastDate: DateTime.utc(2050),
|
||||
).then((selectedDate) {
|
||||
// After selecting the date, display the time picker.
|
||||
if (selectedDate != null) {
|
||||
return showTimePicker(
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () async {
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
).then((selectedTime) {
|
||||
// Handle the selected date and time here.
|
||||
if (selectedTime != null) {
|
||||
DateTime selectedDateTime = DateTime(
|
||||
selectedDate.year,
|
||||
selectedDate.month,
|
||||
selectedDate.day,
|
||||
selectedTime.hour,
|
||||
selectedTime.minute,
|
||||
);
|
||||
return selectedDateTime;
|
||||
initialEntryMode: DatePickerEntryMode.calendar,
|
||||
initialDate: initial ?? DateTime.now(),
|
||||
firstDate: DateTime.utc(2000),
|
||||
lastDate: DateTime.utc(2050),
|
||||
).then((selectedDate) {
|
||||
// After selecting the date, display the time picker.
|
||||
if (selectedDate != null) {
|
||||
return showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
).then((selectedTime) {
|
||||
// Handle the selected date and time here.
|
||||
if (selectedTime != null) {
|
||||
DateTime selectedDateTime = DateTime(
|
||||
selectedDate.year,
|
||||
selectedDate.month,
|
||||
selectedDate.day,
|
||||
selectedTime.hour,
|
||||
selectedTime.minute,
|
||||
);
|
||||
return selectedDateTime;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return null;
|
||||
});
|
||||
onChanged(date);
|
||||
},
|
||||
child: Expanded(
|
||||
child: Text(
|
||||
initial?.let(
|
||||
(d) =>
|
||||
'${d.year}.${d.month}.${d.day} ${d.hour}:${d.minute}',
|
||||
) ??
|
||||
'No date',
|
||||
onChanged(date);
|
||||
},
|
||||
child: Text(
|
||||
initial?.let(
|
||||
(d) =>
|
||||
'${d.year}.${d.month}.${d.day} ${d.hour}:${d.minute}',
|
||||
) ??
|
||||
'No date',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class EnumParam<T extends Enum> extends StatelessWidget {
|
|||
.toList(),
|
||||
onChanged: (v) => setState(() {
|
||||
value = v!;
|
||||
onChanged(v!);
|
||||
onChanged(v);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in a new issue