Skip to content

Commit

Permalink
Theming
Browse files Browse the repository at this point in the history
  • Loading branch information
Yustas committed Dec 3, 2024
1 parent 0baec8b commit 13dedfd
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#DB
DB_VERSION=42
DB_VERSION=14
Binary file modified assets/db/mova.db
Binary file not shown.
6 changes: 6 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -444,6 +445,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -556,6 +558,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -566,6 +569,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -611,6 +615,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -621,6 +626,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
28 changes: 3 additions & 25 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mova/themes/material.dart';
import 'package:mova/repository/content.dart';
import 'package:mova/screens/pravopys.dart';
import 'package:logging/logging.dart';
Expand All @@ -25,32 +26,9 @@ class MovaApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
final textTheme = ThemeData().textTheme.copyWith(
// AppTitle
titleLarge: ThemeData().textTheme.titleLarge!.copyWith(fontSize: 20),
// # Heading 1
headlineLarge: ThemeData()
.textTheme
.headlineLarge!
.copyWith(fontSize: 24, fontWeight: FontWeight.bold),
headlineSmall:
ThemeData().textTheme.headlineSmall!.copyWith(fontSize: 24),
bodyMedium: ThemeData().textTheme.bodyMedium!.copyWith(
fontSize: 15,
),
bodySmall: ThemeData().textTheme.bodySmall!.copyWith(fontSize: 16));

return MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
textTheme: textTheme,
/* light theme settings */
),
darkTheme: ThemeData(
brightness: Brightness.dark,
textTheme: textTheme,
/* dark theme settings */
),
theme: themeLight(context),
darkTheme: MaterialTheme.dark(context),
themeMode: ThemeMode.system,
home: const Pravopys(content: homeContent, prevContent: null),
);
Expand Down
1 change: 1 addition & 0 deletions lib/screens/pravopys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class _PravopysState extends State<Pravopys> {
}

return Scaffold(
// backgroundColor: Theme.of(context).colorScheme.surface,
appBar: AppBar(
title: Text(appBarTitle),
titleTextStyle: Theme.of(context).textTheme.titleMedium,
Expand Down
2 changes: 2 additions & 0 deletions lib/styles/markdown.dart → lib/themes/markdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ var stylesheet = MarkdownStyleSheet(
.textTheme
.titleLarge!
.copyWith(fontSize: 24, color: Colors.blue),
listIndent: 15.0,

);
78 changes: 78 additions & 0 deletions lib/themes/material.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';

const Color seedColor = Colors.white;

ColorScheme lightColorScheme(context) {
return ColorScheme.fromSeed(
seedColor: seedColor,
brightness: Brightness.light,
contrastLevel: 0,
dynamicSchemeVariant: DynamicSchemeVariant.neutral
);
}

ThemeData themeLight(BuildContext context) {
return ThemeData(
useMaterial3: true,
colorScheme: lightColorScheme(context),
textTheme: MaterialTheme.textTheme(lightColorScheme(context)),
appBarTheme: AppBarTheme(
backgroundColor: lightColorScheme(context).surface
)
);
}

class MaterialTheme {
static TextTheme textTheme(ColorScheme colorScheme) {
return ThemeData().textTheme.copyWith(
// AppTitle
titleLarge: ThemeData().textTheme.titleLarge!.copyWith(fontSize: 20),
// # Heading 1
headlineLarge: ThemeData()
.textTheme
.headlineLarge!
.copyWith(
fontSize: 34,
fontWeight: FontWeight.w800,
color: colorScheme.onSurface
),
headlineSmall:
ThemeData().textTheme.headlineSmall!.copyWith(fontSize: 24),
bodyMedium: ThemeData().textTheme.bodyMedium!.copyWith(
fontSize: 15,
),
bodySmall: ThemeData().textTheme.bodySmall!.copyWith(fontSize: 16));
}

static ThemeData light(BuildContext context) {
return ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: seedColor,
brightness: Brightness.light,
contrastLevel: 1,
dynamicSchemeVariant: DynamicSchemeVariant.content,
),
textTheme: MaterialTheme.textTheme(lightColorScheme(context)),
// scaffoldBackgroundColor: const Color(0xFF931010),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.white
));
}

static ThemeData dark(BuildContext context) {
return ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: seedColor,
brightness: Brightness.dark,
contrastLevel: -1,
dynamicSchemeVariant: DynamicSchemeVariant.content,
),
textTheme: MaterialTheme.textTheme(lightColorScheme(context)),
// scaffoldBackgroundColor: const Color(0xFF931010),
appBarTheme: const AppBarTheme(
// backgroundColor: Colors.amber
));
}
}
2 changes: 1 addition & 1 deletion lib/widgets/articles_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:mova/repository/content.dart';
import 'package:mova/screens/pravopys.dart';

import '../models/article.dart';
import 'package:mova/styles/markdown.dart';
import 'package:mova/themes//markdown.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

class ArticlesList extends StatefulWidget {
Expand Down
13 changes: 5 additions & 8 deletions lib/widgets/content_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ class ContentList extends StatelessWidget {
}

return Container(
decoration: const BoxDecoration(
color: Color.fromARGB(30, 150, 150, 150),
border: Border(
top: BorderSide(color: Color.fromARGB(70, 150, 150, 150)))),
color: Colors.grey,
// decoration: const BoxDecoration(
// border: Border(
// top: BorderSide(color: Color.fromARGB(70, 150, 150, 150)))),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
child: Container(
padding: const EdgeInsets.all(16.0),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(15.0)),
),
color: Colors.white,
child: ListView.builder(
scrollDirection: Axis.vertical,
itemCount: content.length,
Expand Down
31 changes: 5 additions & 26 deletions lib/widgets/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:mova/utils/controllers.dart';
import 'package:mova/widgets/search.dart';

class Header extends StatefulWidget {
class Header extends StatelessWidget {
const Header(
{super.key,
required this.title,
Expand All @@ -13,29 +13,7 @@ class Header extends StatefulWidget {
final bool searchBar;
final ScrollPositionController scrollController;

@override
State<Header> createState() => _HeaderState(scrollController);
}

class _HeaderState extends State<Header> {

ScrollPosition? scrollPosition;
double? fontSize = 24;
double? height;
TextOverflow? overflow;

void doScroll(ScrollPosition scrollPosition) {
scrollPosition = scrollPosition;
setState(() {
fontSize = scrollPosition.pixels > 0 ? 10 : 24;
height = (scrollPosition.pixels > 0) ? 30 : null;
overflow = (scrollPosition.pixels > 0) ? TextOverflow.ellipsis : null;
});
}

_HeaderState(ScrollPositionController scrollController) {
scrollController.doScroll = doScroll;
}
final double? fontSize = 24;

@override
Widget build(BuildContext context) {
Expand All @@ -46,7 +24,7 @@ class _HeaderState extends State<Header> {
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
child: Text(
widget.title,
title,
style: Theme.of(context).textTheme.headlineLarge,
textAlign: TextAlign.left,
),
Expand All @@ -55,12 +33,13 @@ class _HeaderState extends State<Header> {
const SizedBox(height: 10),
];

if (widget.searchBar) {
if (searchBar) {
children.add(const Search());
children.add(const SizedBox(height: 10));
}

return Container(
color: Theme.of(context).colorScheme.surface,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
children: children,
Expand Down

0 comments on commit 13dedfd

Please sign in to comment.