-
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
0092b3e
commit 862c6bf
Showing
10 changed files
with
227 additions
and
101 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
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,61 @@ | ||
import 'package:buzz/buzz.dart'; | ||
import 'package:core/core.dart'; | ||
import 'package:example/shared/components/labeled_section.dart'; | ||
import 'package:example/shared/modules/trivia/components/trivia_data_view.dart'; | ||
import 'package:example/shared/modules/trivia/page.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
class JoinView extends StatelessWidget { | ||
const JoinView({ | ||
Key? key, | ||
required this.joinCode, | ||
}) : super(key: key); | ||
|
||
final String joinCode; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final controller = Get.put( | ||
JoinViewController(joinCode), | ||
tag: joinCode, | ||
); | ||
|
||
return Obx(() { | ||
final joinCode = controller.joinCode(); | ||
|
||
return LabeledSection( | ||
label: 'joinCode: $joinCode', | ||
child: Column( | ||
children: [ | ||
const TriviaDataView( | ||
hostName: 'hostName', | ||
triviaName: 'hostName', | ||
triviaDescription: 'hostName', | ||
triviaMainQuestion: 'hostName', | ||
), | ||
MainActionWidget( | ||
action: MainAction( | ||
label: 'Join to $joinCode', | ||
onPressed: () { | ||
debugPrint('$runtimeType onJoinConfirmTap'); | ||
controller.onJoinConfirmTap('someId'); | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
}); | ||
} | ||
} | ||
|
||
class JoinViewController extends GetxController { | ||
late Rx<String> joinCode; | ||
|
||
JoinViewController(String code) : joinCode = code.obs; | ||
|
||
void onJoinConfirmTap(String triviaId) { | ||
Buzz.fire(NavigateToTrivia(triviaId: triviaId)); | ||
} | ||
} |
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,30 +1,29 @@ | ||
import 'package:core/core.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
import 'join_view.dart'; | ||
|
||
class JoinPage extends StatelessWidget { | ||
static const String routeName = '/join/join_code'; | ||
static const String routeName = '/join/:join_code'; | ||
static const String pageName = 'JoinPage'; | ||
|
||
const JoinPage({ | ||
Key? key, | ||
required this.onNewTriviaGameTap, | ||
}) : super(key: key); | ||
|
||
final Function() onNewTriviaGameTap; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return BasePage( | ||
name: '$runtimeType', | ||
actions: [ | ||
MainAction( | ||
label: 'New trivia game', | ||
onPressed: () { | ||
debugPrint('$runtimeType onNewTriviaGameTap'); | ||
onNewTriviaGameTap(); | ||
}, | ||
), | ||
], | ||
final joinCode = Get.parameters['join_code']; | ||
if (joinCode == null) { | ||
throw UnimplementedError( | ||
'join_code must not be null', | ||
); | ||
} | ||
|
||
return Scaffold( | ||
body: JoinView( | ||
joinCode: joinCode, | ||
), | ||
); | ||
} | ||
} |
10 changes: 8 additions & 2 deletions
10
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
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
Oops, something went wrong.