Merge pull request #85 from krawieck/small-tweaks
This commit is contained in:
commit
f3f0f09bae
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart' as ul;
|
||||
|
||||
import 'hooks/stores.dart';
|
||||
import 'pages/communities_tab.dart';
|
||||
|
@ -61,11 +62,34 @@ class MyApp extends HookWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class TemporarySearchTab extends HookWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final accStore = useAccountsStore();
|
||||
return ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Center(
|
||||
child: Text('🚧 this tab is still under construction 🚧\n'
|
||||
'but you can open your instances in a browser '
|
||||
' for missing functionality')),
|
||||
),
|
||||
Divider(),
|
||||
for (final inst in accStore.instances)
|
||||
ListTile(
|
||||
title: Text(inst),
|
||||
onTap: () => ul.launch('https://$inst/'),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends HookWidget {
|
||||
final List<Widget> pages = [
|
||||
HomeTab(),
|
||||
CommunitiesTab(),
|
||||
Center(child: Text('search')), // TODO: search tab
|
||||
TemporarySearchTab(), // TODO: search tab
|
||||
UserProfileTab(),
|
||||
];
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import '../hooks/stores.dart';
|
|||
import '../util/extensions/api.dart';
|
||||
import '../util/goto.dart';
|
||||
import '../util/intl.dart';
|
||||
import '../util/more_icon.dart';
|
||||
import '../util/text_color.dart';
|
||||
import '../widgets/badge.dart';
|
||||
import '../widgets/bottom_modal.dart';
|
||||
|
@ -164,8 +165,7 @@ class CommunityPage extends HookWidget {
|
|||
style: TextStyle(color: colorOnCard)),
|
||||
actions: [
|
||||
IconButton(icon: Icon(Icons.share), onPressed: _share),
|
||||
IconButton(
|
||||
icon: Icon(Icons.more_vert), onPressed: _openMoreMenu),
|
||||
IconButton(icon: Icon(moreIcon), onPressed: _openMoreMenu),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background:
|
||||
|
|
|
@ -8,6 +8,7 @@ import '../hooks/logged_in_action.dart';
|
|||
import '../hooks/memo_future.dart';
|
||||
import '../hooks/stores.dart';
|
||||
import '../util/extensions/api.dart';
|
||||
import '../util/more_icon.dart';
|
||||
import '../widgets/comment_section.dart';
|
||||
import '../widgets/post.dart';
|
||||
import '../widgets/save_post_button.dart';
|
||||
|
@ -82,7 +83,7 @@ class FullPostPage extends HookWidget {
|
|||
IconButton(icon: Icon(Icons.share), onPressed: sharePost),
|
||||
SavePostButton(post),
|
||||
IconButton(
|
||||
icon: Icon(Icons.more_vert),
|
||||
icon: Icon(moreIcon),
|
||||
onPressed: () => Post.showMoreMenu(context, post)),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -22,10 +22,12 @@ import 'inbox.dart';
|
|||
class HomeTab extends HookWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final selectedList =
|
||||
useState(_SelectedList(listingType: PostListingType.subscribed));
|
||||
// TODO: needs to be an observer? for accounts changes
|
||||
final accStore = useAccountsStore();
|
||||
final selectedList = useState(_SelectedList(
|
||||
listingType: accStore.hasNoAccount
|
||||
? PostListingType.all
|
||||
: PostListingType.subscribed));
|
||||
final isc = useInfiniteScrollController();
|
||||
final theme = Theme.of(context);
|
||||
final instancesIcons = useMemoFuture(() async {
|
||||
|
@ -153,6 +155,17 @@ class HomeTab extends HookWidget {
|
|||
return '$first$last';
|
||||
}();
|
||||
|
||||
if (accStore.instances.isEmpty) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Center(child: Text('there needs to be at least one instance')),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
// TODO: make appbar autohide when scrolling down
|
||||
appBar: AppBar(
|
||||
|
|
|
@ -8,6 +8,7 @@ import 'package:lemmy_api_client/lemmy_api_client.dart';
|
|||
import '../hooks/stores.dart';
|
||||
import '../util/extensions/api.dart';
|
||||
import '../util/goto.dart';
|
||||
import '../util/more_icon.dart';
|
||||
import '../util/text_color.dart';
|
||||
import '../widgets/badge.dart';
|
||||
import '../widgets/fullscreenable_image.dart';
|
||||
|
@ -99,7 +100,7 @@ class InstancePage extends HookWidget {
|
|||
actions: [
|
||||
IconButton(icon: Icon(Icons.share), onPressed: _share),
|
||||
IconButton(
|
||||
icon: Icon(Icons.more_vert),
|
||||
icon: Icon(moreIcon),
|
||||
onPressed: () => _openMoreMenu(context)),
|
||||
],
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
|
|
|
@ -18,8 +18,23 @@ class UserProfileTab extends HookWidget {
|
|||
final theme = Theme.of(context);
|
||||
final accountsStore = useAccountsStore();
|
||||
|
||||
final actions = [
|
||||
IconButton(
|
||||
icon: Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
goTo(context, (_) => SettingsPage());
|
||||
},
|
||||
)
|
||||
];
|
||||
|
||||
if (accountsStore.hasNoAccount) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: actions,
|
||||
backgroundColor: Colors.transparent,
|
||||
iconTheme: theme.iconTheme,
|
||||
shadowColor: Colors.transparent,
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
@ -100,14 +115,7 @@ class UserProfileTab extends HookWidget {
|
|||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
goTo(context, (_) => SettingsPage());
|
||||
},
|
||||
)
|
||||
],
|
||||
actions: actions,
|
||||
),
|
||||
body: UserProfile(
|
||||
userId: accountsStore.defaultToken.payload.id,
|
||||
|
|
|
@ -30,8 +30,8 @@ class AccountsStore extends ChangeNotifier {
|
|||
// I barely understand what I did. Long story short it casts a
|
||||
// raw json into a nested ObservableMap
|
||||
nestedMapsCast<T>(T f(Map<String, dynamic> json)) => HashMap.of(
|
||||
(jsonDecode(prefs.getString(SharedPrefKeys.tokens) ?? '{}')
|
||||
as Map<String, dynamic>)
|
||||
(jsonDecode(prefs.getString(SharedPrefKeys.tokens) ??
|
||||
'{"lemmy.ml":{}}') as Map<String, dynamic>)
|
||||
?.map(
|
||||
(k, e) => MapEntry(
|
||||
k,
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
final moreIcon =
|
||||
(Platform.isIOS || Platform.isMacOS) ? Icons.more_horiz : Icons.more_vert;
|
|
@ -105,6 +105,7 @@ class CommentSection extends HookWidget {
|
|||
)
|
||||
else
|
||||
for (final com in comments) Comment(com, postCreatorId: postCreatorId),
|
||||
SizedBox(height: 50),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import '../pages/full_post.dart';
|
|||
import '../url_launcher.dart';
|
||||
import '../util/extensions/api.dart';
|
||||
import '../util/goto.dart';
|
||||
import '../util/more_icon.dart';
|
||||
import 'bottom_modal.dart';
|
||||
import 'fullscreenable_image.dart';
|
||||
import 'info_table_popup.dart';
|
||||
|
@ -226,7 +227,7 @@ class Post extends HookWidget {
|
|||
children: [
|
||||
IconButton(
|
||||
onPressed: () => showMoreMenu(context, post),
|
||||
icon: Icon(Icons.more_vert),
|
||||
icon: Icon(moreIcon),
|
||||
iconSize: 24,
|
||||
padding: EdgeInsets.all(0),
|
||||
visualDensity: VisualDensity.compact,
|
||||
|
|
Loading…
Reference in New Issue