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 _brightness = Brightness.light;
|
||||||
Brightness get brightness => _brightness;
|
Brightness get brightness => _brightness;
|
||||||
Future<void> setBrightness(Brightness v) async {
|
Future<void> toggleBrightness() async {
|
||||||
// TODO: Save
|
// TODO: Save
|
||||||
_brightness = v;
|
_brightness =
|
||||||
|
_brightness == Brightness.dark ? Brightness.light : Brightness.dark;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ class CommonScaffold extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
switch (Provider.of<ThemeModel>(context).theme) {
|
final theme = Provider.of<ThemeModel>(context);
|
||||||
|
|
||||||
|
switch (theme.theme) {
|
||||||
case AppThemeType.cupertino:
|
case AppThemeType.cupertino:
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
@ -30,6 +32,7 @@ class CommonScaffold extends StatelessWidget {
|
|||||||
default:
|
default:
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
brightness: theme.brightness,
|
||||||
title: title,
|
title: title,
|
||||||
actions: [
|
actions: [
|
||||||
if (action != null) action,
|
if (action != null) action,
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:git_touch/models/notification.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/scaffolds/list_stateful.dart';
|
||||||
import 'package:git_touch/utils/utils.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:git_touch/widgets/app_bar_title.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import '../widgets/event_item.dart';
|
import '../widgets/event_item.dart';
|
||||||
@ -51,6 +53,17 @@ class NewsScreenState extends State<NewsScreen> {
|
|||||||
Widget build(context) {
|
Widget build(context) {
|
||||||
return ListStatefulScaffold<EventPayload, int>(
|
return ListStatefulScaffold<EventPayload, int>(
|
||||||
title: AppBarTitle('News'),
|
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),
|
itemBuilder: (payload) => EventItem(payload),
|
||||||
onRefresh: fetchEvents,
|
onRefresh: fetchEvents,
|
||||||
onLoadMore: (page) => fetchEvents(page),
|
onLoadMore: (page) => fetchEvents(page),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user