Skip to content

Commit

Permalink
feat: add typography, theme, fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodexhub committed Jun 29, 2024
1 parent f04b651 commit 6acb577
Show file tree
Hide file tree
Showing 16 changed files with 539 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
23 changes: 23 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PODS:
- Flutter (1.0.0)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS

DEPENDENCIES:
- Flutter (from `Flutter`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.13.0
170 changes: 156 additions & 14 deletions ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
3 changes: 3 additions & 0 deletions ios/Runner.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import 'package:flutter/material.dart';
import 'package:sudoku/counter/counter.dart';
import 'package:sudoku/l10n/l10n.dart';
import 'package:sudoku/theme/theme.dart';

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
appBarTheme: AppBarTheme(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
useMaterial3: true,
),
theme: SudokuTheme.light,
darkTheme: SudokuTheme.dark,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: const CounterPage(),
Expand Down
5 changes: 2 additions & 3 deletions lib/models/sudoku.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class Sudoku extends Equatable {
const Sudoku({required this.blocks});

/// Converts raw data to a [Sudoku] model.
///
///
/// The `generated` list defines the initial state of the puzzle,
/// and the `answer` defines the completed state.
///
///
/// Throws a [SudokuInvalidRawDataException] when validation fails
/// on raw data. The validation checks for 3 things -
/// - Whether the generated and asnswer have same number of items.
Expand Down Expand Up @@ -94,7 +94,6 @@ class Sudoku extends Equatable {
/// List of [Block]s representing the current state of the [Sudoku].
final List<Block> blocks;


/// Gets the dimension of the [Sudoku], i.e., the number of row or column.
///
/// A 3 x 3 Sudoku will have 81 blocks, and dimesion will be 9.
Expand Down
59 changes: 59 additions & 0 deletions lib/theme/theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';

/// Defines [ThemeData] for Sudoku App UI.
class SudokuTheme {
/// Light theme with blue accent
static ThemeData get light {
return ThemeData(
scaffoldBackgroundColor: const Color(0xFFF8F8F8),
appBarTheme: const AppBarTheme(
color: Color(0xFFF8F8F8), // Light background color
),
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF3F51B5), // Blue accent color
),
snackBarTheme: const SnackBarThemeData(
behavior: SnackBarBehavior.floating,
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF3F51B5),
foregroundColor: Colors.white,
elevation: 0,
),
),
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: Color(0xFF3F51B5),
foregroundColor: Colors.white,
),
);
}

/// Dark theme with same blue accent
static ThemeData get dark {
return ThemeData(
scaffoldBackgroundColor: const Color(0xFF212121),
appBarTheme: const AppBarTheme(
color: Color(0xFF212121), // Dark background color
),
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
seedColor: const Color(0xFF3F51B5), // Blue accent color
),
snackBarTheme: const SnackBarThemeData(
behavior: SnackBarBehavior.floating,
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF3F51B5),
foregroundColor: Colors.white,
elevation: 0,
),
),
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: Color(0xFF3F51B5),
foregroundColor: Colors.white,
),
);
}
}
31 changes: 31 additions & 0 deletions lib/typography/font_weights.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/widgets.dart';

/// Defines font weights for Sudoku App UI.
abstract class SudokuFontWeight {
/// [FontWeight] value of `w900`
static const FontWeight black = FontWeight.w900;

/// [FontWeight] value of `w800`
static const FontWeight extraBold = FontWeight.w800;

/// [FontWeight] value of `w700`
static const FontWeight bold = FontWeight.w700;

/// [FontWeight] value of `w600`
static const FontWeight semiBold = FontWeight.w600;

/// [FontWeight] value of `w500`
static const FontWeight medium = FontWeight.w500;

/// [FontWeight] value of `w400`
static const FontWeight regular = FontWeight.w400;

/// [FontWeight] value of `w300`
static const FontWeight light = FontWeight.w300;

/// [FontWeight] value of `w200`
static const FontWeight extraLight = FontWeight.w200;

/// [FontWeight] value of `w100`
static const FontWeight thin = FontWeight.w100;
}
106 changes: 106 additions & 0 deletions lib/typography/text_styles.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'package:flutter/widgets.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:sudoku/typography/typography.dart';

/// Defines [TextStyle]s for Sudoku App UI.
class SudokuTextStyle {
/// Headline 1 Text Style
static TextStyle get headline1 {
return _baseTextStyle.copyWith(
fontSize: 56,
fontWeight: SudokuFontWeight.medium,
);
}

/// Headline 2 Text Style
static TextStyle get headline2 {
return _baseTextStyle.copyWith(
fontSize: 30,
fontWeight: SudokuFontWeight.regular,
);
}

/// Headline 3 Text Style
static TextStyle get headline3 {
return _baseTextStyle.copyWith(
fontSize: 24,
fontWeight: SudokuFontWeight.regular,
);
}

/// Headline 4 Text Style
static TextStyle get headline4 {
return _baseTextStyle.copyWith(
fontSize: 22,
fontWeight: SudokuFontWeight.bold,
);
}

/// Headline 5 Text Style
static TextStyle get headline5 {
return _baseTextStyle.copyWith(
fontSize: 22,
fontWeight: SudokuFontWeight.medium,
);
}

/// Headline 6 Text Style
static TextStyle get headline6 {
return _baseTextStyle.copyWith(
fontSize: 22,
fontWeight: SudokuFontWeight.bold,
);
}

/// Subtitle 1 Text Style
static TextStyle get subtitle1 {
return _baseTextStyle.copyWith(
fontSize: 16,
fontWeight: SudokuFontWeight.bold,
);
}

/// Subtitle 2 Text Style
static TextStyle get subtitle2 {
return _baseTextStyle.copyWith(
fontSize: 14,
fontWeight: SudokuFontWeight.bold,
);
}

/// Body Text 1 Text Style
static TextStyle get bodyText1 {
return _baseTextStyle.copyWith(
fontSize: 18,
fontWeight: SudokuFontWeight.medium,
);
}

/// Body Text 2 Text Style (the default)
static TextStyle get bodyText2 {
return _baseTextStyle.copyWith(
fontSize: 16,
fontWeight: SudokuFontWeight.regular,
);
}

/// Caption Text Style
static TextStyle get caption {
return _baseTextStyle.copyWith(
fontSize: 14,
fontWeight: SudokuFontWeight.regular,
);
}

/// Button Text Style
static TextStyle get button {
return _baseTextStyle.copyWith(
fontSize: 16,
fontWeight: SudokuFontWeight.medium,
);
}

static final _baseTextStyle = GoogleFonts.inter(
fontWeight: SudokuFontWeight.regular,
);
}
2 changes: 2 additions & 0 deletions lib/typography/typography.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'font_weights.dart';
export 'text_styles.dart';
Loading

0 comments on commit 6acb577

Please sign in to comment.