Skip to content

Commit

Permalink
feat: add restriction to checking term
Browse files Browse the repository at this point in the history
  • Loading branch information
boroboro01 committed Oct 16, 2024
1 parent 12b08fd commit 6976a9b
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions lib/screens/selling/term_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ class TermScreen extends StatefulWidget {
}

class _TermScreenState extends State<TermScreen> {
final List<bool> _terms = [false, false, false, false];

bool get _allTermsAccepted => _terms.every((element) => element);

void _updateTermState(int index, bool value) {
setState(() {
_terms[index] = value;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -41,34 +51,42 @@ class _TermScreenState extends State<TermScreen> {
),
),
),
const Term(
Term(
content: '사용자는 판매하려는 제품에 대한 정확하고 정직한 정보를 제공해야 합니다.',
initial: false,
onChanged: (value) => _updateTermState(0, value),
),
const Term(
Term(
content: '사진에 타인의 얼굴이나 개인정보가 포함되지 않도록 주의해야 합니다.',
initial: false,
onChanged: (value) => _updateTermState(1, value),
),
const Term(
Term(
content: '금지된 품목을 사진에 포함하거나 게시하는 것은 엄격히 금지됩니다.',
initial: false,
onChanged: (value) => _updateTermState(2, value),
),
const Term(
Term(
content:
'사진은 선명하고 제품의 상태를 명확히 보여줄 수 있어야 합니다. 흐리거나 제품의 상태를 왜곡하는 사진은 삭제될 수 있습니다.',
initial: false,
onChanged: (value) => _updateTermState(3, value),
),
const SizedBox(height: 100.0),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: NormalButton(
title: '확인했어요',
bgColor: black,
bgColor: _allTermsAccepted ? black : gray400,
txtColor: white,
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const ProcessScreen(),
));
_allTermsAccepted
? {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const ProcessScreen(),
))
}
: null;
},
flag: true,
),
Expand All @@ -89,10 +107,12 @@ class Term extends StatefulWidget {
super.key,
required this.content,
required this.initial,
required this.onChanged,
});

final String content;
final bool initial;
final ValueChanged<bool> onChanged;

@override
State<Term> createState() => _TermState();
Expand Down Expand Up @@ -128,10 +148,13 @@ class _TermState extends State<Term> {
),
Checkbox(
value: approve,
onChanged: (value) {
setState(() {
approve = value!;
});
onChanged: (bool? value) {
if (value != null) {
setState(() {
approve = value;
});
widget.onChanged(value);
}
},
),
],
Expand Down

0 comments on commit 6976a9b

Please sign in to comment.