diff --git a/lib/main.dart b/lib/main.dart index 277f34f..80e3163 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -117,12 +117,8 @@ class _HomeState extends State { Widget build(BuildContext context) { var settings = Provider.of(context); var themData = ThemeData( - // primaryColor: HSLColor.fromColor(Palette.primary) - // .withLightness(0.3) - // .toColor(), - // primaryColor: Color(0xff333333), - primaryColor: PrimerColors.gray900, - accentColor: PrimerColors.gray900, + primaryColor: PrimerColors.white, + accentColor: PrimerColors.blue500, ); // TODO: diff --git a/lib/screens/search.dart b/lib/screens/search.dart index cf757a7..c11d5cd 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:git_touch/models/theme.dart'; -import 'package:git_touch/scaffolds/tab.dart'; -import 'package:git_touch/widgets/app_bar_title.dart'; +import 'package:git_touch/scaffolds/utils.dart'; import 'package:git_touch/widgets/issue_item.dart'; +import 'package:git_touch/widgets/loading.dart'; import 'package:git_touch/widgets/user_item.dart'; +import 'package:primer/primer.dart'; import 'package:provider/provider.dart'; import 'package:git_touch/models/auth.dart'; import '../utils/utils.dart'; @@ -93,21 +94,42 @@ class _SearchScreenState extends State { Widget _buildInput() { switch (Provider.of(context).theme) { case AppThemeType.cupertino: - return CupertinoTextField( - controller: _controller, - // padding: EdgeInsets.all(10), - placeholder: 'Type to search', - clearButtonMode: OverlayVisibilityMode.editing, - onSubmitted: (_) => _query(), + return Container( + color: Colors.white, + child: CupertinoTextField( + prefix: Row( + children: [ + SizedBox(width: 8), + Icon(Octicons.search, size: 20, color: PrimerColors.gray400), + ], + ), + placeholder: 'Search', + clearButtonMode: OverlayVisibilityMode.editing, + textInputAction: TextInputAction.go, + onSubmitted: (_) => _query(), + controller: _controller, + ), ); default: return TextField( + textInputAction: TextInputAction.go, onSubmitted: (_) => _query(), controller: _controller, ); } } + _onTabSwitch(int index) { + setState(() { + _activeTab = index; + }); + if (_payloads[_activeTab].isEmpty) { + _query(); + } + } + + static const tabs = ['Repositories', 'Users', 'Issues']; + Widget _buildItem(data) { switch (_activeTab) { case 0: @@ -126,25 +148,50 @@ class _SearchScreenState extends State { @override Widget build(BuildContext context) { - return TabScaffold( - title: AppBarTitle('Search GitHub Repositories'), - body: Column( - children: [ - Container(padding: EdgeInsets.all(8), child: _buildInput()), - Column(children: _payloads[_activeTab].map(_buildItem).toList()) - ], + final theme = Provider.of(context).theme; + + final scaffold = CommonScaffold( + title: _buildInput(), + body: SingleChildScrollView( + child: _loading + ? Loading() + : Column( + children: [ + if (theme == AppThemeType.cupertino) + Center( + child: Padding( + padding: EdgeInsets.symmetric(vertical: 8), + child: CupertinoSegmentedControl( + groupValue: _activeTab, + onValueChanged: _onTabSwitch, + children: tabs.asMap().map((key, text) => MapEntry( + key, + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 8), + child: + Text(text, style: TextStyle(fontSize: 14)), + ))), + ), + ), + ), + ..._payloads[_activeTab].map(_buildItem).toList(), + ], + ), + ), + bottom: TabBar( + onTap: _onTabSwitch, + tabs: tabs.map((text) => Tab(text: text.toUpperCase())).toList(), ), - activeTab: _activeTab, - onRefresh: _query, - onTabSwitch: (int index) { - setState(() { - _activeTab = index; - }); - if (_payloads[_activeTab].isEmpty) { - _query(); - } - }, - tabs: ['Repositories', 'Users', 'Issues'], ); + + if (theme == AppThemeType.material) { + return DefaultTabController( + length: tabs.length, + child: scaffold, + ); + } else { + return scaffold; + } } } diff --git a/lib/widgets/loading.dart b/lib/widgets/loading.dart index 5c75462..ffa8bf2 100644 --- a/lib/widgets/loading.dart +++ b/lib/widgets/loading.dart @@ -9,34 +9,25 @@ class Loading extends StatelessWidget { Loading({this.more = false}); Widget _buildIndicator(BuildContext context) { - // return Image.asset('images/loading.webp'); - switch (Provider.of(context).theme) { case AppThemeType.cupertino: return CupertinoActivityIndicator(radius: 12); default: - return Center( - child: SizedBox( - width: 24, - height: 24, - child: CircularProgressIndicator(), - ), + return SizedBox( + width: 24, + height: 24, + child: CircularProgressIndicator(), ); } } @override Widget build(BuildContext context) { - if (more) { - return Padding( - padding: EdgeInsets.symmetric(vertical: 20), + return Center( + child: Padding( + padding: EdgeInsets.symmetric(vertical: more ? 20 : 100), child: _buildIndicator(context), - ); - } else { - return Padding( - padding: EdgeInsets.symmetric(vertical: 50), - child: _buildIndicator(context), - ); - } + ), + ); } }