-
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.
feat: add trivia page view components
- Loading branch information
1 parent
97783f3
commit 6a973b3
Showing
8 changed files
with
166 additions
and
13 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
41 changes: 41 additions & 0 deletions
41
example/lib/shared/modules/trivia/components/copy_join_link_view.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,41 @@ | ||
import 'package:core/core.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class CopyJoinLinkView extends StatelessWidget { | ||
const CopyJoinLinkView({ | ||
Key? key, | ||
required this.joinLink, | ||
required this.onCopyJoinLinkTap, | ||
}) : super(key: key); | ||
|
||
final String joinLink; | ||
final Function(String) onCopyJoinLinkTap; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
Container( | ||
decoration: BoxDecoration( | ||
border: Border.all( | ||
color: const Color.fromARGB(255, 51, 204, 255), | ||
width: 1, | ||
), | ||
borderRadius: BorderRadius.circular(5), | ||
shape: BoxShape.rectangle, | ||
), | ||
child: Text(joinLink), | ||
), | ||
MainActionWidget( | ||
action: MainAction( | ||
label: 'Copy!', | ||
onPressed: () { | ||
debugPrint('$runtimeType onStartPlayTap'); | ||
onCopyJoinLinkTap(joinLink); | ||
}, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
example/lib/shared/modules/trivia/components/trivia_data_view.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,50 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class TriviaDataView extends StatelessWidget { | ||
const TriviaDataView({ | ||
Key? key, | ||
required this.hostName, | ||
required this.triviaName, | ||
required this.triviaDescription, | ||
required this.triviaMainQuestion, | ||
}) : super(key: key); | ||
|
||
final String hostName; | ||
final String triviaName; | ||
final String triviaDescription; | ||
final String triviaMainQuestion; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
_TriviaDataViewLabel(hostName), | ||
_TriviaDataViewLabel(triviaName), | ||
_TriviaDataViewLabel(triviaDescription), | ||
_TriviaDataViewLabel(triviaMainQuestion), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _TriviaDataViewLabel extends StatelessWidget { | ||
const _TriviaDataViewLabel( | ||
this.content, { | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
final String content; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric( | ||
vertical: 16, | ||
horizontal: 20, | ||
), | ||
child: Center( | ||
child: Text(content), | ||
), | ||
); | ||
} | ||
} |
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 @@ | ||
|
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,41 @@ | ||
import 'package:example/shared/modules/trivia/components/trivia_data_view.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('TriviaDataView test1', (tester) async { | ||
// Given | ||
await tester.pumpWidget( | ||
const Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: MediaQuery( | ||
data: MediaQueryData(), | ||
child: TriviaDataView( | ||
hostName: 'Luis', | ||
triviaName: 'High school times', | ||
triviaDescription: | ||
'Search the song on the Spotify app, and paste the share link!', | ||
triviaMainQuestion: | ||
'What is that song that reminds you of high school times?', | ||
), | ||
), | ||
), | ||
); | ||
|
||
// When | ||
final hostNameFinder = find.text('Luis'); | ||
final nameFinder = find.text('High school times'); | ||
final descriptionFinder = find.text( | ||
'Search the song on the Spotify app, and paste the share link!', | ||
); | ||
final questionFinder = find.text( | ||
'What is that song that reminds you of high school times?', | ||
); | ||
|
||
// Then | ||
expect(hostNameFinder, findsOneWidget); | ||
expect(nameFinder, findsOneWidget); | ||
expect(descriptionFinder, findsOneWidget); | ||
expect(questionFinder, findsOneWidget); | ||
}); | ||
} |