0% found this document useful (0 votes)
9 views

New Text Document (4)

The document describes a Flutter function that displays a modal bottom sheet for adding a product, including fields for product type, story type, name, description, price, and content. It utilizes a StatefulBuilder to manage state changes and allows users to select product types from a dropdown menu. Additionally, it provides a button to navigate to a content editor screen for further input on the product's content.

Uploaded by

dminh2k4cn
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

New Text Document (4)

The document describes a Flutter function that displays a modal bottom sheet for adding a product, including fields for product type, story type, name, description, price, and content. It utilizes a StatefulBuilder to manage state changes and allows users to select product types from a dropdown menu. Additionally, it provides a button to navigate to a content editor screen for further input on the product's content.

Uploaded by

dminh2k4cn
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 14

Future<void> _showAddProductDialog() async {

String? productType = 'text';


String genre = 'Kinh dị';
String storyType = 'All in one';
String name = '';
String description = '';
int price = 0;
String content = '';

showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: productType == 'text'
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Thêm sản phẩm', style: TextStyle(fontSize: 18,
fontWeight: FontWeight.bold)),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện
chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: storyType,
onChanged: (value) {
setState(() {
storyType = value!;
});
},
items: [
DropdownMenuItem(value: 'All in one', child: Text('All
in one')),
DropdownMenuItem(value: 'Nhiều tập', child: Text('Nhiều
tập')),
],
decoration: InputDecoration(
labelText: 'Loại truyện',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => name = value,
decoration: InputDecoration(
labelText: 'Tên sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => description = value,
decoration: InputDecoration(
labelText: 'Mô tả',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
keyboardType: TextInputType.number,
onChanged: (value) => price = int.tryParse(value) ?? 0,
decoration: InputDecoration(
labelText: 'Giá (Diamonds)',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ContentEditorScreen(initialContent: content),
),
);

if (result != null) {
content = result;
}
},
child: Text('Nội dung'),
),
],
)
: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
Text(
'Chức năng đang được phát triển!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.red,
),
textAlign: TextAlign.center,
),
],
),
),

);
},
),
);
},
);
}
}

Future<void> _showAddProductDialog() async {


String? productType = 'text';
String genre = 'Kinh dị';
String storyType = 'All in one';
String name = '';
String description = '';
int price = 0;
String content = '';

showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: productType == 'text'
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Thêm sản phẩm', style: TextStyle(fontSize: 18,
fontWeight: FontWeight.bold)),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện
chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: storyType,
onChanged: (value) {
setState(() {
storyType = value!;
});
},
items: [
DropdownMenuItem(value: 'All in one', child: Text('All
in one')),
DropdownMenuItem(value: 'Nhiều tập', child: Text('Nhiều
tập')),
],
decoration: InputDecoration(
labelText: 'Loại truyện',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => name = value,
decoration: InputDecoration(
labelText: 'Tên sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => description = value,
decoration: InputDecoration(
labelText: 'Mô tả',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
keyboardType: TextInputType.number,
onChanged: (value) => price = int.tryParse(value) ?? 0,
decoration: InputDecoration(
labelText: 'Giá (Diamonds)',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ContentEditorScreen(initialContent: content),
),
);

if (result != null) {
content = result;
}
},
child: Text('Nội dung'),
),
],
)
: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
Text(
'Chức năng đang được phát triển!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.red,
),
textAlign: TextAlign.center,
),
],
),
),

);
},
),
);
},
);
}
}

Future<void> _showAddProductDialog() async {


String? productType = 'text';
String genre = 'Kinh dị';
String storyType = 'All in one';
String name = '';
String description = '';
int price = 0;
String content = '';

showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: productType == 'text'
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Thêm sản phẩm', style: TextStyle(fontSize: 18,
fontWeight: FontWeight.bold)),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện
chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: storyType,
onChanged: (value) {
setState(() {
storyType = value!;
});
},
items: [
DropdownMenuItem(value: 'All in one', child: Text('All
in one')),
DropdownMenuItem(value: 'Nhiều tập', child: Text('Nhiều
tập')),
],
decoration: InputDecoration(
labelText: 'Loại truyện',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => name = value,
decoration: InputDecoration(
labelText: 'Tên sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => description = value,
decoration: InputDecoration(
labelText: 'Mô tả',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
keyboardType: TextInputType.number,
onChanged: (value) => price = int.tryParse(value) ?? 0,
decoration: InputDecoration(
labelText: 'Giá (Diamonds)',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ContentEditorScreen(initialContent: content),
),
);
if (result != null) {
content = result;
}
},
child: Text('Nội dung'),
),
],
)
: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
Text(
'Chức năng đang được phát triển!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.red,
),
textAlign: TextAlign.center,
),
],
),
),

);
},
),
);
},
);
}
}

Future<void> _showAddProductDialog() async {


String? productType = 'text';
String genre = 'Kinh dị';
String storyType = 'All in one';
String name = '';
String description = '';
int price = 0;
String content = '';

showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: productType == 'text'
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Thêm sản phẩm', style: TextStyle(fontSize: 18,
fontWeight: FontWeight.bold)),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện
chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: storyType,
onChanged: (value) {
setState(() {
storyType = value!;
});
},
items: [
DropdownMenuItem(value: 'All in one', child: Text('All
in one')),
DropdownMenuItem(value: 'Nhiều tập', child: Text('Nhiều
tập')),
],
decoration: InputDecoration(
labelText: 'Loại truyện',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => name = value,
decoration: InputDecoration(
labelText: 'Tên sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => description = value,
decoration: InputDecoration(
labelText: 'Mô tả',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
keyboardType: TextInputType.number,
onChanged: (value) => price = int.tryParse(value) ?? 0,
decoration: InputDecoration(
labelText: 'Giá (Diamonds)',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ContentEditorScreen(initialContent: content),
),
);

if (result != null) {
content = result;
}
},
child: Text('Nội dung'),
),
],
)
: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
Text(
'Chức năng đang được phát triển!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.red,
),
textAlign: TextAlign.center,
),
],
),
),

);
},
),
);
},
);
}
}

Future<void> _showAddProductDialog() async {


String? productType = 'text';
String genre = 'Kinh dị';
String storyType = 'All in one';
String name = '';
String description = '';
int price = 0;
String content = '';

showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: productType == 'text'
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Thêm sản phẩm', style: TextStyle(fontSize: 18,
fontWeight: FontWeight.bold)),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện
chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
DropdownButtonFormField<String>(
value: storyType,
onChanged: (value) {
setState(() {
storyType = value!;
});
},
items: [
DropdownMenuItem(value: 'All in one', child: Text('All
in one')),
DropdownMenuItem(value: 'Nhiều tập', child: Text('Nhiều
tập')),
],
decoration: InputDecoration(
labelText: 'Loại truyện',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => name = value,
decoration: InputDecoration(
labelText: 'Tên sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
onChanged: (value) => description = value,
decoration: InputDecoration(
labelText: 'Mô tả',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
keyboardType: TextInputType.number,
onChanged: (value) => price = int.tryParse(value) ?? 0,
decoration: InputDecoration(
labelText: 'Giá (Diamonds)',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ContentEditorScreen(initialContent: content),
),
);

if (result != null) {
content = result;
}
},
child: Text('Nội dung'),
),
],
)
: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownButtonFormField<String>(
value: productType,
onChanged: (value) {
setState(() {
productType = value;
});
},
items: [
DropdownMenuItem(value: 'text', child: Text('Truyện chữ')),
DropdownMenuItem(value: 'comic', child: Text('Truyện
tranh')),
DropdownMenuItem(value: 'music', child: Text('Nhạc')),
DropdownMenuItem(value: 'video', child: Text('Video')),
],
decoration: InputDecoration(
labelText: 'Chọn loại sản phẩm',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
Text(
'Chức năng đang được phát triển!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.red,
),
textAlign: TextAlign.center,
),
],
),
),
);
},
),
);
},
);
}
}

You might also like