mirror of
https://github.com/git-touch/git-touch
synced 2025-02-01 08:26:53 +01:00
feat: brightness toggle button
This commit is contained in:
parent
ad7b9f2e27
commit
a7a05bab88
@ -91,9 +91,10 @@ class ThemeModel with ChangeNotifier {
|
||||
|
||||
Brightness _brightness = Brightness.light;
|
||||
Brightness get brightness => _brightness;
|
||||
Future<void> setBrightness(Brightness v) async {
|
||||
Future<void> toggleBrightness() async {
|
||||
// TODO: Save
|
||||
_brightness = v;
|
||||
_brightness =
|
||||
_brightness == Brightness.dark ? Brightness.light : Brightness.dark;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,9 @@ class CommonScaffold extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (Provider.of<ThemeModel>(context).theme) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
switch (theme.theme) {
|
||||
case AppThemeType.cupertino:
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
@ -30,6 +32,7 @@ class CommonScaffold extends StatelessWidget {
|
||||
default:
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
brightness: theme.brightness,
|
||||
title: title,
|
||||
actions: [
|
||||
if (action != null) action,
|
||||
|
@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../widgets/event_item.dart';
|
||||
@ -51,6 +53,17 @@ class NewsScreenState extends State<NewsScreen> {
|
||||
Widget build(context) {
|
||||
return ListStatefulScaffold<EventPayload, int>(
|
||||
title: AppBarTitle('News'),
|
||||
actionBuilder: () {
|
||||
return ActionEntry(
|
||||
iconData:
|
||||
Provider.of<ThemeModel>(context).brightness == Brightness.dark
|
||||
? Ionicons.md_sunny
|
||||
: Ionicons.md_moon,
|
||||
onTap: () {
|
||||
Provider.of<ThemeModel>(context).toggleBrightness();
|
||||
},
|
||||
);
|
||||
},
|
||||
itemBuilder: (payload) => EventItem(payload),
|
||||
onRefresh: fetchEvents,
|
||||
onLoadMore: (page) => fetchEvents(page),
|
||||
|
Loading…
x
Reference in New Issue
Block a user