@@ -43,6 +43,15 @@ class _FiltersPageState extends State<FiltersPage> {
4343 onPressed: () => FiltersStorage ().removeFilterAt (i),
4444 ),
4545 );
46+ } else if (filter is CompanyNameFilter ) {
47+ return ListTile (
48+ leading: const Icon (Icons .groups),
49+ title: Text (filter.companyName),
50+ trailing: IconButton (
51+ icon: const Icon (Icons .clear),
52+ onPressed: () => FiltersStorage ().removeFilterAt (i),
53+ ),
54+ );
4655 } else {
4756 logInfo ("filter not supported" );
4857 }
@@ -83,18 +92,29 @@ class _FiltersPageState extends State<FiltersPage> {
8392 case _DialogType .AuthorNickname :
8493 await _createAuthorNicknameFilter ();
8594 break ;
95+ case _DialogType .CompanyName :
96+ await _createCompanyNameFilter ();
97+ break ;
8698 default :
8799 logInfo ('$type not supported' );
88100 }
89101 }
90102
91103 Future <void > _createAuthorNicknameFilter () async {
92- await showDialog <_DialogType >(
104+ await showDialog <void >(
93105 context: context,
94106 builder: (BuildContext context) {
95107 return _AuthorNicknameFilterDialog ();
96108 });
97109 }
110+
111+ Future <void > _createCompanyNameFilter () async {
112+ await showDialog <void >(
113+ context: context,
114+ builder: (BuildContext context) {
115+ return _CompanyNameFilterDialog ();
116+ });
117+ }
98118}
99119
100120enum _DialogType {
@@ -134,19 +154,20 @@ class _AuthorNicknameFilterDialogState
134154 controller: nickanameControll,
135155 autofocus: true ,
136156 decoration: InputDecoration (
137- labelText: AppLocalizations .of (context).authorNickname,
138- hintText: AppLocalizations .of (context).authorNicknameHint),
157+ labelText: AppLocalizations .of (context).authorNickname,
158+ hintText: AppLocalizations .of (context).authorNicknameHint,
159+ ),
139160 ),
140161 )
141162 ],
142163 ),
143164 actions: < Widget > [
144- FlatButton (
165+ TextButton (
145166 child: Text (AppLocalizations .of (context).cancel),
146167 onPressed: () {
147168 Navigator .pop (context);
148169 }),
149- FlatButton (
170+ TextButton (
150171 child: Text (AppLocalizations .of (context).create),
151172 onPressed: () {
152173 if (nicknameValid ())
@@ -158,3 +179,58 @@ class _AuthorNicknameFilterDialogState
158179 );
159180 }
160181}
182+
183+ class _CompanyNameFilterDialog extends StatefulWidget {
184+ @override
185+ State <StatefulWidget > createState () => _CompanyNameFilterDialogState ();
186+ }
187+
188+ class _CompanyNameFilterDialogState extends State <_CompanyNameFilterDialog > {
189+ TextEditingController nickanameControll;
190+
191+ @override
192+ void initState () {
193+ super .initState ();
194+ nickanameControll = TextEditingController ();
195+ }
196+
197+ bool nicknameValid () {
198+ return nickanameControll.text.isNotEmpty;
199+ }
200+
201+ @override
202+ Widget build (BuildContext context) {
203+ return AlertDialog (
204+ contentPadding: const EdgeInsets .all (16.0 ),
205+ content: Row (
206+ children: [
207+ Expanded (
208+ child: TextField (
209+ controller: nickanameControll,
210+ autofocus: true ,
211+ decoration: InputDecoration (
212+ labelText: "Имя компании" ,
213+ hintText: "Например, RUVDS.com" ,
214+ ),
215+ ),
216+ )
217+ ],
218+ ),
219+ actions: < Widget > [
220+ TextButton (
221+ child: Text (AppLocalizations .of (context).cancel),
222+ onPressed: () {
223+ Navigator .pop (context);
224+ }),
225+ TextButton (
226+ child: Text (AppLocalizations .of (context).create),
227+ onPressed: () {
228+ if (nicknameValid ())
229+ FiltersStorage ()
230+ .addFilter (CompanyNameFilter (nickanameControll.text));
231+ Navigator .pop (context);
232+ })
233+ ],
234+ );
235+ }
236+ }
0 commit comments