-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a60b19d
commit 6521c22
Showing
16 changed files
with
251 additions
and
19 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
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,25 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:garcon/repositories/privacy/base_privacy_repo.dart'; | ||
|
||
import '../../../models/info.dart'; | ||
|
||
part 'privacy_event.dart'; | ||
|
||
part 'privacy_state.dart'; | ||
|
||
class PrivacyBloc extends Bloc<PrivacyEvent, PrivacyState> { | ||
final BasePrivacyRepository _privacyRepository; | ||
|
||
PrivacyBloc(this._privacyRepository) : super(PrivacyInitial()) { | ||
on<GetPrivacyEvent>((event, emit) async { | ||
emit(PrivacyLoading()); | ||
try { | ||
final privacy = await _privacyRepository.getPrivacy().first; | ||
emit(PrivacyLoaded(privacy)); | ||
} catch (e) { | ||
emit(PrivacyError('Failed to fetch terms info: $e')); | ||
} | ||
}); | ||
} | ||
} |
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,10 @@ | ||
part of 'privacy_bloc.dart'; | ||
|
||
abstract class PrivacyEvent extends Equatable { | ||
const PrivacyEvent(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class GetPrivacyEvent extends PrivacyEvent {} |
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,30 @@ | ||
part of 'privacy_bloc.dart'; | ||
|
||
abstract class PrivacyState extends Equatable { | ||
const PrivacyState(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class PrivacyInitial extends PrivacyState {} | ||
|
||
class PrivacyLoading extends PrivacyState {} | ||
|
||
class PrivacyLoaded extends PrivacyState { | ||
final Info privacy; | ||
|
||
const PrivacyLoaded(this.privacy); | ||
|
||
@override | ||
List<Object> get props => [privacy]; | ||
} | ||
|
||
class PrivacyError extends PrivacyState { | ||
final String error; | ||
|
||
const PrivacyError(this.error); | ||
|
||
@override | ||
List<Object> get props => [error]; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,73 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:garcon/configs/configs.dart'; | ||
import 'package:garcon/core/core.dart'; | ||
import 'package:garcon/application/application.dart'; | ||
import '../widgets.dart'; | ||
|
||
class PrivacyScreen extends StatelessWidget { | ||
class PrivacyScreen extends StatefulWidget { | ||
const PrivacyScreen({super.key}); | ||
|
||
@override | ||
State<PrivacyScreen> createState() => _PrivacyScreenState(); | ||
} | ||
|
||
class _PrivacyScreenState extends State<PrivacyScreen> { | ||
@override | ||
void initState() { | ||
context.read<PrivacyBloc>().add(GetPrivacyEvent()); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Placeholder(); | ||
return Scaffold( | ||
appBar: customAppBar(context: context, title: "Privacy Policy"), | ||
body: BlocBuilder<PrivacyBloc, PrivacyState>( | ||
builder: (context, state) { | ||
if (state is PrivacyError) { | ||
return Center( | ||
child: Text( | ||
"error loading info", | ||
style: AppText.h3b, | ||
), | ||
); | ||
} else if (state is PrivacyLoading) { | ||
return const Center( | ||
child: CircularProgressIndicator(), | ||
); | ||
} else if (state is PrivacyLoaded) { | ||
return Padding( | ||
padding: Space.hf(1.5), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Space.yf(1.5), | ||
Text( | ||
state.privacy.header1.capitalize(), | ||
style: AppText.h3b?.copyWith(height: 2), | ||
), | ||
verseText( | ||
text: state.privacy.subheader1, | ||
withPadding: false, | ||
), | ||
Space.yf(1.5), | ||
Text( | ||
state.privacy.header2.capitalize(), | ||
style: AppText.h3b?.copyWith(height: 2), | ||
), | ||
verseText( | ||
text: state.privacy.subheader2, | ||
withPadding: false, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
return const SizedBox.shrink(); | ||
}, | ||
), | ||
); | ||
; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,74 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:garcon/core/core.dart'; | ||
import 'package:garcon/application/application.dart'; | ||
import 'package:garcon/configs/configs.dart'; | ||
import 'package:garcon/presentation/widgets.dart'; | ||
|
||
class TermsScreen extends StatelessWidget { | ||
class TermsScreen extends StatefulWidget { | ||
const TermsScreen({super.key}); | ||
|
||
@override | ||
State<TermsScreen> createState() => _TermsScreenState(); | ||
} | ||
|
||
class _TermsScreenState extends State<TermsScreen> { | ||
@override | ||
void initState() { | ||
context.read<TermsBloc>().add( | ||
GetTermsEvent(), | ||
); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Placeholder(); | ||
return Scaffold( | ||
appBar: customAppBar(context: context, title: "Terms of Service"), | ||
body: BlocBuilder<TermsBloc, TermsState>( | ||
builder: (context, state) { | ||
if (state is TermsError) { | ||
return Center( | ||
child: Text( | ||
"error loading info", | ||
style: AppText.h3b, | ||
), | ||
); | ||
} else if (state is TermsLoading) { | ||
return const Center( | ||
child: CircularProgressIndicator(), | ||
); | ||
} else if (state is TermsLoaded) { | ||
return Padding( | ||
padding: Space.hf(1.5), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Space.yf(1.5), | ||
Text( | ||
state.terms.header1.capitalize(), | ||
style: AppText.h3b?.copyWith(height: 2), | ||
), | ||
verseText( | ||
text: state.terms.subheader1, | ||
withPadding: false, | ||
), | ||
Space.yf(1.5), | ||
Text( | ||
state.terms.header2.capitalize(), | ||
style: AppText.h3b?.copyWith(height: 2), | ||
), | ||
verseText( | ||
text: state.terms.subheader2, | ||
withPadding: false, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
return const SizedBox.shrink(); | ||
}, | ||
), | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import '../../models/models.dart'; | ||
|
||
abstract class BasePrivacyRepository{ | ||
Stream<Info> getPrivacy(); | ||
} |
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,19 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:garcon/models/info.dart'; | ||
import 'package:garcon/repositories/privacy/base_privacy_repo.dart'; | ||
|
||
class PrivacyRepository extends BasePrivacyRepository { | ||
final FirebaseFirestore _firebaseFirestore; | ||
|
||
PrivacyRepository({FirebaseFirestore? firebaseFirestore}) | ||
: _firebaseFirestore = firebaseFirestore ?? FirebaseFirestore.instance; | ||
|
||
@override | ||
Stream<Info> getPrivacy() { | ||
return _firebaseFirestore | ||
.collection("info") | ||
.doc("privacy") | ||
.snapshots() | ||
.map((snap) => Info.fromSnapShot(snap)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import '../../models/models.dart'; | ||
|
||
abstract class BaseTermsRepository{ | ||
Stream<Terms> getTerms(); | ||
Stream<Info> getTerms(); | ||
} |
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