Skip to content
Snippets Groups Projects
Commit a6c02fcf authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '1-create-initial-empty-application' into 'master'

Resolve "Create initial empty application"

Closes #1

See merge request !1
parents e7e3ef86 3fd192ad
Branches
Tags Release_0.0.1_1
1 merge request!1Resolve "Create initial empty application"
Pipeline #4834 passed
Showing
with 783 additions and 0 deletions
Création de l'application minimale vide.
Assistant Stop Motion
\ No newline at end of file
Assistant Stop Motion
\ No newline at end of file
Assistant Stop Motion
\ No newline at end of file
AuthorName: 'Benoît Harrault'
Categories:
- Multimedia
Name: Stop Motion assistant
AutoName: stopmotion
License: GPL-3.0-only
WebSite: 'https://git.harrault.fr/android/org.benoitharrault.stopmotion'
SourceCode: 'https://git.harrault.fr/android/org.benoitharrault.stopmotion'
IssueTracker: 'https://git.harrault.fr/android/org.benoitharrault.stopmotion/issues'
Changelog: 'https://git.harrault.fr/android/org.benoitharrault.stopmotion/-/tags'
Summary: Your stop motion movie assistant
Description: |
Your stop motion movie assistant.
RepoType: git
Repo: 'https://git.harrault.fr/android/org.benoitharrault.stopmotion.git'
FdroidAppUrl: 'https://f-droid.org/fr/packages/org.benoitharrault.stopmotion/'
#! /bin/bash
# Check dependencies
command -v inkscape >/dev/null 2>&1 || { echo >&2 "I require inkscape but it's not installed. Aborting."; exit 1; }
command -v scour >/dev/null 2>&1 || { echo >&2 "I require scour but it's not installed. Aborting."; exit 1; }
command -v optipng >/dev/null 2>&1 || { echo >&2 "I require optipng but it's not installed. Aborting."; exit 1; }
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
BASE_DIR="$(dirname "${CURRENT_DIR}")"
SOURCE_ICON="${CURRENT_DIR}/icon.svg"
SOURCE_FASTLANE="${CURRENT_DIR}/featureGraphic.svg"
SOURCE_LAUNCH_IMAGE="${CURRENT_DIR}/icon.svg"
OPTIPNG_OPTIONS="-preserve -quiet -o7"
if [ ! -f "${SOURCE_ICON}" ]; then
echo "Missing file: ${SOURCE_ICON}"
fi
if [ ! -f "${SOURCE_FASTLANE}" ]; then
echo "Missing file: ${SOURCE_FASTLANE}"
fi
if [ ! -f "${SOURCE_LAUNCH_IMAGE}" ]; then
echo "Missing file: ${SOURCE_LAUNCH_IMAGE}"
fi
function optimize_svg() {
SVG="$1"
cp ${SVG} ${SVG}.tmp
scour \
--remove-descriptive-elements \
--enable-id-stripping \
--enable-viewboxing \
--enable-comment-stripping \
--nindent=4 \
--quiet \
-i ${SVG}.tmp \
-o ${SVG}
rm ${SVG}.tmp
}
# optimize source svg files
optimize_svg ${SOURCE_ICON}
optimize_svg ${SOURCE_FASTLANE}
optimize_svg ${SOURCE_LAUNCH_IMAGE}
# build icons
function build_application_icon() {
ICON_SIZE="$1"
TARGET="$2"
echo "Building ${TARGET}"
TARGET_PNG="${TARGET}.png"
inkscape \
--export-width=${ICON_SIZE} \
--export-height=${ICON_SIZE} \
--export-filename=${TARGET_PNG} \
${SOURCE_ICON}
optipng ${OPTIPNG_OPTIONS} ${TARGET_PNG}
}
# build fastlane image
function build_fastlane_image() {
WIDTH="$1"
HEIGHT="$2"
TARGET="$3"
echo "Building ${TARGET}"
TARGET_PNG="${TARGET}.png"
inkscape \
--export-width=${WIDTH} \
--export-height=${HEIGHT} \
--export-filename=${TARGET_PNG} \
${SOURCE_FASTLANE}
optipng ${OPTIPNG_OPTIONS} ${TARGET_PNG}
}
# build launch images (splash screen)
function build_launch_image() {
ICON_SIZE="$1"
TARGET="$2"
echo "Building ${TARGET}"
TARGET_PNG="${TARGET}.png"
inkscape \
--export-width=${ICON_SIZE} \
--export-height=${ICON_SIZE} \
--export-filename=${TARGET_PNG} \
${SOURCE_LAUNCH_IMAGE}
optipng ${OPTIPNG_OPTIONS} ${TARGET_PNG}
}
build_application_icon 72 ${BASE_DIR}/android/app/src/main/res/mipmap-hdpi/ic_launcher
build_application_icon 48 ${BASE_DIR}/android/app/src/main/res/mipmap-mdpi/ic_launcher
build_application_icon 96 ${BASE_DIR}/android/app/src/main/res/mipmap-xhdpi/ic_launcher
build_application_icon 144 ${BASE_DIR}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher
build_application_icon 192 ${BASE_DIR}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher
build_application_icon 512 ${BASE_DIR}/fastlane/metadata/android/en-US/images/icon
build_launch_image 72 ${BASE_DIR}/android/app/src/main/res/mipmap-hdpi/launch_image
build_launch_image 48 ${BASE_DIR}/android/app/src/main/res/mipmap-mdpi/launch_image
build_launch_image 96 ${BASE_DIR}/android/app/src/main/res/mipmap-xhdpi/launch_image
build_launch_image 144 ${BASE_DIR}/android/app/src/main/res/mipmap-xxhdpi/launch_image
build_launch_image 192 ${BASE_DIR}/android/app/src/main/res/mipmap-xxxhdpi/launch_image
build_fastlane_image 1024 500 ${BASE_DIR}/fastlane/metadata/android/en-US/images/featureGraphic
<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 100 100" version="1.1" viewBox="0 0 1024 500" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><rect width="1024" height="500" rx="0" ry="0" fill="#977cff"/></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 28.747 28.747" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="filter6206-7" x="-.072" y="-.072" width="1.144" height="1.144" color-interpolation-filters="sRGB">
<feGaussianBlur stdDeviation="0.658125"/>
</filter>
</defs>
<g transform="translate(0 -1093.8)">
<path transform="matrix(1.0781 0 0 1.0641 -.093733 2.7509)" d="m4.4177 1028.2v1.6051h-1.6052v18.192h1.6052v2.1402h18.192v-2.1402h2.1402v-18.192h-2.1402v-1.6051z" fill="#1a237e" filter="url(#filter6206-7)" opacity=".2"/>
<rect x="2.9987" y="1096.8" width="22.749" height="22.749" rx="1.1973" ry="1.1974" fill="#673ab7"/>
<g transform="translate(-22.32 1056.5)">
<path d="m0 0h51.2v51.2h-51.2z" fill="none" stroke-width="1.0667"/>
<g transform="matrix(.33601 0 0 .33601 1.5296 73.043)">
<path d="m0 0h51.2v51.2h-51.2z" fill="none" stroke-width="1.0667"/>
</g>
<g transform="matrix(.37187 0 0 .37187 38.802 63.239)">
<path d="m0 0h51.2v51.2h-51.2z" fill="none" stroke-width="1.0667"/>
<g transform="matrix(2.6891 0 0 2.6891 -82.906 -48.45)">
<path d="m0 0h51.2v51.2h-51.2z" fill="none" stroke-width="1.0667"/>
</g>
</g>
</g>
<path d="m4.1958 1096.8c-0.66332 0-1.1979 0.5346-1.1979 1.1979v0.3334c0-0.6634 0.53459-1.1979 1.1979-1.1979h20.354c0.66332 0 1.1979 0.5345 1.1979 1.1979v-0.3334c0-0.6633-0.5346-1.1979-1.1979-1.1979z" fill="#fff" opacity=".2"/>
<rect x="128" y="546.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="128" y="631.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="128" y="674.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="128" y="589.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="128" y="717.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="213.33" y="546.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="213.33" y="631.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="213.33" y="674.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="213.33" y="589.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="213.33" y="717.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="298.67" y="546.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="298.67" y="631.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="298.67" y="674.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="298.67" y="589.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="298.67" y="717.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="170.67" y="546.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="170.67" y="631.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="170.67" y="674.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="170.67" y="589.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="170.67" y="717.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="256" y="546.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="256" y="631.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="256" y="674.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="256" y="589.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="256" y="717.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="128" y="759.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="213.33" y="759.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="298.67" y="759.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="170.67" y="759.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="256" y="759.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="341.33" y="589.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="341.33" y="631.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="341.33" y="717.19" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="341.33" y="546.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="341.33" y="674.52" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="341.33" y="759.85" width="42.667" height="42.667" fill="none" stroke-width="1.0667"/>
<rect x="160" y="578.52" width="192" height="192" fill="none" stroke-width="1.0667"/>
<g transform="matrix(.37344 0 0 .37344 4.7333 1097.4)">
<path d="m0 0h51.2v51.2h-51.2z" fill="none" stroke-width="1.0667"/>
</g>
<g transform="matrix(.36471 0 0 .36471 5.1356 1097.4)">
<path d="m0 0h51.2v51.2h-51.2z" fill="none" stroke-width="1.0667"/>
</g>
<g transform="matrix(.41585 0 0 .41585 84.325 1055.9)">
<g transform="matrix(.062269 0 0 .062269 -28.238 185.29)">
<g transform="matrix(38.618 0 0 38.618 14724 -13542)">
<g transform="matrix(.71436 0 0 .71436 -400.52 188.34)">
<path d="m1293.2-120.67c-181.75 0.2763-511.18 0.13525-699.05 0.13998-2.3216 10.413-3.593 21.251-3.593 32.384v114c207.65 0.73695 494.72 0.38136 706.23 0.3733v-114.37c0-11.18-1.2522-22.07-3.593-32.523zm-458.69 295.56c-78.385-4e-3 -158.85 0.17892-243.95 0.55995v138.63c286.34-0.39317 421.73-0.13827 706.23-0.32664v-137.75c-163.2-0.53005-311.22-1.1113-462.28-1.1199z" opacity="0" stroke-width="1.4932"/>
</g>
</g>
</g>
</g>
<path d="m24.549 1119.5c0.66325 0 1.1979-0.5346 1.1979-1.1979v-0.3333c0 0.6632-0.53461 1.1978-1.1979 1.1978h-20.354c-0.66325 0-1.1979-0.5346-1.1979-1.1978v0.3333c0 0.6633 0.53461 1.1979 1.1979 1.1979z" fill="#1a237e" opacity=".2"/>
</g>
<path d="m21.141 11.764a1.1513 1.1513 0 0 0-1.0798-0.89569c-0.95204 0.0038-1.9043-0.0075-2.8564 0.0065a0.65653 0.65653 0 0 0-0.13626-0.42804c-0.38572-0.49919-0.75993-1.0074-1.1479-1.5046a0.59422 0.59422 0 0 0-0.46814-0.23494c-0.75192-1e-3 -1.5038 0.00401-2.2557 5.128e-4a0.56532 0.56532 0 0 0-0.45536 0.22292c-0.38397 0.50019-0.76394 1.0034-1.1454 1.5056a0.66926 0.66926 0 0 0-0.14077 0.43356c-0.24772-0.0055-0.49543-0.0027-0.74315-0.0013-1.21e-4 -0.02042-6.77e-4 -0.04078-1e-3 -0.06118v-0.1958h-0.11981c-0.0018-0.14287-0.0011-0.28595-0.0019-0.42881-0.53324-3e-3 -1.0668-0.0023-1.6-0.0043-0.00261 0.14436 0.00209 0.28871-0.00334 0.43306h-0.12164c-9.324e-4 0.0317-6.066e-4 0.06344 0 0.09521v0.1633l-0.0048-3.97e-4a1.1764 1.1764 0 0 0-1.2235 0.90684 0.47582 0.47582 0 0 0-0.52749 0.48843 0.48424 0.48424 0 0 0 0.51798 0.47765q0.00115 2.4537-7.529e-4 4.907a2.7779 2.7779 0 0 0 0.028558 0.53025 1.2133 1.2133 0 0 0 1.1602 0.93626c0.8516-0.0036 1.703-2e-3 2.5546-0.0013 0.06838 0.0032 0.14778-0.01828 0.2044 0.03181a4.6428 4.6428 0 0 0 5.431 0.03206 0.2352 0.2352 0 0 1 0.13-0.06337c0.96682-0.0045 1.9334 0.0016 2.9002-0.0027a1.1953 1.1953 0 0 0 1.1159-1.187c2e-3 -1.727-0.0036-3.454 0.0025-5.181a0.49917 0.49917 0 0 0 0.48141-0.42907 0.49272 0.49272 0 0 0-0.49343-0.55153zm-2.5192 3.8332a4.1985 4.1985 0 0 1-0.95655 2.4641 4.3163 4.3163 0 0 1-7.2952-0.94127 4.1969 4.1969 0 0 1-0.37496-2.002 4.3722 4.3722 0 0 1 1.8755-3.2777 4.3074 4.3074 0 0 1 6.7512 3.7568zm1.2326-2.6122a0.73486 0.73486 0 1 1 0.17909-0.82029 0.72723 0.72723 0 0 1-0.17909 0.82029z" stroke-width=".23306"/>
<path class="cls-1" d="m14.303 11.474a3.9178 3.9178 0 1 0 3.9178 3.9178 3.9178 3.9178 0 0 0-3.9178-3.9178zm2.3572 6.275a3.3312 3.3312 0 1 1 0.97733-2.3572 3.3219 3.3219 0 0 1-0.97733 2.3572zm-0.13841-4.5761a3.1379 3.1379 0 1 0 0.9191 2.2188 3.1269 3.1269 0 0 0-0.9191-2.2188zm-0.55365 2.3446-2.5547 1.4778a0.1401 0.1401 0 0 1-0.14516 0 0.14179 0.14179 0 0 1-0.07259-0.12575v-2.9522a0.14179 0.14179 0 0 1 0.07259-0.12912 0.1401 0.1401 0 0 1 0.14516 0l2.5547 1.4778a0.14516 0.14516 0 0 1 0 0.25319z" fill-rule="evenodd" stroke-width=".084398"/>
</svg>
class DefaultSettings {
static const int defaultDummyValue = 20;
static const List<int> allowedDummyValues = [
10,
defaultDummyValue,
30,
];
}
import 'package:flutter/material.dart';
/// Colors from Tailwind CSS (v3.0) - June 2022
///
/// https://tailwindcss.com/docs/customizing-colors
const int _primaryColor = 0xFF6366F1;
const MaterialColor primarySwatch = MaterialColor(_primaryColor, <int, Color>{
50: Color(0xFFEEF2FF), // indigo-50
100: Color(0xFFE0E7FF), // indigo-100
200: Color(0xFFC7D2FE), // indigo-200
300: Color(0xFFA5B4FC), // indigo-300
400: Color(0xFF818CF8), // indigo-400
500: Color(_primaryColor), // indigo-500
600: Color(0xFF4F46E5), // indigo-600
700: Color(0xFF4338CA), // indigo-700
800: Color(0xFF3730A3), // indigo-800
900: Color(0xFF312E81), // indigo-900
});
const int _textColor = 0xFF64748B;
const MaterialColor textSwatch = MaterialColor(_textColor, <int, Color>{
50: Color(0xFFF8FAFC), // slate-50
100: Color(0xFFF1F5F9), // slate-100
200: Color(0xFFE2E8F0), // slate-200
300: Color(0xFFCBD5E1), // slate-300
400: Color(0xFF94A3B8), // slate-400
500: Color(_textColor), // slate-500
600: Color(0xFF475569), // slate-600
700: Color(0xFF334155), // slate-700
800: Color(0xFF1E293B), // slate-800
900: Color(0xFF0F172A), // slate-900
});
const Color errorColor = Color(0xFFDC2626); // red-600
final ColorScheme lightColorScheme = ColorScheme.light(
primary: primarySwatch.shade500,
secondary: primarySwatch.shade500,
onSecondary: Colors.white,
error: errorColor,
background: textSwatch.shade200,
onBackground: textSwatch.shade500,
onSurface: textSwatch.shade500,
surface: textSwatch.shade50,
surfaceVariant: Colors.white,
shadow: textSwatch.shade900.withOpacity(.1),
);
final ColorScheme darkColorScheme = ColorScheme.dark(
primary: primarySwatch.shade500,
secondary: primarySwatch.shade500,
onSecondary: Colors.white,
error: errorColor,
background: const Color(0xFF171724),
onBackground: textSwatch.shade400,
onSurface: textSwatch.shade300,
surface: const Color(0xFF262630),
surfaceVariant: const Color(0xFF282832),
shadow: textSwatch.shade900.withOpacity(.2),
);
final ThemeData lightTheme = ThemeData(
colorScheme: lightColorScheme,
fontFamily: 'Nunito',
textTheme: TextTheme(
displayLarge: TextStyle(
color: textSwatch.shade700,
fontFamily: 'Nunito',
),
displayMedium: TextStyle(
color: textSwatch.shade600,
fontFamily: 'Nunito',
),
displaySmall: TextStyle(
color: textSwatch.shade500,
fontFamily: 'Nunito',
),
headlineLarge: TextStyle(
color: textSwatch.shade700,
fontFamily: 'Nunito',
),
headlineMedium: TextStyle(
color: textSwatch.shade600,
fontFamily: 'Nunito',
),
headlineSmall: TextStyle(
color: textSwatch.shade500,
fontFamily: 'Nunito',
),
titleLarge: TextStyle(
color: textSwatch.shade700,
fontFamily: 'Nunito',
),
titleMedium: TextStyle(
color: textSwatch.shade600,
fontFamily: 'Nunito',
),
titleSmall: TextStyle(
color: textSwatch.shade500,
fontFamily: 'Nunito',
),
bodyLarge: TextStyle(
color: textSwatch.shade700,
fontFamily: 'Nunito',
),
bodyMedium: TextStyle(
color: textSwatch.shade600,
fontFamily: 'Nunito',
),
bodySmall: TextStyle(
color: textSwatch.shade500,
fontFamily: 'Nunito',
),
labelLarge: TextStyle(
color: textSwatch.shade700,
fontFamily: 'Nunito',
),
labelMedium: TextStyle(
color: textSwatch.shade600,
fontFamily: 'Nunito',
),
labelSmall: TextStyle(
color: textSwatch.shade500,
fontFamily: 'Nunito',
),
),
);
final ThemeData darkTheme = lightTheme.copyWith(
colorScheme: darkColorScheme,
textTheme: TextTheme(
displayLarge: TextStyle(
color: textSwatch.shade200,
fontFamily: 'Nunito',
),
displayMedium: TextStyle(
color: textSwatch.shade300,
fontFamily: 'Nunito',
),
displaySmall: TextStyle(
color: textSwatch.shade400,
fontFamily: 'Nunito',
),
headlineLarge: TextStyle(
color: textSwatch.shade200,
fontFamily: 'Nunito',
),
headlineMedium: TextStyle(
color: textSwatch.shade300,
fontFamily: 'Nunito',
),
headlineSmall: TextStyle(
color: textSwatch.shade400,
fontFamily: 'Nunito',
),
titleLarge: TextStyle(
color: textSwatch.shade200,
fontFamily: 'Nunito',
),
titleMedium: TextStyle(
color: textSwatch.shade300,
fontFamily: 'Nunito',
),
titleSmall: TextStyle(
color: textSwatch.shade400,
fontFamily: 'Nunito',
),
bodyLarge: TextStyle(
color: textSwatch.shade200,
fontFamily: 'Nunito',
),
bodyMedium: TextStyle(
color: textSwatch.shade300,
fontFamily: 'Nunito',
),
bodySmall: TextStyle(
color: textSwatch.shade400,
fontFamily: 'Nunito',
),
labelLarge: TextStyle(
color: textSwatch.shade200,
fontFamily: 'Nunito',
),
labelMedium: TextStyle(
color: textSwatch.shade300,
fontFamily: 'Nunito',
),
labelSmall: TextStyle(
color: textSwatch.shade400,
fontFamily: 'Nunito',
),
),
);
final ThemeData appTheme = darkTheme;
import 'package:hydrated_bloc/hydrated_bloc.dart';
class BottomNavCubit extends HydratedCubit<int> {
BottomNavCubit() : super(0);
int pagesCount = 2;
void updateIndex(int index) {
if (isIndexAllowed(index)) {
emit(index);
} else {
goToHomePage();
}
}
bool isIndexAllowed(int index) {
return (index >= 0) && (index < pagesCount);
}
void goToHomePage() => emit(0);
@override
int? fromJson(Map<String, dynamic> json) {
return 0;
}
@override
Map<String, dynamic>? toJson(int state) {
return <String, int>{'pageIndex': state};
}
}
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:stopmotion/config/default_settings.dart';
part 'settings_state.dart';
class SettingsCubit extends HydratedCubit<SettingsState> {
SettingsCubit() : super(const SettingsState());
int getDummyValue() {
return state.dummyValue ?? DefaultSettings.defaultDummyValue;
}
void setValues({
int? dummyValue,
}) {
emit(SettingsState(
dummyValue: dummyValue ?? state.dummyValue,
));
}
@override
SettingsState? fromJson(Map<String, dynamic> json) {
int dummyValue = json['dummyValue'] as int;
return SettingsState(
dummyValue: dummyValue,
);
}
@override
Map<String, dynamic>? toJson(SettingsState state) {
return <String, dynamic>{
'dummyValue': state.dummyValue ?? DefaultSettings.defaultDummyValue,
};
}
}
part of 'settings_cubit.dart';
@immutable
class SettingsState extends Equatable {
const SettingsState({
this.dummyValue,
});
final int? dummyValue;
@override
List<dynamic> get props => <dynamic>[
dummyValue,
];
Map<String, dynamic> get values => <String, dynamic>{
'dummyValue': dummyValue,
};
}
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hive/hive.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:path_provider/path_provider.dart';
import 'package:stopmotion/config/theme.dart';
import 'package:stopmotion/cubit/bottom_nav_cubit.dart';
import 'package:stopmotion/cubit/settings_cubit.dart';
import 'package:stopmotion/ui/skeleton.dart';
void main() async {
/// Initialize packages
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
final Directory tmpDir = await getTemporaryDirectory();
Hive.init(tmpDir.toString());
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: tmpDir,
);
runApp(
EasyLocalization(
path: 'assets/translations',
supportedLocales: const <Locale>[
Locale('en'),
Locale('fr'),
],
fallbackLocale: const Locale('en'),
useFallbackTranslations: true,
child: const MyApp(),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider<BottomNavCubit>(create: (context) => BottomNavCubit()),
BlocProvider<SettingsCubit>(create: (context) => SettingsCubit()),
],
child: MaterialApp(
title: 'Stop Motion',
theme: appTheme,
home: const SkeletonScreen(),
// Localization stuff
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
debugShowCheckedModeBanner: false,
),
);
}
}
import 'package:flutter/material.dart';
import 'package:unicons/unicons.dart';
class ScreenHome extends StatelessWidget {
const ScreenHome({super.key});
static Icon navBarIcon = const Icon(UniconsLine.home);
static String navBarText = 'bottom_nav_home';
@override
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.background,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 4),
physics: const BouncingScrollPhysics(),
children: <Widget>[
const SizedBox(height: 8),
const Text('CONTENT'),
const SizedBox(height: 36),
],
),
);
}
}
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:stopmotion/ui/widgets/app_titles.dart';
import 'package:stopmotion/ui/widgets/settings_form.dart';
import 'package:unicons/unicons.dart';
class ScreenSettings extends StatelessWidget {
const ScreenSettings({super.key});
static Icon navBarIcon = const Icon(UniconsLine.setting);
static String navBarText = 'bottom_nav_settings';
@override
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.background,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 4),
physics: const BouncingScrollPhysics(),
children: <Widget>[
SizedBox(height: 8),
AppTitle1(text: tr('settings_title')),
SettingsForm(),
],
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:stopmotion/cubit/bottom_nav_cubit.dart';
import 'package:stopmotion/ui/screens/home.dart';
import 'package:stopmotion/ui/screens/settings.dart';
import 'package:stopmotion/ui/widgets/app_bar.dart';
import 'package:stopmotion/ui/widgets/bottom_nav_bar.dart';
class SkeletonScreen extends StatefulWidget {
const SkeletonScreen({super.key});
@override
State<SkeletonScreen> createState() => _SkeletonScreenState();
}
class _SkeletonScreenState extends State<SkeletonScreen> {
@override
Widget build(BuildContext context) {
List<Widget> pageNavigation = <Widget>[
ScreenHome(),
const ScreenSettings(),
];
return Scaffold(
appBar: StandardAppBar(),
extendBodyBehindAppBar: false,
body: BlocBuilder<BottomNavCubit, int>(
builder: (BuildContext context, int state) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: pageNavigation.elementAt(state),
);
},
),
backgroundColor: Theme.of(context).colorScheme.background,
bottomNavigationBar: BottomNavBar(),
);
}
}
import 'package:flutter/material.dart';
import 'package:stopmotion/ui/widgets/app_titles.dart';
class StandardAppBar extends StatelessWidget implements PreferredSizeWidget {
const StandardAppBar({super.key});
@override
Widget build(BuildContext context) {
return AppBar(
title: const AppTitle(text: 'app_name'),
actions: [],
);
}
@override
Size get preferredSize => const Size.fromHeight(50);
}
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
class AppTitle extends StatelessWidget {
const AppTitle({super.key, required this.text});
final String text;
@override
Widget build(BuildContext context) {
return Text(
tr(text),
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.headlineLarge!.apply(fontWeightDelta: 2),
);
}
}
class AppTitle1 extends StatelessWidget {
const AppTitle1({super.key, required this.text});
final String text;
@override
Widget build(BuildContext context) {
return Text(
text,
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.titleLarge!.apply(fontWeightDelta: 2),
);
}
}
class AppTitle2 extends StatelessWidget {
const AppTitle2({super.key, required this.text});
final String text;
@override
Widget build(BuildContext context) {
return Text(
text,
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.titleMedium!.apply(fontWeightDelta: 2),
);
}
}
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:stopmotion/cubit/bottom_nav_cubit.dart';
import 'package:stopmotion/ui/screens/settings.dart';
import 'package:stopmotion/ui/screens/home.dart';
class BottomNavBar extends StatelessWidget {
const BottomNavBar({super.key});
@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.only(top: 1, right: 4, left: 4),
elevation: 4,
shadowColor: Theme.of(context).colorScheme.shadow,
color: Theme.of(context).colorScheme.surfaceVariant,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
),
child: BlocBuilder<BottomNavCubit, int>(builder: (BuildContext context, int state) {
return BottomNavigationBar(
currentIndex: state,
onTap: (int index) => context.read<BottomNavCubit>().updateIndex(index),
type: BottomNavigationBarType.fixed,
elevation: 0,
backgroundColor: Colors.transparent,
selectedItemColor: Theme.of(context).colorScheme.primary,
unselectedItemColor: Theme.of(context).textTheme.bodySmall!.color,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: ScreenHome.navBarIcon,
label: tr(ScreenHome.navBarText),
),
BottomNavigationBarItem(
icon: ScreenSettings.navBarIcon,
label: tr(ScreenSettings.navBarText),
),
],
);
}),
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment