Индикатор панели вкладок не меняется при трепетанииAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Индикатор панели вкладок не меняется при трепетании

Сообщение Anonymous »

В дизайне используется панель вкладок, а при нажатии кнопки «Развернуть» медиафайл сборки передается в MaterialPageRoute. Некоторые логические переменные используются для отключения просмотра и вкладок, когда они недоступны. При расширении при изменении индикатора вкладки не изменяется, отображается отключение при выборе. Я попытался создать новую панель вкладок для кнопки развертывания, проблема осталась та же.

Код: Выделить всё

 Widget _buildTab({bool showInModal = false}) {
if(showInModal){
_tabController = TabController(vsync: this, length: 4);
}

return ignoreImage && ignoreVideo && ignoreB2B &&  ignoreCertificate
? Container()
: DefaultTabController(
length: 4,
child: TabBar(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
indicatorSize: TabBarIndicatorSize.tab,
tabAlignment: TabAlignment.start,
isScrollable: true,
padding: EdgeInsets.zero,
labelPadding: EdgeInsets.zero,
tabs: [
Tab(
height: 30,
// text: "Image",
child: Container(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Text(
'Image',
style: ignoreImage ? ignoreStyle : const TextStyle(),
),
),
),
Tab(
height: 30,
child: Container(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Text(
'Video',
style: ignoreVideo ? ignoreStyle : const TextStyle(),
),
),
),
Tab(
height: 30,
child: Container(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Text(
'B2B Sparkle',
style: ignoreB2B ? ignoreStyle : const TextStyle(),
),
),
),
Tab(
height: 30,
child: Container(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Text(
'Certificate',
style:
ignoreCertificate ? ignoreStyle : const TextStyle(),
),
),
),
],
onTap:  (index) {
if (index == 0) {
if (photoUrlList.isNotEmpty) {
tabIndexValueNotifier.value = index;
leftArrowIndicatorValueNotifier.value = 0;
rightArrowIndicatorValueNotifier.value = 0;
photoNameValueNotifier.value = 0;
rightArrowIndicatorValueNotifier.notifyListeners();
leftArrowIndicatorValueNotifier.notifyListeners();
} else {
if (_tabController.indexIsChanging) {
_tabController.index = _tabController.previousIndex;
} else {
return;
}
}
} else if (index == 1) {
if (!ignoreVideo) {
tabIndexValueNotifier.value = index;
webVideoKey.currentState?.reloadWebView();
} else {
if (_tabController.indexIsChanging) {
_tabController.index = _tabController.previousIndex;
} else {
return;
}
}
} else if (index == 2) {
if (!ignoreB2B) {
tabIndexValueNotifier.value = index;
webB2bKey.currentState?.reloadWebView();
} else {
if (_tabController.indexIsChanging) {
_tabController.index = _tabController.previousIndex;
} else {
return;
}
}
} else if (index == 3) {
if (certificateUrlList.isNotEmpty) {
tabIndexValueNotifier.value = index;
} else {
if (_tabController.indexIsChanging) {
_tabController.index = _tabController.previousIndex;
} else {
return;
}
}
} else {
tabIndexValueNotifier.value = index;
}
},
),
);
}
Метод _buildMedia

Код: Выделить всё

 Widget _buildMedia(
BuildContext context, {
bool isShownInModal = false,
}) {
final effectivePageViewController = isShownInModal
? PageController(initialPage: photoNameValueNotifier.value)
: mediaPageViewController;

return ignoreImage && ignoreVideo && ignoreB2B &&  ignoreCertificate
? Container(
height: 350,
decoration: BoxDecoration(
color: CoreColor.neutral100,
borderRadius: BorderRadius.circular(4),
),
child: Center(child: Assets.coreSvgs.imagePlaceholder.svg()),
)
: SizedBox(
height: isShownInModal ? null : 320,
child: Column(
children: [
_buildTab(showInModal: true),
Expanded(
child: BlocBuilder(
builder: (context, state) {
return LayoutBuilder(
builder: (context, constraints) {
return ValueListenableBuilder(
valueListenable: tabIndexValueNotifier,
builder: (context, value, _) {
if (value == 0) {
return _buildPhotoView(
context,
effectivePageViewController,
isShownInModal: isShownInModal,
);
} else if (value == 1) {
return _buildVideoWebView(
isShownInModal,
constraints,
);
} else if (value == 2) {
return _buildB2BWebView(
isShownInModal, constraints);
} else if (value == 3) {
return _buildCertificateView(
context,
effectivePageViewController,
isShownInModal: isShownInModal,
);
} else {
return const SizedBox();
}
},
);
},
);
},
),
),
],
),
);
}
На кнопке «Развернуть»

Код: Выделить всё

CoreIconButton(
tooltip: 'frame',
child: const PhosphorIcon(
PhosphorIconsRegular.cornersOut,
color: CoreColor.neutral900,
),
onPressed: () async {
webB2b2Key.currentState?.reloadWebView();
final page = MaterialPageRoute(
builder: (newContext) {
return Theme(
data: CoreTheme.light,
child: BlocProvider.value(
value:
context.read(),
child: Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.stretch,
children: [
16.height,
Align(
alignment: Alignment.topRight,
child: Padding(
padding:
const EdgeInsets.only(right: 16),
child: InkWell(
onTap: context.pop,
child: const PhosphorIcon(
PhosphorIconsRegular.x,
color:  CoreColor.neutral900,
),
),
),
),
const Spacer(),
Expanded(
flex: 7,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: kScreenPadding,
),
child: _buildMedia(
newContext,
isShownInModal: true,
),
),
),
16.height,
photoUrlList.isNotEmpty
? _buildDotsIndicator()
: Container(),
photoUrlList.isNotEmpty
? 16.height
: 0.height,
_buildAssetName(),
16.height,
_buildActions(false),
const Spacer(),
],
),
),
),
),
);
},
);
Navigator.of(context).push(page);
},
)
Изображение


Подробнее здесь: https://stackoverflow.com/questions/787 ... in-flutter
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»