-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add full screen button, prepare the save folder dialog
- Loading branch information
Ellet
committed
Dec 27, 2023
1 parent
c72ec6a
commit 6ff171e
Showing
17 changed files
with
447 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
import '../../notes/universal/models/m_note.dart'; | ||
|
||
part 'm_note_folder.freezed.dart'; | ||
|
||
@freezed | ||
class NoteFolder with _$NoteFolder { | ||
const factory NoteFolder({ | ||
required String folderName, | ||
required List<Directory> folders, | ||
required List<UniversalNote> notes, | ||
}) = _NoteFolder; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark | ||
|
||
part of 'm_note_folder.dart'; | ||
|
||
// ************************************************************************** | ||
// FreezedGenerator | ||
// ************************************************************************** | ||
|
||
T _$identity<T>(T value) => value; | ||
|
||
final _privateConstructorUsedError = UnsupportedError( | ||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); | ||
|
||
/// @nodoc | ||
mixin _$NoteFolder { | ||
String get folderName => throw _privateConstructorUsedError; | ||
List<Directory> get folders => throw _privateConstructorUsedError; | ||
List<UniversalNote> get notes => throw _privateConstructorUsedError; | ||
|
||
@JsonKey(ignore: true) | ||
$NoteFolderCopyWith<NoteFolder> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} | ||
|
||
/// @nodoc | ||
abstract class $NoteFolderCopyWith<$Res> { | ||
factory $NoteFolderCopyWith( | ||
NoteFolder value, $Res Function(NoteFolder) then) = | ||
_$NoteFolderCopyWithImpl<$Res, NoteFolder>; | ||
@useResult | ||
$Res call( | ||
{String folderName, List<Directory> folders, List<UniversalNote> notes}); | ||
} | ||
|
||
/// @nodoc | ||
class _$NoteFolderCopyWithImpl<$Res, $Val extends NoteFolder> | ||
implements $NoteFolderCopyWith<$Res> { | ||
_$NoteFolderCopyWithImpl(this._value, this._then); | ||
|
||
// ignore: unused_field | ||
final $Val _value; | ||
// ignore: unused_field | ||
final $Res Function($Val) _then; | ||
|
||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? folderName = null, | ||
Object? folders = null, | ||
Object? notes = null, | ||
}) { | ||
return _then(_value.copyWith( | ||
folderName: null == folderName | ||
? _value.folderName | ||
: folderName // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
folders: null == folders | ||
? _value.folders | ||
: folders // ignore: cast_nullable_to_non_nullable | ||
as List<Directory>, | ||
notes: null == notes | ||
? _value.notes | ||
: notes // ignore: cast_nullable_to_non_nullable | ||
as List<UniversalNote>, | ||
) as $Val); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
abstract class _$$NoteFolderImplCopyWith<$Res> | ||
implements $NoteFolderCopyWith<$Res> { | ||
factory _$$NoteFolderImplCopyWith( | ||
_$NoteFolderImpl value, $Res Function(_$NoteFolderImpl) then) = | ||
__$$NoteFolderImplCopyWithImpl<$Res>; | ||
@override | ||
@useResult | ||
$Res call( | ||
{String folderName, List<Directory> folders, List<UniversalNote> notes}); | ||
} | ||
|
||
/// @nodoc | ||
class __$$NoteFolderImplCopyWithImpl<$Res> | ||
extends _$NoteFolderCopyWithImpl<$Res, _$NoteFolderImpl> | ||
implements _$$NoteFolderImplCopyWith<$Res> { | ||
__$$NoteFolderImplCopyWithImpl( | ||
_$NoteFolderImpl _value, $Res Function(_$NoteFolderImpl) _then) | ||
: super(_value, _then); | ||
|
||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? folderName = null, | ||
Object? folders = null, | ||
Object? notes = null, | ||
}) { | ||
return _then(_$NoteFolderImpl( | ||
folderName: null == folderName | ||
? _value.folderName | ||
: folderName // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
folders: null == folders | ||
? _value._folders | ||
: folders // ignore: cast_nullable_to_non_nullable | ||
as List<Directory>, | ||
notes: null == notes | ||
? _value._notes | ||
: notes // ignore: cast_nullable_to_non_nullable | ||
as List<UniversalNote>, | ||
)); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
class _$NoteFolderImpl implements _NoteFolder { | ||
const _$NoteFolderImpl( | ||
{required this.folderName, | ||
required final List<Directory> folders, | ||
required final List<UniversalNote> notes}) | ||
: _folders = folders, | ||
_notes = notes; | ||
|
||
@override | ||
final String folderName; | ||
final List<Directory> _folders; | ||
@override | ||
List<Directory> get folders { | ||
if (_folders is EqualUnmodifiableListView) return _folders; | ||
// ignore: implicit_dynamic_type | ||
return EqualUnmodifiableListView(_folders); | ||
} | ||
|
||
final List<UniversalNote> _notes; | ||
@override | ||
List<UniversalNote> get notes { | ||
if (_notes is EqualUnmodifiableListView) return _notes; | ||
// ignore: implicit_dynamic_type | ||
return EqualUnmodifiableListView(_notes); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'NoteFolder(folderName: $folderName, folders: $folders, notes: $notes)'; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
return identical(this, other) || | ||
(other.runtimeType == runtimeType && | ||
other is _$NoteFolderImpl && | ||
(identical(other.folderName, folderName) || | ||
other.folderName == folderName) && | ||
const DeepCollectionEquality().equals(other._folders, _folders) && | ||
const DeepCollectionEquality().equals(other._notes, _notes)); | ||
} | ||
|
||
@override | ||
int get hashCode => Object.hash( | ||
runtimeType, | ||
folderName, | ||
const DeepCollectionEquality().hash(_folders), | ||
const DeepCollectionEquality().hash(_notes)); | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
@pragma('vm:prefer-inline') | ||
_$$NoteFolderImplCopyWith<_$NoteFolderImpl> get copyWith => | ||
__$$NoteFolderImplCopyWithImpl<_$NoteFolderImpl>(this, _$identity); | ||
} | ||
|
||
abstract class _NoteFolder implements NoteFolder { | ||
const factory _NoteFolder( | ||
{required final String folderName, | ||
required final List<Directory> folders, | ||
required final List<UniversalNote> notes}) = _$NoteFolderImpl; | ||
|
||
@override | ||
String get folderName; | ||
@override | ||
List<Directory> get folders; | ||
@override | ||
List<UniversalNote> get notes; | ||
@override | ||
@JsonKey(ignore: true) | ||
_$$NoteFolderImplCopyWith<_$NoteFolderImpl> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:io' show Directory; | ||
|
||
import 'package:bloc/bloc.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:path/path.dart' as path; | ||
import 'package:path_provider/path_provider.dart' | ||
show getApplicationDocumentsDirectory; | ||
|
||
import '../../../data/note_folder/models/m_note_folder.dart'; | ||
import '../../../data/notes/universal/models/m_note.dart'; | ||
|
||
part 'note_folder_state.dart'; | ||
|
||
class NoteFolderCubit extends Cubit<NoteFolderState> { | ||
NoteFolderCubit() : super(const NoteFolderState(folders: [])); | ||
|
||
Future<void> getFolders() async { | ||
final documentsDirectory = await getApplicationDocumentsDirectory(); | ||
final noteFoldersDirectory = | ||
Directory(path.join(documentsDirectory.path, 'note-folders')); | ||
final folders = noteFoldersDirectory | ||
.listSync() | ||
.map( | ||
(event) => NoteFolder( | ||
folderName: path.basename(event.path), | ||
folders: [], | ||
notes: [ | ||
UniversalNote( | ||
noteId: 'noteId', | ||
userId: 'userId', | ||
title: 'title', | ||
text: 'text', | ||
isSyncWithCloud: true, | ||
isPrivate: false, | ||
isTrash: false, | ||
isFavorite: false, | ||
createdAt: DateTime.now(), | ||
updatedAt: DateTime.now(), | ||
) | ||
], | ||
), | ||
) | ||
.toList(); | ||
emit(NoteFolderState( | ||
folders: folders, | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
part of 'note_folder_cubit.dart'; | ||
|
||
class NoteFolderState extends Equatable { | ||
const NoteFolderState({required this.folders}); | ||
|
||
final List<NoteFolder> folders; | ||
|
||
@override | ||
List<Object?> get props => [ | ||
folders, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
lib/presentation/components/note/toolbar/buttons/full_screen.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart' show SystemChrome, SystemUiMode; | ||
|
||
class NoteToolbarFullScreenButton extends StatefulWidget { | ||
const NoteToolbarFullScreenButton({super.key}); | ||
|
||
@override | ||
State<NoteToolbarFullScreenButton> createState() => | ||
_NoteToolbarFullScreenButtonState(); | ||
} | ||
|
||
class _NoteToolbarFullScreenButtonState | ||
extends State<NoteToolbarFullScreenButton> { | ||
var _isFullScreen = false; | ||
|
||
@override | ||
void dispose() { | ||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | ||
|
||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (_isFullScreen) { | ||
return IconButton.filled( | ||
onPressed: () { | ||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | ||
|
||
setState(() { | ||
_isFullScreen = false; | ||
}); | ||
}, | ||
icon: const Icon(Icons.fullscreen), | ||
); | ||
} | ||
return IconButton( | ||
onPressed: () { | ||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); | ||
|
||
setState(() { | ||
_isFullScreen = true; | ||
}); | ||
}, | ||
icon: const Icon(Icons.fullscreen_exit), | ||
); | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.