624214d0
liangchengyou
feat:看题选字/选图UI和部分逻辑
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
Widget _topicPictureView() => BlocBuilder<TopicPictureBloc,TopicPictureState>(
buildWhen: (_,s) => s is CurrentPageIndexState,
builder: (context,state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return Container(
color: Colors.white,
child: Stack(
children: [
Column(
children: [
PracticeHeaderWidget(
title: '${bloc.currentPage}/8',
onTap: (){Navigator.pop(context);},
),
Expanded(
child: PageView.builder(
itemCount: 8,
scrollDirection: Axis.horizontal,
controller: bloc.pageController,
onPageChanged: (int index) {
bloc.add(CurrentPageIndexChangeEvent(index));
},
itemBuilder: (BuildContext context,int index){
return _pageViewItemWidget();
}),
)
],
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Image.asset('bottom_grass'.assetPng)
)
],
),
);
});
Widget _pageViewItemWidget() => BlocBuilder<TopicPictureBloc,TopicPictureState>(
builder: (context, state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return SafeArea(
child: Column(
children: [
Text(
'What to do when the sentence question is very long and needs a line break',
softWrap: true,
style: TextStyle(
fontSize: 21.sp,
color: const Color(0xFF333333)
)
),
26.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Offstage(
offstage: (bloc.modelCount < 1),
child: _decodeImageWidget(1),
),
Offstage(
offstage: (bloc.modelCount < 2),
child: _decodeImageWidget(2),
),
Offstage(
offstage: (bloc.modelCount < 3),
child: _decodeImageWidget(3),
),
Offstage(
offstage: (bloc.modelCount < 4),
child: _decodeImageWidget(4),
)
],
)
],
),
);
});
Widget _decodeImageWidget(int index) => BlocBuilder<TopicPictureBloc,TopicPictureState>(
buildWhen: (_, s) => s is SelectItemChangeState,
builder: (context,state){
final bloc = BlocProvider.of<TopicPictureBloc>(context);
return GestureDetector(
onTap: () => bloc.add(SelectItemEvent(index)),
child: Container(
padding: const EdgeInsets.all(4.5),
decoration: BoxDecoration(
color: bloc.selectItem == index?const Color(0xFF00B6F1):Colors.white,
borderRadius: BorderRadius.circular(15),
),
height: 143.h,
width: 143.w,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
border: Border.all(
width: 1.0,
color: const Color(0xFF140C10)
),
image: const DecorationImage(
fit: BoxFit.fitWidth,
image: NetworkImage('https://img1.baidu.com/it/u=3392591833,1640391553&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=714')
)
),
),
),
);
});
|