@@ -2,6 +2,7 @@ import 'dart:convert';
22
33import 'package:flutter/material.dart' ;
44import 'package:flutter_secure_storage/flutter_secure_storage.dart' ;
5+ import 'package:pr_watch/app_theme.dart' ;
56import 'package:pr_watch/models/app_state.dart' ;
67import 'package:pr_watch/models/organization.dart' ;
78import 'package:pr_watch/models/settings.dart' ;
@@ -119,6 +120,33 @@ class _ConfigureStateState extends State<ConfigureState> {
119120 value: _appState.members.map ((e) => e.id).join (',' ));
120121 }
121122
123+ // Bots can't be team members, so they're saved by login from the
124+ // Members page. Their watched state is kept with the members'.
125+ var botLogins = await storage.read (key: 'BOTS' );
126+ if (botLogins != null && botLogins.isNotEmpty) {
127+ var watched = (await storage.read (key: 'WATCHED_MEMBERS' ))
128+ ? .split (',' )
129+ .map ((e) => int .tryParse (e));
130+ for (var login in botLogins.split (',' )) {
131+ try {
132+ var bot = await GithubService .instance.fetchMember (login);
133+ _appState.bots.add (bot);
134+ _appState.isMemberWatched[bot.id] =
135+ watched? .contains (bot.id) ?? true ;
136+ } on Exception catch (e) {
137+ if (mounted) SnackbarService .show (context, e.toString ());
138+ }
139+ }
140+ }
141+
142+ // No saved selection means bot PRs show from every team repository.
143+ var botRepos = await storage.read (key: 'BOT_REPOS' );
144+ var botRepoIds = botRepos? .split (',' ).map ((e) => int .tryParse (e));
145+ for (var i = 0 ; i < _appState.repositories.length; i++ ) {
146+ _appState.isBotRepoWatched[_appState.repositories[i].id] =
147+ botRepoIds? .contains (_appState.repositories[i].id) ?? true ;
148+ }
149+
122150 var adminReviewers = await storage.read (key: 'ADMIN_REVIEWER' );
123151 if (adminReviewers != null ) {
124152 var admin = adminReviewers.split (',' ).map ((e) => int .tryParse (e));
@@ -209,13 +237,14 @@ class _ConfigureStateState extends State<ConfigureState> {
209237 }
210238
211239 Widget _buildOrgSelect () {
240+ final colors = AppColors .of (context);
212241 return Column (
213242 children: [
214- const Padding (
215- padding: EdgeInsets .all (16.0 ),
243+ Padding (
244+ padding: const EdgeInsets .all (16.0 ),
216245 child: Text (
217246 'Select an organization' ,
218- style: TextStyle (fontSize: 36 , color: Colors .white ),
247+ style: TextStyle (fontSize: 36 , color: colors.text ),
219248 ),
220249 ),
221250 const Divider (
@@ -252,37 +281,38 @@ class _ConfigureStateState extends State<ConfigureState> {
252281 ),
253282 ),
254283 if (_orgs.isEmpty)
255- const Center (
284+ Center (
256285 child: Text ('You are not part of any organizations' ,
257- style: TextStyle (fontSize: 24 , color: Colors .white )),
286+ style: TextStyle (fontSize: 24 , color: colors.text )),
258287 ),
259288 ],
260289 );
261290 }
262291
263292 Widget _buildTeamSelect () {
293+ final colors = AppColors .of (context);
264294 return Column (
265295 children: [
266- const Padding (
267- padding: EdgeInsets .all (16.0 ),
296+ Padding (
297+ padding: const EdgeInsets .all (16.0 ),
268298 child: Text (
269299 'Select a team' ,
270- style: TextStyle (fontSize: 36 , color: Colors .white ),
300+ style: TextStyle (fontSize: 36 , color: colors.text ),
271301 ),
272302 ),
273303 TextField (
274- decoration: const InputDecoration (
304+ decoration: InputDecoration (
275305 labelText: 'Search' ,
276- labelStyle: TextStyle (color: Colors .white ),
277- prefixIcon: Icon (Icons .search, color: Colors .white ),
306+ labelStyle: TextStyle (color: colors.text ),
307+ prefixIcon: Icon (Icons .search, color: colors.text ),
278308 enabledBorder: UnderlineInputBorder (
279- borderSide: BorderSide (color: Colors .white ),
309+ borderSide: BorderSide (color: colors.text ),
280310 ),
281311 focusedBorder: UnderlineInputBorder (
282- borderSide: BorderSide (color: Colors .white ),
312+ borderSide: BorderSide (color: colors.text ),
283313 ),
284314 ),
285- style: const TextStyle (color: Colors .white ),
315+ style: TextStyle (color: colors.text ),
286316 onChanged: (value) {
287317 setState (() {
288318 _emptySearchText = value.isEmpty;
@@ -335,14 +365,14 @@ class _ConfigureStateState extends State<ConfigureState> {
335365 ),
336366 ),
337367 if (_filteredTeams.isEmpty && ! _emptySearchText)
338- const Center (
368+ Center (
339369 child: Text ('No teams found' ,
340- style: TextStyle (fontSize: 24 , color: Colors .white )),
370+ style: TextStyle (fontSize: 24 , color: colors.text )),
341371 ),
342372 if (_filteredTeams.isEmpty && _emptySearchText)
343- const Center (
373+ Center (
344374 child: Text ('Search for your team' ,
345- style: TextStyle (fontSize: 24 , color: Colors .white )),
375+ style: TextStyle (fontSize: 24 , color: colors.text )),
346376 ),
347377 ],
348378 );
@@ -359,7 +389,8 @@ class _ConfigureStateState extends State<ConfigureState> {
359389 const SizedBox (height: 10 ),
360390 Text (
361391 _loadingText,
362- style: const TextStyle (color: Colors .white, fontSize: 24 ),
392+ style: TextStyle (
393+ color: AppColors .of (context).text, fontSize: 24 ),
363394 ),
364395 ],
365396 ))
0 commit comments