Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Revise theming (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
shilangyu authored Feb 9, 2021
1 parent 60ff6f7 commit b1dad4d
Show file tree
Hide file tree
Showing 33 changed files with 957 additions and 1,337 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
## Unreleased

Lemmur is now available on the [play store](https://play.google.com/store/apps/details?id=com.krawieck.lemmur) and [f-droid](https://f-droid.org/packages/com.krawieck.lemmur)

### Changed

- Posts with large amount of text are now truncated in infinite scroll views
- Changed image viewer dismissal to be more fun. The image now also moves on the x axis, changes scale and rotates a bit for more user enjoyment

### Fixed

- Fixed issue where the "About lemmur" tile would not appear on Windows/Linux
- Added a bigger bottom margin in the comment section to prevent the floating action button from covering the last comment

## v0.2.2 - 2021-02-03

Minimum Lemmy version supported: `v0.9.4`
Expand Down
42 changes: 4 additions & 38 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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';
Expand All @@ -14,6 +13,7 @@ import 'pages/profile_tab.dart';
import 'pages/search_tab.dart';
import 'stores/accounts_store.dart';
import 'stores/config_store.dart';
import 'theme.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -45,51 +45,17 @@ class MyApp extends HookWidget {
@override
Widget build(BuildContext context) {
final configStore = useConfigStore();
final maybeAmoledColor = configStore.amoledDarkMode ? Colors.black : null;

return MaterialApp(
title: 'Lemmur',
title: 'lemmur',
themeMode: configStore.theme,
darkTheme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: maybeAmoledColor,
backgroundColor: maybeAmoledColor,
canvasColor: maybeAmoledColor,
cardColor: maybeAmoledColor,
splashColor: maybeAmoledColor,
),
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
),
darkTheme: configStore.amoledDarkMode ? amoledTheme : darkTheme,
theme: lightTheme,
home: const MyHomePage(),
);
}
}

class TemporarySearchTab extends HookWidget {
const TemporarySearchTab();

@override
Widget build(BuildContext context) {
final accStore = useAccountsStore();
return ListView(
children: [
const ListTile(
title: Center(
child: Text('🚧 this tab is still under construction 🚧\n'
'but you can open your instances in a browser '
' for missing functionality')),
),
const Divider(),
for (final inst in accStore.instances)
ListTile(
title: Text(inst),
onTap: () => ul.launch('https://$inst/'),
)
],
);
}
}

class MyHomePage extends HookWidget {
const MyHomePage();

Expand Down
205 changes: 74 additions & 131 deletions lib/pages/add_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:url_launcher/url_launcher.dart' as ul;

import '../hooks/delayed_loading.dart';
import '../hooks/stores.dart';
import '../widgets/bottom_modal.dart';
import '../widgets/fullscreenable_image.dart';
import '../widgets/radio_picker.dart';
import 'add_instance.dart';

/// A modal where an account can be added for a given instance
Expand All @@ -22,62 +22,21 @@ class AddAccountPage extends HookWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);

final usernameController = useTextEditingController();
final passwordController = useTextEditingController();
useValueListenable(usernameController);
useValueListenable(passwordController);
final usernameController = useListenable(useTextEditingController());
final passwordController = useListenable(useTextEditingController());
final accountsStore = useAccountsStore();

final loading = useDelayedLoading();
final selectedInstance = useState(instanceHost);
final icon = useState<String>(null);

useEffect(() {
LemmyApiV2(selectedInstance.value)
.run(GetSite())
.then((site) => icon.value = site.siteView.site.icon);
return null;
}, [selectedInstance.value]);

/// show a modal with a list of instance checkboxes
selectInstance() async {
final val = await showModalBottomSheet<String>(
backgroundColor: Colors.transparent,
isScrollControlled: true,
context: context,
builder: (context) => BottomModal(
title: 'select instance',
child: Column(children: [
for (final i in accountsStore.instances)
RadioListTile<String>(
value: i,
groupValue: selectedInstance.value,
onChanged: (val) {
Navigator.of(context).pop(val);
},
title: Text(i),
),
ListTile(
leading: const Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.add),
),
title: const Text('Add instance'),
onTap: () async {
final val = await showCupertinoModalPopup<String>(
context: context,
builder: (context) => AddInstancePage(),
);
Navigator.of(context).pop(val);
},
),
]),
),
);
if (val != null) {
selectedInstance.value = val;
}
}

handleOnAdd() async {
try {
loading.start();
Expand All @@ -99,107 +58,91 @@ class AddAccountPage extends HookWidget {
key: scaffoldKey,
appBar: AppBar(
leading: const CloseButton(),
actionsIconTheme: theme.iconTheme,
iconTheme: theme.iconTheme,
textTheme: theme.textTheme,
brightness: theme.brightness,
centerTitle: true,
title: const Text('Add account'),
backgroundColor: theme.canvasColor,
shadowColor: Colors.transparent,
),
body: Padding(
body: ListView(
padding: const EdgeInsets.all(15),
child: ListView(
children: [
if (icon.value == null)
const SizedBox(height: 150)
else
SizedBox(
height: 150,
child: FullscreenableImage(
url: icon.value,
child: CachedNetworkImage(
imageUrl: icon.value,
errorWidget: (_, __, ___) => const SizedBox.shrink(),
),
children: [
if (icon.value == null)
const SizedBox(height: 150)
else
SizedBox(
height: 150,
child: FullscreenableImage(
url: icon.value,
child: CachedNetworkImage(
imageUrl: icon.value,
errorWidget: (_, __, ___) => const SizedBox.shrink(),
),
),
FlatButton(
onPressed: selectInstance,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
RadioPicker<String>(
title: 'select instance',
values: accountsStore.instances.toList(),
groupValue: selectedInstance.value,
onChanged: (value) => selectedInstance.value = value,
buttonBuilder: (context, displayValue, onPressed) => TextButton(
onPressed: onPressed,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(selectedInstance.value),
Text(displayValue),
const Icon(Icons.arrow_drop_down),
],
),
),
// TODO: add support for password managers
TextField(
autofocus: true,
controller: usernameController,
decoration: InputDecoration(
isDense: true,
contentPadding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
labelText: 'Username or email',
),
),
const SizedBox(height: 5),
TextField(
controller: passwordController,
obscureText: true,
decoration: InputDecoration(
isDense: true,
contentPadding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
labelText: 'Password',
),
),
RaisedButton(
color: theme.accentColor,
padding: const EdgeInsets.all(0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
onPressed: usernameController.text.isEmpty ||
passwordController.text.isEmpty
? null
: loading.pending
? () {}
: handleOnAdd,
child: !loading.loading
? const Text('Sign in')
: SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(theme.canvasColor),
),
),
),
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
trailing: ListTile(
leading: const Padding(
padding: EdgeInsets.all(8),
child: Icon(Icons.add),
),
onPressed: () {
ul.launch('https://${selectedInstance.value}/login');
title: const Text('Add instance'),
onTap: () async {
final value = await showCupertinoModalPopup<String>(
context: context,
builder: (context) => AddInstancePage(),
);
Navigator.of(context).pop(value);
},
child: const Text('Register'),
),
],
),
),
// TODO: add support for password managers
TextField(
autofocus: true,
controller: usernameController,
decoration: const InputDecoration(labelText: 'Username or email'),
),
const SizedBox(height: 5),
TextField(
controller: passwordController,
obscureText: true,
decoration: const InputDecoration(labelText: 'Password'),
),
ElevatedButton(
onPressed: usernameController.text.isEmpty ||
passwordController.text.isEmpty
? null
: loading.pending
? () {}
: handleOnAdd,
child: !loading.loading
? const Text('Sign in')
: SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(theme.canvasColor),
),
),
),
TextButton(
onPressed: () {
ul.launch('https://${selectedInstance.value}/login');
},
child: const Text('Register'),
),
],
),
);
}
Expand Down
21 changes: 2 additions & 19 deletions lib/pages/add_instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,7 @@ class AddInstancePage extends HookWidget {
return Scaffold(
key: scaffoldKey,
appBar: AppBar(
backgroundColor: theme.scaffoldBackgroundColor,
brightness: theme.brightness,
shadowColor: Colors.transparent,
iconTheme: theme.iconTheme,
centerTitle: true,
leading: const CloseButton(),
actionsIconTheme: theme.iconTheme,
textTheme: theme.textTheme,
title: const Text('Add instance'),
),
body: ListView(
Expand Down Expand Up @@ -107,13 +100,7 @@ class AddInstancePage extends HookWidget {
autofocus: true,
controller: instanceController,
autocorrect: false,
decoration: InputDecoration(
isDense: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
labelText: 'instance url',
),
decoration: const InputDecoration(labelText: 'instance url'),
),
),
),
Expand All @@ -122,11 +109,7 @@ class AddInstancePage extends HookWidget {
padding: const EdgeInsets.symmetric(horizontal: 15),
child: SizedBox(
height: 40,
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
color: theme.accentColor,
child: ElevatedButton(
onPressed: isSite.value == true ? handleOnAdd : null,
child: !debounce.loading
? const Text('Add')
Expand Down
5 changes: 1 addition & 4 deletions lib/pages/communities_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ class CommunitiesListPage extends StatelessWidget {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
brightness: theme.brightness,
title: Text(title, style: theme.textTheme.headline6),
centerTitle: true,
backgroundColor: theme.cardColor,
iconTheme: theme.iconTheme,
title: Text(title),
),
body: SortableInfiniteList<CommunityView>(
fetcher: fetcher,
Expand Down
Loading

0 comments on commit b1dad4d

Please sign in to comment.